authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-02 12:46:18-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-02 12:46:18-07:00
log136a9a9d6b657e29680ca53f158f46eb5b92e9e7
tree08dbb09049745d9b2529dd5bf33394632b3b3eb0
parent4b9e782d37a334740a04190e3b3dd375f41ef3fe

variable declarations must be followed by semicolon


1 files changed, 6 insertions(+), 4 deletions(-)

src/parser.cpp+6-4
...@@ -1598,8 +1598,6 @@ static AstNode *ast_parse_variable_declaration_expr(ParseContext *pc, size_t *to...@@ -1598,8 +1598,6 @@ static AstNode *ast_parse_variable_declaration_expr(ParseContext *pc, size_t *to
1598 *token_index += 1;1598 *token_index += 1;
1599 if (eq_or_colon->id == TokenIdEq) {1599 if (eq_or_colon->id == TokenIdEq) {
1600 node->data.variable_declaration.expr = ast_parse_expression(pc, token_index, true);1600 node->data.variable_declaration.expr = ast_parse_expression(pc, token_index, true);
1601
1602 return node;
1603 } else if (eq_or_colon->id == TokenIdColon) {1601 } else if (eq_or_colon->id == TokenIdColon) {
1604 node->data.variable_declaration.type = ast_parse_type_expr(pc, token_index, true);1602 node->data.variable_declaration.type = ast_parse_type_expr(pc, token_index, true);
1605 Token *eq_token = &pc->tokens->at(*token_index);1603 Token *eq_token = &pc->tokens->at(*token_index);
...@@ -1608,11 +1606,15 @@ static AstNode *ast_parse_variable_declaration_expr(ParseContext *pc, size_t *to...@@ -1608,11 +1606,15 @@ static AstNode *ast_parse_variable_declaration_expr(ParseContext *pc, size_t *to
16081606
1609 node->data.variable_declaration.expr = ast_parse_expression(pc, token_index, true);1607 node->data.variable_declaration.expr = ast_parse_expression(pc, token_index, true);
1610 }1608 }
1611
1612 return node;
1613 } else {1609 } else {
1614 ast_invalid_token_error(pc, eq_or_colon);1610 ast_invalid_token_error(pc, eq_or_colon);
1615 }1611 }
1612
1613 // peek ahead and ensure that all variable declarations are followed by a semicolon
1614 Token *semicolon_token = &pc->tokens->at(*token_index);
1615 ast_expect_token(pc, semicolon_token, TokenIdSemicolon);
1616
1617 return node;
1616}1618}
16171619
1618/*1620/*