public Node Call() { var result = new Call(); Expect(TokenCategory.LEFT_PAR); if (firstOfExpression.Contains(CurrentToken)) { result.Add(Expression()); while (CurrentToken == TokenCategory.COMA) { Expect(TokenCategory.COMA); result.Add(Expression()); } } Expect(TokenCategory.RIGHT_PAR); return(result); }
public Node Call() { var result = new Call() { AnchorToken = Expect(TokenCategory.PARENTHESIS_OPEN) }; if (CurrentToken != TokenCategory.PARENTHESIS_CLOSE) { result.Add(Expression()); while (CurrentToken == TokenCategory.COMMA) { Expect(TokenCategory.COMMA); result.Add(Expression()); } } Expect(TokenCategory.PARENTHESIS_CLOSE); return(result); }
/**************************************************************** * Simple Expression ***************************************************************/ public Node SimpleExpression() { switch (CurrentToken) { case TokenCategory.CALL: var callSub = new Call(); callSub.AnchorToken = Expect(TokenCategory.CALL); callSub.Add(IdentifierFound()); return(callSub); case TokenCategory.IDENTIFIER: return(IdentifierFound()); case TokenCategory.INT_LITERAL: return(new IntLiteral() { AnchorToken = Expect(TokenCategory.INT_LITERAL) }); case TokenCategory.LOGIC_LITERAL: return(new LogicLiteral() { AnchorToken = Expect(TokenCategory.LOGIC_LITERAL) }); case TokenCategory.REAL: return(RealFunction()); case TokenCategory.REAL_LITERAL: return(new RealLiteral() { AnchorToken = Expect(TokenCategory.REAL_LITERAL) }); case TokenCategory.STRING_LITERAL: return(new StringLiteral() { AnchorToken = Expect(TokenCategory.STRING_LITERAL) }); case TokenCategory.PARENTHESIS_OPEN: Expect(TokenCategory.PARENTHESIS_OPEN); var result = Expression(); Expect(TokenCategory.PARENTHESIS_CLOSE); return(result); default: throw new SyntaxError(firstOfSimpleExpression, tokenStream.Current); } }