Changeset 473d1da0
- Timestamp:
- Jan 31, 2022, 6:59:08 PM (23 months ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 0fba0d4
- Parents:
- c9c1c1c
- git-author:
- Peter A. Buhr <pabuhr@…> (01/31/22 18:57:10)
- git-committer:
- Peter A. Buhr <pabuhr@…> (01/31/22 18:59:08)
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
rc9c1c1c r473d1da0 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 17:28:53 202113 // Update Count : 90 012 // Last Modified On : Sat Jan 29 09:45:56 2022 13 // Update Count : 901 14 14 // 15 15 … … 390 390 Statement * build_expr( ExpressionNode * ctl ); 391 391 392 struct IfCtrl {393 IfCtrl( DeclarationNode * decl, ExpressionNode * condition ) :392 struct CondCtl { 393 CondCtl( DeclarationNode * decl, ExpressionNode * condition ) : 394 394 init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {} 395 395 … … 409 409 }; 410 410 411 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init );412 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt );411 Expression * build_if_control( CondCtl * ctl, std::list< Statement * > & init ); 412 Statement * build_if( CondCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ); 413 413 Statement * build_switch( bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ); 414 414 Statement * build_case( ExpressionNode * ctl ); 415 415 Statement * build_default(); 416 Statement * build_while( IfCtrl * ctl, StatementNode * stmt );416 Statement * build_while( CondCtl * ctl, StatementNode * stmt ); 417 417 Statement * build_do_while( ExpressionNode * ctl, StatementNode * stmt ); 418 418 Statement * build_for( ForCtrl * forctl, StatementNode * stmt ); -
src/Parser/StatementNode.cc
rc9c1c1c r473d1da0 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Oct 24 04:20:55 202013 // Update Count : 38 312 // Last Modified On : Sat Jan 29 09:45:51 2022 13 // Update Count : 384 14 14 // 15 15 … … 78 78 } // build_expr 79 79 80 Expression * build_if_control( IfCtrl * ctl, std::list< Statement * > & init ) {80 Expression * build_if_control( CondCtl * ctl, std::list< Statement * > & init ) { 81 81 if ( ctl->init != 0 ) { 82 82 buildMoveList( ctl->init, init ); … … 100 100 } // build_if_control 101 101 102 Statement * build_if( IfCtrl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) {102 Statement * build_if( CondCtl * ctl, StatementNode * then_stmt, StatementNode * else_stmt ) { 103 103 Statement * thenb, * elseb = nullptr; 104 104 std::list< Statement * > branches; … … 145 145 } // build_default 146 146 147 Statement * build_while( IfCtrl * ctl, StatementNode * stmt ) {147 Statement * build_while( CondCtl * ctl, StatementNode * stmt ) { 148 148 std::list< Statement * > branches; 149 149 buildMoveList< Statement, StatementNode >( stmt, branches ); -
src/Parser/parser.yy
rc9c1c1c r473d1da0 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Oct 15 09:20:17 202113 // Update Count : 516 312 // Last Modified On : Sun Jan 30 09:41:13 2022 13 // Update Count : 5165 14 14 // 15 15 … … 238 238 WaitForStmt * wfs; 239 239 Expression * constant; 240 IfCtrl * ifctl;240 CondCtl * ifctl; 241 241 ForCtrl * fctl; 242 242 enum OperKinds compop; … … 327 327 %type<en> comma_expression comma_expression_opt 328 328 %type<en> argument_expression_list_opt argument_expression_list argument_expression default_initializer_opt 329 %type<ifctl> if_control_expression329 %type<ifctl> conditional_declaration 330 330 %type<fctl> for_control_expression for_control_expression_list 331 331 %type<compop> inclexcl … … 1123 1123 1124 1124 if_statement: 1125 IF '(' if_control_expression ')' statement%prec THEN1125 IF '(' conditional_declaration ')' statement %prec THEN 1126 1126 // explicitly deal with the shift/reduce conflict on if/else 1127 1127 { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), nullptr ) ); } 1128 | IF '(' if_control_expression ')' statement ELSE statement1128 | IF '(' conditional_declaration ')' statement ELSE statement 1129 1129 { $$ = new StatementNode( build_if( $3, maybe_build_compound( $5 ), maybe_build_compound( $7 ) ) ); } 1130 1130 ; 1131 1131 1132 if_control_expression:1132 conditional_declaration: 1133 1133 comma_expression 1134 { $$ = new IfCtrl( nullptr, $1 ); }1134 { $$ = new CondCtl( nullptr, $1 ); } 1135 1135 | c_declaration // no semi-colon 1136 { $$ = new IfCtrl( $1, nullptr ); }1136 { $$ = new CondCtl( $1, nullptr ); } 1137 1137 | cfa_declaration // no semi-colon 1138 { $$ = new IfCtrl( $1, nullptr ); }1138 { $$ = new CondCtl( $1, nullptr ); } 1139 1139 | declaration comma_expression // semi-colon separated 1140 { $$ = new IfCtrl( $1, $2 ); }1140 { $$ = new CondCtl( $1, $2 ); } 1141 1141 ; 1142 1142 … … 1193 1193 iteration_statement: 1194 1194 WHILE '(' ')' statement // CFA => while ( 1 ) 1195 { $$ = new StatementNode( build_while( new IfCtrl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); }1196 | WHILE '(' if_control_expression ')' statement%prec THEN1195 { $$ = new StatementNode( build_while( new CondCtl( nullptr, new ExpressionNode( build_constantInteger( *new string( "1" ) ) ) ), maybe_build_compound( $4 ) ) ); } 1196 | WHILE '(' conditional_declaration ')' statement %prec THEN 1197 1197 { $$ = new StatementNode( build_while( $3, maybe_build_compound( $5 ) ) ); } 1198 | WHILE '(' if_control_expression ')' statement ELSE statement // CFA1198 | WHILE '(' conditional_declaration ')' statement ELSE statement // CFA 1199 1199 { SemanticError( yylloc, "Loop default block is currently unimplemented." ); $$ = nullptr; } 1200 1200 | DO statement WHILE '(' ')' ';' // CFA => do while( 1 )
Note: See TracChangeset
for help on using the changeset viewer.