public object Visit(IntExpressionNode n, object o) { n.IntLiteral.Accept(this, null); return(null); }
public object Visit(IntExpressionNode n, object o) { return(null); }
private ExpressionNode Primary() { ExpressionNode itsAST = null; // in case there is a syntactic error SourceCodePosition itsPos = _currentToken.SourcePosition; if (_currentToken.Type == Token.TokenType.LeftParen) { Accept(Token.TokenType.LeftParen); itsAST = Expression(); Accept(Token.TokenType.RightParen); } else if (Array.Exists(_literalFirstSet, e => e == _currentToken.Type)) { switch (_currentToken.Type) { case Token.TokenType.IntLiteral: IntLiteralNode intLiteral = new IntLiteralNode(_currentToken.Value, _currentToken.SourcePosition); Accept(Token.TokenType.IntLiteral); itsAST = new IntExpressionNode(intLiteral, itsPos); break; case Token.TokenType.RealLiteral: RealLiteralNode realLiteral = new RealLiteralNode(_currentToken.Value, _currentToken.SourcePosition); Accept(Token.TokenType.RealLiteral); itsAST = new RealExpressionNode(realLiteral, itsPos); break; case Token.TokenType.StringLiteral: StringLiteralNode stringLiteral = new StringLiteralNode(_currentToken.Value, _currentToken.SourcePosition); Accept(Token.TokenType.StringLiteral); itsAST = new StringExpressionNode(stringLiteral, itsPos); break; case Token.TokenType.BooleanLiteral: BooleanLiteralNode booleanLiteral = new BooleanLiteralNode(_currentToken.Value, _currentToken.SourcePosition); Accept(Token.TokenType.BooleanLiteral); itsAST = new BooleanExpressionNode(booleanLiteral, itsPos); break; case Token.TokenType.Null: NullLiteralNode nullLiteral = new NullLiteralNode(_currentToken.Value, _currentToken.SourcePosition); Accept(Token.TokenType.Null); itsAST = new NullExpressionNode(nullLiteral, itsPos); break; default: itsAST = null; // should not happen break; } } else if (_currentToken.Type == Token.TokenType.Identifier) { itsAST = MemberReference(); } else if (_currentToken.Type == Token.TokenType.This) { itsAST = ThisReference(); } else if (_currentToken.Type == Token.TokenType.New) { itsAST = Instantiation(); } else { Error("The token is invalid in the current context"); } return(itsAST); }