Changeset a73c16e


Ignore:
Timestamp:
Oct 11, 2021, 11:10:33 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
efc8f3e
Parents:
d4d4ac8
Message:

parse loop default-block for while/do/for

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rd4d4ac8 ra73c16e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct  8 06:57:16 2021
    13 // Update Count     : 5086
     12// Last Modified On : Mon Oct 11 16:14:04 2021
     13// Update Count     : 5131
    1414//
    1515
     
    346346%type<en> case_value
    347347%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    348 %type<sn> iteration_statement                   jump_statement
     348%type<sn> iteration_statement                   loop_default_opt                        jump_statement
    349349%type<sn> expression_statement                  asm_statement
    350350%type<sn> with_statement
     
    11921192
    11931193iteration_statement:
    1194         WHILE '(' push if_control_expression ')' statement pop
    1195                 { $$ = new StatementNode( build_while( $4, maybe_build_compound( $6 ) ) ); }
     1194        WHILE '(' push if_control_expression ')' loop_default_opt statement pop
     1195                { $$ = new StatementNode( build_while( $4, maybe_build_compound( $7 ) ) ); }
    11961196        | WHILE '(' ')' statement                                                       // CFA => while ( 1 )
    11971197                { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); }
    1198         | DO statement WHILE '(' comma_expression ')' ';'
     1198        | DO statement WHILE '(' comma_expression ')' loop_default_opt ';'
    11991199                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
    12001200        | DO statement WHILE '(' ')' ';'                                        // CFA => do while( 1 )
    12011201                { $$ = new StatementNode( build_do_while( new ExpressionNode( build_constantInteger( *new string( "1" ) ) ), maybe_build_compound( $2 ) ) ); }
    1202         | FOR '(' push for_control_expression_list ')' statement pop
    1203                 { $$ = new StatementNode( build_for( $4, maybe_build_compound( $6 ) ) ); }
     1202        | FOR '(' push for_control_expression_list ')' loop_default_opt statement pop
     1203                { $$ = new StatementNode( build_for( $4, maybe_build_compound( $7 ) ) ); }
    12041204        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
    12051205                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }
     1206        ;
     1207
     1208loop_default_opt:
     1209        // empty
     1210                { $$ = nullptr; }
     1211        | DEFAULT statement ELSE
     1212                { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
     1213                // { $$ = $2; }
    12061214        ;
    12071215
Note: See TracChangeset for help on using the changeset viewer.