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()); }
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()); }