Changeset 42bce4e


Ignore:
Timestamp:
Mar 11, 2026, 5:42:49 PM (44 hours ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
4c5ce70
Parents:
4acd1f8
Message:

during parsing, wrap loop else-clause in compound statement if it is only an expression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r4acd1f8 r42bce4e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 21 18:44:44 2025
    13 // Update Count     : 7296
     12// Last Modified On : Wed Mar 11 11:09:33 2026
     13// Update Count     : 7300
    1414//
    1515
     
    14151415                { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
    14161416        | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA
    1417                 { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); }
     1417                { $$ = new StatementNode( build_while( yylloc, $3, maybe_build_compound( yylloc, $5 ), maybe_build_compound( yylloc, $7 ) ) ); }
    14181418        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    14191419                { $$ = new StatementNode( build_do_while( yylloc, NEW_ONE, maybe_build_compound( yylloc, $2 ) ) ); }
     
    14261426                { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ) ) ); }
    14271427        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
    1428                 { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ), $8 ) ); }
     1428                { $$ = new StatementNode( build_do_while( yylloc, $5, maybe_build_compound( yylloc, $2 ), maybe_build_compound( yylloc, $8 ) ) ); }
    14291429        | FOR '(' ')' statement                                                         %prec THEN // CFA => for ( ;; )
    14301430                { $$ = new StatementNode( build_for( yylloc, new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( yylloc, $4 ) ) ); }
     
    14371437                { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ) ) ); }
    14381438        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    1439                 { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ), $7 ) ); }
     1439                { $$ = new StatementNode( build_for( yylloc, $3, maybe_build_compound( yylloc, $5 ), maybe_build_compound( yylloc, $7 ) ) ); }
    14401440        ;
    14411441
Note: See TracChangeset for help on using the changeset viewer.