Beispiel #1
0
 private List<Expression> parseExpressionList() {
   List<Expression> expressions = new ArrayList<Expression>();
   do {
     Expression expression = parseExpression();
     expressions.add(expression);
   } while (myLexer.nextToken() == TokenType.COMMA);
   myLexer.pushBack();
   return expressions;
 }
Beispiel #2
0
 private StatementsNode parseStatements(boolean insideGroup) {
   List<Statement> statements = new ArrayList<Statement>();
   do {
     Statement statement = parseStatement();
     statements.add(statement);
     TokenType type = myLexer.nextToken();
     myLexer.pushBack();
     if (type == TokenType.EOF || insideGroup && type == TokenType.RBRACE) {
       break;
     }
   } while (true);
   return new StatementsNode(statements);
 }
Beispiel #3
-1
 private Statement parseFunctionDeclaration() {
   tokenExpected(TokenType.IDENTIFIER);
   String name = myLexer.getToken();
   tokenExpected(TokenType.LPAREN);
   List<String> parameters = new ArrayList<String>();
   do {
     tokenExpected(TokenType.IDENTIFIER);
     parameters.add(myLexer.getToken());
   } while (myLexer.nextToken() == TokenType.COMMA);
   myLexer.pushBack();
   tokenExpected(TokenType.RPAREN);
   Statement body = parseStatement();
   return new FunctionDeclaration(name, parameters, body);
 }