Changeset efc8f3e


Ignore:
Timestamp:
Oct 15, 2021, 9:25:30 AM (7 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
55cbff8
Parents:
a73c16e
Message:

change loop default-block for while/do/for to Python style

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    ra73c16e refc8f3e  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Oct 11 16:14:04 2021
    13 // Update Count     : 5131
     12// Last Modified On : Fri Oct 15 09:20:17 2021
     13// Update Count     : 5163
    1414//
    1515
     
    6969        // 2. String encodings are transformed into canonical form (one encoding at start) so the encoding can be found
    7070        //    without searching the string, e.g.: "abc" L"def" L"ghi" => L"abc" "def" "ghi". Multiple encodings must match,
    71         //    i.e., u"a" U"b" L"c" is disallowed.
     71        //    e.g., u"a" U"b" L"c" is disallowed.
    7272
    7373        if ( from[0] != '"' ) {                                                         // encoding ?
     
    346346%type<en> case_value
    347347%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    348 %type<sn> iteration_statement                   loop_default_opt                        jump_statement
     348%type<sn> iteration_statement                   jump_statement
    349349%type<sn> expression_statement                  asm_statement
    350350%type<sn> with_statement
     
    11921192
    11931193iteration_statement:
    1194         WHILE '(' push if_control_expression ')' loop_default_opt statement pop
    1195                 { $$ = new StatementNode( build_while( $4, maybe_build_compound( $7 ) ) ); }
    1196         | WHILE '(' ')' statement                                                       // CFA => while ( 1 )
     1194        WHILE '(' ')' statement                                                         // CFA => while ( 1 )
    11971195                { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); }
    1198         | DO statement WHILE '(' comma_expression ')' loop_default_opt ';'
    1199                 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
     1196        | WHILE '(' if_control_expression ')' statement         %prec THEN
     1197                { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); }
     1198        | WHILE '(' if_control_expression ')' statement ELSE statement // CFA
     1199                { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    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 ')' loop_default_opt statement pop
    1203                 { $$ = new StatementNode( build_for( $4, maybe_build_compound( $7 ) ) ); }
     1202        | DO statement WHILE '(' comma_expression ')' ';'       %prec THEN
     1203                { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ) ) ); }
     1204        | DO statement WHILE '(' comma_expression ')' ELSE statement // CFA
     1205                { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    12041206        | FOR '(' ')' statement                                                         // CFA => for ( ;; )
    12051207                { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }
    1206         ;
    1207 
    1208 loop_default_opt:
    1209         // empty
    1210                 { $$ = nullptr; }
    1211         | DEFAULT statement ELSE
     1208        | FOR '(' for_control_expression_list ')' statement     %prec THEN
     1209                { $$ = new StatementNode( build_for( $3, maybe_build_compound( $5 ) ) ); }
     1210        | FOR '(' for_control_expression_list ')' statement ELSE statement // CFA
    12121211                { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; }
    1213                 // { $$ = $2; }
    12141212        ;
    12151213
Note: See TracChangeset for help on using the changeset viewer.