Changeset 135b431 for src/Parser
- Timestamp:
- Aug 25, 2017, 11:09:02 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:
- 6b224a52
- Parents:
- 3eab0ef6
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
r3eab0ef6 r135b431 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
r3eab0ef6 r135b431 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
r3eab0ef6 r135b431 97 97 DeclarationNode::TypeClass tclass; 98 98 StatementNode * sn; 99 WaitForStmt * wfs; 99 100 ConstantExpr * constant; 100 101 IfCtl * ifctl; … … 187 188 %type<flag> asm_volatile_opt 188 189 %type<en> handler_predicate_opt 190 %type<en> when_clause_opt timeout 189 191 190 192 // statements … … 192 194 %type<sn> iteration_statement jump_statement 193 195 %type<sn> with_statement exception_statement asm_statement 194 %type<sn> w hen_clause_opt waitfor_statement waitfor_clause waitfor timeout196 %type<sn> waitfor_statement 195 197 %type<sn> fall_through_opt fall_through 196 198 %type<sn> statement statement_list … … 202 204 %type<sn> handler_clause finally_clause 203 205 %type<catch_kind> handler_key 206 %type<wfs> waitfor_clause 207 %type<en> waitfor 204 208 205 209 // declarations … … 979 983 when_clause_opt: 980 984 // empty 981 { $$ = nullptr; } // FIX ME985 { $$ = nullptr; } 982 986 | WHEN '(' comma_expression ')' 983 { $$ = nullptr; } // FIX ME987 { $$ = $3; } 984 988 ; 985 989 986 990 waitfor: 987 991 WAITFOR '(' identifier ')' 988 { $$ = nullptr; } // FIX ME 992 { 993 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 994 delete $3; 995 } 989 996 | WAITFOR '(' identifier ',' argument_expression_list ')' 990 { $$ = nullptr; } // FIX ME 997 { 998 $$ = new ExpressionNode( new NameExpr( *$3 ) ); 999 $$->set_last( $5 ); 1000 delete $3; 1001 } 991 1002 ; 992 1003 993 1004 timeout: 994 1005 TIMEOUT '(' comma_expression ')' 995 { $$ = nullptr; } // FIX ME1006 { $$ = $3; } 996 1007 ; 997 1008 998 1009 waitfor_clause: 999 1010 when_clause_opt waitfor statement %prec THEN 1000 { $$ = nullptr; } // FIX ME1011 { $$ = build_waitfor( $2, $3, $1 ); } 1001 1012 | when_clause_opt waitfor statement WOR waitfor_clause 1002 { $$ = nullptr; } // FIX ME1013 { $$ = build_waitfor( $2, $3, $1, $5 ); } 1003 1014 | when_clause_opt timeout statement %prec THEN 1004 { $$ = nullptr; } // FIX ME1015 { $$ = build_waitfor_timeout( $2, $3, $1 ); } 1005 1016 | when_clause_opt ELSE statement 1006 { $$ = nullptr; } // FIX ME1017 { $$ = build_waitfor_timeout( nullptr, $3, $1 ); } 1007 1018 | when_clause_opt timeout statement WOR when_clause_opt ELSE statement 1008 { $$ = nullptr; } // FIX ME1019 { $$ = build_waitfor_timeout( $2, $3, $1, $7, $5 ); } 1009 1020 ; 1010 1021 1011 1022 waitfor_statement: 1012 1023 when_clause_opt waitfor statement %prec THEN 1013 { $$ = n ullptr; } // FIX ME1024 { $$ = new StatementNode( build_waitfor( $2, $3, $1 ) ); } 1014 1025 | when_clause_opt waitfor statement WOR waitfor_clause 1015 { $$ = n ullptr; } // FIX ME1026 { $$ = new StatementNode( build_waitfor( $2, $3, $1, $5 ) ); } 1016 1027 ; 1017 1028
Note:
See TracChangeset
for help on using the changeset viewer.