new ForStatement parsing test and small grammar fix

This commit is contained in:
Lefteris Karapetsas 2014-12-15 17:54:29 +01:00
parent f7029726be
commit 3f2600bb31
2 changed files with 1 additions and 2 deletions

View File

@ -381,7 +381,6 @@ ASTPointer<ForStatement> Parser::parseForStatement()
ASTPointer<Expression> conditionExpression = parseExpression();
expectToken(Token::SEMICOLON);
ASTPointer<ExpressionStatement> loopExpression = parseExpressionStatement();
expectToken(Token::SEMICOLON);
expectToken(Token::RPAREN);
ASTPointer<Statement> body = parseStatement();
nodeFactory.setEndPositionFromNode(body);

View File

@ -20,7 +20,7 @@ Statement = IfStatement | WhileStatement | Block |
IfStatement = 'if' '(' Expression ')' Statement ( 'else' Statement )?
WhileStatement = 'while' '(' Expression ')' Statement
ForStatement = 'for' '(' Expressionstatement Expression Expressionstatement ')' Statement
ForStatement = 'for' '(' VardefOrExpressionstatement ';' Expression ';' Expressionstatement ')' Statement
Continue = 'continue' ';'
Break = 'break' ';'
Return = 'return' Expression? ';'