예제 #1
0
        public static ExpressionSyntax TranspileExpression(this TokenNode tokenNode)
        {
            if (tokenNode.TokenType == SyntaxTokenType.AlphanumericIdentifier)
            {
                return(SyntaxFactory.ParseExpression(
                           _reservedKeywords.Value.Contains(tokenNode.ValueText)
                        ? $"{AntiReservedKeywordConflictPrefix}{tokenNode.ValueText}"
                        : tokenNode.ValueText));
            }

            return(tokenNode.TranspileConstantExpression());
        }
예제 #2
0
        public static ExpressionSyntax TranspileExpression(this TokenNode tokenNode, out bool @const)
        {
            if (tokenNode.TokenType == SyntaxTokenType.AlphanumericIdentifier)
            {
                // Can be true, but too much effort to detect if the assigned identifier itself is also constant.
                @const = false;

                return(SyntaxFactory.ParseExpression(
                           _reservedKeywords.Value.Contains(tokenNode.ValueText)
                        ? $"{AntiReservedKeywordConflictPrefix}{tokenNode.ValueText}"
                        : tokenNode.ValueText));
            }

            @const = true;

            return(tokenNode.TranspileConstantExpression());
        }