Ignore:
Timestamp:
May 4, 2022, 5:12:47 PM (5 months ago)
Author:
caparsons <caparson@…>
Branches:
master, pthread-emulation, qualifiedEnum
Children:
86b8d16, f75e25b
Parents:
ec57856
Message:

fixed loop else parse bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rec57856 r6825167  
    12241224                { $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); }
    12251225        | WHILE '(' ')' statement ELSE statement                        // CFA
    1226                 { SemanticWarning( yylloc, Warning::SuperfluousElse ); }
     1226                { $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); SemanticWarning( yylloc, Warning::SuperfluousElse ); }
    12271227        | WHILE '(' conditional_declaration ')' statement       %prec THEN
    12281228                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
     
    12321232                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); }
    12331233        | DO statement WHILE '(' ')' ELSE statement                     // CFA
    1234                 { SemanticWarning( yylloc, Warning::SuperfluousElse ); }
     1234                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); SemanticWarning( yylloc, Warning::SuperfluousElse ); }
    12351235        | DO statement WHILE '(' comma_expression ')' ';'       %prec THEN
    12361236                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
     
    12391239        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
    12401240                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }
     1241        | FOR '(' ')' statement ELSE statement                  // CFA
     1242                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); SemanticWarning( yylloc, Warning::SuperfluousElse ); }
    12411243        | FOR '(' for_control_expression_list ')' statement     %prec THEN
    12421244                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
Note: See TracChangeset for help on using the changeset viewer.