Changeset 1cb758f2 for src/Parser
- Timestamp:
- Aug 27, 2017, 11:26:26 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 111a8af8, 26238c1, 7ee1e2f6
- Parents:
- 0c6596f (diff), eca3d10a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r0c6596f r1cb758f2 414 414 Statement * build_compound( StatementNode * first ); 415 415 Statement * build_asmstmt( bool voltile, ConstantExpr * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr ); 416 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when ); 417 WaitForStmt * build_waitfor( ExpressionNode * target, StatementNode * stmt, ExpressionNode * when, WaitForStmt * existing ); 418 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when ); 419 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when ); 416 420 417 421 //############################################################################## -
src/Parser/StatementNode.cc
r0c6596f r1cb758f2 93 93 elseb = branches.front(); 94 94 } // if 95 95 96 96 std::list< Statement * > init; 97 97 if ( ctl->init != 0 ) { … … 207 207 } 208 208 209 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when ) { 210 auto node = new WaitForStmt(); 211 212 WaitForStmt::Target target; 213 target.function = maybeBuild<Expression>( targetExpr ); 214 buildMoveList< Expression >( targetExpr, target.arguments ); 215 delete targetExpr; 216 217 node->clauses.push_back( WaitForStmt::Clause{ 218 target, 219 maybeMoveBuild<Statement >( stmt ), 220 maybeMoveBuild<Expression>( when ) 221 }); 222 223 return node; 224 } 225 226 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) { 227 WaitForStmt::Target target; 228 229 target.function = maybeBuild<Expression>( targetExpr ); 230 buildMoveList< Expression >( targetExpr, target.arguments ); 231 delete targetExpr; 232 233 node->clauses.push_back( WaitForStmt::Clause{ 234 std::move( target ), 235 maybeMoveBuild<Statement >( stmt ), 236 maybeMoveBuild<Expression>( when ) 237 }); 238 239 return node; 240 } 241 242 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when ) { 243 auto node = new WaitForStmt(); 244 245 if( timeout ) { 246 node->timeout.time = maybeMoveBuild<Expression>( timeout ); 247 node->timeout.statement = maybeMoveBuild<Statement >( stmt ); 248 node->timeout.condition = maybeMoveBuild<Expression>( when ); 249 } 250 else { 251 node->orelse.statement = maybeMoveBuild<Statement >( stmt ); 252 node->orelse.condition = maybeMoveBuild<Expression>( when ); 253 } 254 255 return node; 256 } 257 258 WaitForStmt * build_waitfor_timeout( ExpressionNode * timeout, StatementNode * stmt, ExpressionNode * when, StatementNode * else_stmt, ExpressionNode * else_when ) { 259 auto node = new WaitForStmt(); 260 261 node->timeout.time = maybeMoveBuild<Expression>( timeout ); 262 node->timeout.statement = maybeMoveBuild<Statement >( stmt ); 263 node->timeout.condition = maybeMoveBuild<Expression>( when ); 264 265 node->orelse.statement = maybeMoveBuild<Statement >( else_stmt ); 266 node->orelse.condition = maybeMoveBuild<Expression>( else_when ); 267 268 return node; 269 } 270 271 // WaitForStmt::Target build_waitfor( const std::string * name, ExpressionNode * arguments ) { 272 // return WaitForStmt::Clause{ 273 274 // }; 275 // } 276 209 277 Statement *build_compound( StatementNode *first ) { 210 278 CompoundStmt *cs = new CompoundStmt( noLabels ); -
src/Parser/parser.yy
r0c6596f r1cb758f2 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 23 21:08:08201713 // Update Count : 27 0412 // Last Modified On : Sat Aug 26 17:50:19 2017 13 // Update Count : 2712 14 14 // 15 15 … … 97 97 DeclarationNode::TypeClass tclass; 98 98 StatementNode * sn; 99 WaitForStmt * wfs; 99 100 ConstantExpr * constant; 100 101 IfCtl * ifctl; … … 119 120 %token RESTRICT // C99 120 121 %token ATOMIC // C11 121 %token FORALL MUTEX VIRTUAL // CFA122 %token FORALL MUTEX VIRTUAL // CFA 122 123 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 123 124 %token BOOL COMPLEX IMAGINARY // C99 … … 189 190 190 191 // statements 191 %type<sn> labeled_statement compound_statement expression_statement selection_statement 192 %type<sn> iteration_statement jump_statement 193 %type<sn> with_statement exception_statement asm_statement 194 %type<sn> when_clause_opt waitfor_statement waitfor_clause waitfor timeout 195 %type<sn> fall_through_opt fall_through 196 %type<sn> statement statement_list 197 %type<sn> block_item_list block_item 198 %type<sn> with_clause_opt 192 %type<sn> statement labeled_statement compound_statement 193 %type<sn> statement_decl statement_decl_list statement_list_nodecl 194 %type<sn> selection_statement 195 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 199 196 %type<en> case_value 200 197 %type<sn> case_clause case_value_list case_label case_label_list 201 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 202 %type<sn> handler_clause finally_clause 198 %type<sn> fall_through fall_through_opt 199 %type<sn> iteration_statement jump_statement 200 %type<sn> expression_statement asm_statement 201 %type<sn> with_statement with_clause_opt 202 %type<sn> exception_statement handler_clause finally_clause 203 203 %type<catch_kind> handler_key 204 %type<en> when_clause when_clause_opt waitfor timeout 205 %type<sn> waitfor_statement 206 %type<wfs> waitfor_clause 204 207 205 208 // declarations … … 773 776 push push 774 777 local_label_declaration_opt // GCC, local labels 775 block_item_list// C99, intermix declarations and statements778 statement_decl_list // C99, intermix declarations and statements 776 779 pop '}' 777 780 { $$ = new StatementNode( build_compound( $5 ) ); } 778 781 ; 779 782 780 block_item_list:// C99781 block_item782 | block_item_list push block_item783 statement_decl_list: // C99 784 statement_decl 785 | statement_decl_list push statement_decl 783 786 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } } 784 787 ; 785 788 786 block_item:789 statement_decl: 787 790 declaration // CFA, new & old style declarations 788 791 { $$ = new StatementNode( $1 ); } … … 802 805 ; 803 806 804 statement_list :807 statement_list_nodecl: 805 808 statement 806 | statement_list statement809 | statement_list_nodecl statement 807 810 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 808 811 ; … … 814 817 815 818 selection_statement: 816 IF '(' push if_control_expression ')' statement 819 IF '(' push if_control_expression ')' statement %prec THEN 817 820 // explicitly deal with the shift/reduce conflict on if/else 818 821 { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); } … … 889 892 890 893 switch_clause_list: // CFA 891 case_label_list statement_list 894 case_label_list statement_list_nodecl 892 895 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); } 893 | switch_clause_list case_label_list statement_list 896 | switch_clause_list case_label_list statement_list_nodecl 894 897 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 895 898 ; … … 904 907 case_label_list fall_through 905 908 { $$ = $1->append_last_case( $2 ); } 906 | case_label_list statement_list fall_through_opt909 | case_label_list statement_list_nodecl fall_through_opt 907 910 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); } 908 911 | choose_clause_list case_label_list fall_through 909 912 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); } 910 | choose_clause_list case_label_list statement_list fall_through_opt913 | choose_clause_list case_label_list statement_list_nodecl fall_through_opt 911 914 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); } 912 915 ; … … 977 980 ; 978 981 982 when_clause: 983 WHEN '(' comma_expression ')' 984 { $$ = $3; } 985 ; 986 979 987 when_clause_opt: 980 988 // empty 981 { $$ = nullptr; } // FIX ME 982 | WHEN '(' comma_expression ')' 983 { $$ = nullptr; } // FIX ME 989 { $$ = nullptr; } 990 | when_clause 984 991 ; 985 992 986 993 waitfor: 987 994 WAITFOR '(' identifier ')' 988 { $$ = nullptr; } // FIX ME 995 { 996 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 997 delete $3; 998 } 989 999 | WAITFOR '(' identifier ',' argument_expression_list ')' 990 { $$ = nullptr; } // FIX ME 1000 { 1001 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 1002 $$->set_last( $5 ); 1003 delete $3; 1004 } 991 1005 ; 992 1006 993 1007 timeout: 994 1008 TIMEOUT '(' comma_expression ')' 995 { $$ = nullptr; } // FIX ME1009 { $$ = $3; } 996 1010 ; 997 1011 998 1012 waitfor_clause: 999 when_clause_opt waitfor statement 1000 { $$ = nullptr; } // FIX ME1013 when_clause_opt waitfor statement %prec THEN 1014 { $$ = build_waitfor( $2, $3, $1 ); } 1001 1015 | when_clause_opt waitfor statement WOR waitfor_clause 1002 { $$ = nullptr; } // FIX ME1003 | when_clause_opt timeout statement 1004 { $$ = nullptr; } // FIX ME1016 { $$ = build_waitfor( $2, $3, $1, $5 ); } 1017 | when_clause_opt timeout statement %prec THEN 1018 { $$ = build_waitfor_timeout( $2, $3, $1 ); } 1005 1019 | when_clause_opt ELSE statement 1006 { $$ = nullptr; } // FIX ME 1007 | when_clause_opt timeout statement WOR when_clause_opt ELSE statement 1008 { $$ = nullptr; } // FIX ME 1020 { $$ = build_waitfor_timeout( nullptr, $3, $1 ); } 1021 // "else" must be conditional after timeout or timeout is never triggered (i.e., it is meaningless) 1022 | when_clause_opt timeout statement WOR when_clause ELSE statement 1023 { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); } 1009 1024 ; 1010 1025 1011 1026 waitfor_statement: 1012 when_clause_opt waitfor statement 1013 { $$ = n ullptr; } // FIX ME1027 when_clause_opt waitfor statement %prec THEN 1028 { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); } 1014 1029 | when_clause_opt waitfor statement WOR waitfor_clause 1015 { $$ = n ullptr; } // FIX ME1030 { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); } 1016 1031 ; 1017 1032
Note:
See TracChangeset
for help on using the changeset viewer.