Improve error recovery in parse_if() by adding T_else to the anchors earlier.
authorChristoph Mallon <christoph.mallon@gmx.de>
Thu, 3 May 2012 16:22:04 +0000 (18:22 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Fri, 4 May 2012 04:34:18 +0000 (06:34 +0200)
Also remove the unnecessary anchor '{'.

parser.c

index 9b6c138..a04e664 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -9231,7 +9231,7 @@ static statement_t *parse_if(void)
 
        PUSH_PARENT(statement);
 
-       add_anchor_token('{');
+       add_anchor_token(T_else);
 
        expression_t *const expr = parse_condition();
        statement->ifs.condition = expr;
@@ -9239,9 +9239,6 @@ static statement_t *parse_if(void)
         *             scalar type. */
        semantic_condition(expr, "condition of 'if'-statment");
 
-       rem_anchor_token('{');
-
-       add_anchor_token(T_else);
        statement_t *const true_stmt = parse_inner_statement();
        statement->ifs.true_statement = true_stmt;
        rem_anchor_token(T_else);