Changeset 6611177
- Timestamp:
- Apr 11, 2023, 12:48:03 PM (8 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 5541a44e
- Parents:
- 9921573
- Location:
- src/Parser
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r9921573 r6611177 1003 1003 } 1004 1004 1005 void buildList( constDeclarationNode * firstNode,1005 void buildList( DeclarationNode * firstNode, 1006 1006 std::vector<ast::ptr<ast::Decl>> & outputList ) { 1007 1007 SemanticErrorException errors; … … 1136 1136 1137 1137 // currently only builds assertions, function parameters, and return values 1138 void buildList( constDeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList ) {1138 void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList ) { 1139 1139 SemanticErrorException errors; 1140 1140 std::back_insert_iterator<std::vector<ast::ptr<ast::DeclWithType>>> out( outputList ); -
src/Parser/DeclarationNode.h
r9921573 r6611177 180 180 template<typename AstType, typename NodeType, 181 181 template<typename, typename...> class Container, typename... Args> 182 void buildList( constNodeType * firstNode,182 void buildList( NodeType * firstNode, 183 183 Container<ast::ptr<AstType>, Args...> & output ) { 184 184 SemanticErrorException errors; 185 185 std::back_insert_iterator<Container<ast::ptr<AstType>, Args...>> out( output ); 186 constNodeType * cur = firstNode;186 NodeType * cur = firstNode; 187 187 188 188 while ( cur ) { … … 197 197 errors.append( e ); 198 198 } // try 199 constParseNode * temp = cur->get_next();199 ParseNode * temp = cur->get_next(); 200 200 // Should not return nullptr, then it is non-homogeneous: 201 cur = dynamic_cast< constNodeType *>( temp );201 cur = dynamic_cast<NodeType *>( temp ); 202 202 if ( !cur && temp ) { 203 203 SemanticError( temp->location, "internal error, non-homogeneous nodes founds in buildList processing." ); … … 209 209 } 210 210 211 void buildList( constDeclarationNode * firstNode, std::vector<ast::ptr<ast::Decl>> & outputList );212 void buildList( constDeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList );211 void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::Decl>> & outputList ); 212 void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::DeclWithType>> & outputList ); 213 213 void buildTypeList( const DeclarationNode * firstNode, std::vector<ast::ptr<ast::Type>> & outputList ); 214 214 215 215 template<typename AstType, typename NodeType, 216 216 template<typename, typename...> class Container, typename... Args> 217 void buildMoveList( constNodeType * firstNode,218 Container<ast::ptr<AstType>, Args...> & output ) {219 buildList<AstType, NodeType, Container, Args...>( firstNode, output );220 delete firstNode;217 void buildMoveList( NodeType * firstNode, 218 Container<ast::ptr<AstType>, Args...> & output ) { 219 buildList<AstType, NodeType, Container, Args...>( firstNode, output ); 220 delete firstNode; 221 221 } -
src/Parser/ExpressionNode.cc
r9921573 r6611177 702 702 } // build_binary_val 703 703 704 ast::Expr * build_binary_ptr( const CodeLocation & location,705 OperKinds op,706 ExpressionNode * expr_node1,707 ExpressionNode * expr_node2 ) {708 return build_binary_val( location, op, expr_node1, expr_node2 );709 } // build_binary_ptr710 711 704 ast::Expr * build_cond( const CodeLocation & location, 712 705 ExpressionNode * expr_node1, -
src/Parser/ExpressionNode.h
r9921573 r6611177 41 41 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); } 42 42 43 ast::Expr * build() const{44 ast::Expr * node = const_cast<ExpressionNode *>(this)->expr.release();43 ast::Expr * build() { 44 ast::Expr * node = expr.release(); 45 45 node->set_extension( this->get_extension() ); 46 46 node->location = this->location; … … 53 53 bool extension = false; 54 54 }; // ExpressionNode 55 56 /*57 // Must harmonize with OperName.58 enum class OperKinds {59 // diadic60 SizeOf, AlignOf, OffsetOf, Plus, Minus, Exp, Mul, Div, Mod, Or, And,61 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,62 Assign, AtAssn, ExpAssn, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,63 Index, Range,64 // monadic65 UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost,66 Ctor, Dtor,67 }; // OperKinds68 69 enum class EnumHiding { Visible, Hide };70 71 struct LabelNode {72 std::vector<ast::Label> labels;73 };74 */75 55 76 56 // These 4 routines modify the string: … … 99 79 ast::Expr * build_unary_val( const CodeLocation &, OperKinds op, ExpressionNode * expr_node ); 100 80 ast::Expr * build_binary_val( const CodeLocation &, OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ); 101 ast::Expr * build_binary_ptr( const CodeLocation &, OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 );102 81 ast::Expr * build_cond( const CodeLocation &, ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ); 103 82 ast::Expr * build_tuple( const CodeLocation &, ExpressionNode * expr_node = nullptr ); -
src/Parser/StatementNode.cc
r9921573 r6611177 11 11 // Created On : Sat May 16 14:59:41 2015 12 12 // Last Modified By : Andrew Beach 13 // Last Modified On : Tue Apr 4 11:40:00 202314 // Update Count : 42 713 // Last Modified On : Tue Apr 11 10:16:00 2023 14 // Update Count : 428 15 15 // 16 16 … … 32 32 33 33 using namespace std; 34 35 // Some helpers for cases that really want a single node but check for lists. 36 static const ast::Stmt * buildMoveSingle( StatementNode * node ) { 37 std::vector<ast::ptr<ast::Stmt>> list; 38 buildMoveList( node, list ); 39 assertf( list.size() == 1, "CFA Internal Error: Extra/Missing Nodes" ); 40 return list.front().release(); 41 } 42 43 static const ast::Stmt * buildMoveOptional( StatementNode * node ) { 44 std::vector<ast::ptr<ast::Stmt>> list; 45 buildMoveList( node, list ); 46 assertf( list.size() <= 1, "CFA Internal Error: Extra Nodes" ); 47 return list.empty() ? nullptr : list.front().release(); 48 } 34 49 35 50 StatementNode::StatementNode( DeclarationNode * decl ) { … … 69 84 } 70 85 71 StatementNode * StatementNode::append_last_case( StatementNode * stmt ) {72 StatementNode * prev = this;86 ClauseNode * ClauseNode::append_last_case( StatementNode * stmt ) { 87 ClauseNode * prev = this; 73 88 // find end of list and maintain previous pointer 74 for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) { 75 StatementNode * node = strict_dynamic_cast< StatementNode * >(curr); 76 assert( nullptr == node->stmt.get() ); 89 for ( ClauseNode * curr = prev; curr != nullptr; curr = (ClauseNode *)curr->get_next() ) { 90 ClauseNode * node = strict_dynamic_cast< ClauseNode * >(curr); 77 91 assert( dynamic_cast<ast::CaseClause *>( node->clause.get() ) ); 78 92 prev = curr; 79 93 } // for 94 ClauseNode * node = dynamic_cast< ClauseNode * >(prev); 80 95 // convert from StatementNode list to Statement list 81 StatementNode * node = dynamic_cast< StatementNode * >(prev);82 96 std::vector<ast::ptr<ast::Stmt>> stmts; 83 97 buildMoveList( stmt, stmts ); … … 89 103 stmts.clear(); 90 104 return this; 91 } // StatementNode::append_last_case105 } // ClauseNode::append_last_case 92 106 93 107 ast::Stmt * build_expr( CodeLocation const & location, ExpressionNode * ctl ) { … … 113 127 for ( ast::ptr<ast::Stmt> & stmt : inits ) { 114 128 // build the && of all of the declared variables compared against 0 115 //auto declStmt = strict_dynamic_cast<ast::DeclStmt *>( stmt );116 129 auto declStmt = stmt.strict_as<ast::DeclStmt>(); 117 //ast::DeclWithType * dwt = strict_dynamic_cast<ast::DeclWithType *>( declStmt->decl );118 130 auto dwt = declStmt->decl.strict_as<ast::DeclWithType>(); 119 131 ast::Expr * nze = notZeroExpr( new ast::VariableExpr( dwt->location, dwt ) ); … … 136 148 ast::Stmt const * astelse = nullptr; 137 149 if ( else_ ) { 138 std::vector<ast::ptr<ast::Stmt>> aststmt; 139 buildMoveList( else_, aststmt ); 140 assert( aststmt.size() == 1 ); 141 astelse = aststmt.front().release(); 150 astelse = buildMoveSingle( else_ ); 142 151 } // if 143 152 … … 147 156 } // build_if 148 157 149 // Temporary work around. Split StmtClause off from StatementNode. 150 template<typename clause_t> 151 static void buildMoveClauseList( StatementNode * firstNode, 152 std::vector<ast::ptr<clause_t>> & output ) { 153 SemanticErrorException errors; 154 std::back_insert_iterator<std::vector<ast::ptr<clause_t>>> 155 out( output ); 156 StatementNode * cur = firstNode; 157 158 while ( cur ) { 159 try { 160 auto clause = cur->clause.release(); 161 if ( auto result = dynamic_cast<clause_t *>( clause ) ) { 162 *out++ = result; 163 } else { 164 assertf(false, __PRETTY_FUNCTION__ ); 165 SemanticError( cur->location, "type specifier declaration in forall clause is currently unimplemented." ); 166 } // if 167 } catch( SemanticErrorException & e ) { 168 errors.append( e ); 169 } // try 170 ParseNode * temp = cur->get_next(); 171 // Should not return nullptr, then it is non-homogeneous: 172 cur = dynamic_cast<StatementNode *>( temp ); 173 if ( !cur && temp ) { 174 SemanticError( temp->location, "internal error, non-homogeneous nodes founds in buildList processing." ); 175 } // if 176 } // while 177 if ( ! errors.isEmpty() ) { 178 throw errors; 179 } // if 180 // Usually in the wrapper. 181 delete firstNode; 182 } 183 184 ast::Stmt * build_switch( const CodeLocation & location, bool isSwitch, ExpressionNode * ctl, StatementNode * stmt ) { 158 ast::Stmt * build_switch( const CodeLocation & location, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt ) { 185 159 std::vector<ast::ptr<ast::CaseClause>> aststmt; 186 buildMove ClauseList( stmt, aststmt );160 buildMoveList( stmt, aststmt ); 187 161 // If it is not a switch it is a choose statement. 188 162 if ( ! isSwitch ) { … … 206 180 } // build_switch 207 181 208 ast::CaseClause * build_case( ExpressionNode * ctl ) {182 ast::CaseClause * build_case( const CodeLocation & location, ExpressionNode * ctl ) { 209 183 // stmt starts empty and then added to 210 184 auto expr = maybeMoveBuild( ctl ); 211 return new ast::CaseClause( expr->location, expr, {} );185 return new ast::CaseClause( location, expr, {} ); 212 186 } // build_case 213 187 … … 221 195 ast::Expr * astcond = build_if_control( ctl, astinit ); // ctl deleted, cond/init set 222 196 223 std::vector<ast::ptr<ast::Stmt>> aststmt; // loop body, compound created if empty224 buildMoveList( stmt, aststmt );225 assert( aststmt.size() == 1 );226 227 std::vector<ast::ptr<ast::Stmt>> astelse; // else clause, maybe empty228 buildMoveList( else_, astelse );229 assert( astelse.size() <= 1 );230 231 197 return new ast::WhileDoStmt( location, 232 198 astcond, 233 aststmt.front(),234 astelse.empty() ? nullptr : astelse.front().release(),199 buildMoveSingle( stmt ), 200 buildMoveOptional( else_ ), 235 201 std::move( astinit ), 236 202 ast::While … … 239 205 240 206 ast::Stmt * build_do_while( const CodeLocation & location, ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ ) { 241 std::vector<ast::ptr<ast::Stmt>> aststmt; // loop body, compound created if empty242 buildMoveList( stmt, aststmt );243 assert( aststmt.size() == 1 ); // compound created if empty244 245 std::vector<ast::ptr<ast::Stmt>> astelse; // else clause, maybe empty246 buildMoveList( else_, astelse );247 assert( astelse.size() <= 1 );248 249 207 // do-while cannot have declarations in the contitional, so init is always empty 250 208 return new ast::WhileDoStmt( location, 251 209 notZeroExpr( maybeMoveBuild( ctl ) ), 252 aststmt.front(),253 astelse.empty() ? nullptr : astelse.front().release(),210 buildMoveSingle( stmt ), 211 buildMoveOptional( else_ ), 254 212 {}, 255 213 ast::DoWhile … … 267 225 astincr = maybeMoveBuild( forctl->change ); 268 226 delete forctl; 269 270 std::vector<ast::ptr<ast::Stmt>> aststmt; // loop body, compound created if empty271 buildMoveList( stmt, aststmt );272 assert( aststmt.size() == 1 );273 274 std::vector<ast::ptr<ast::Stmt>> astelse; // else clause, maybe empty275 buildMoveList( else_, astelse );276 assert( astelse.size() <= 1 );277 227 278 228 return new ast::ForStmt( location, … … 280 230 astcond, 281 231 astincr, 282 aststmt.front(),283 astelse.empty() ? nullptr : astelse.front().release()232 buildMoveSingle( stmt ), 233 buildMoveOptional( else_ ) 284 234 ); 285 235 } // build_for … … 342 292 } // build_resume_at 343 293 344 ast::Stmt * build_try( const CodeLocation & location, StatementNode * try_, StatementNode * catch_, StatementNode * finally_ ) {294 ast::Stmt * build_try( const CodeLocation & location, StatementNode * try_, ClauseNode * catch_, ClauseNode * finally_ ) { 345 295 std::vector<ast::ptr<ast::CatchClause>> aststmt; 346 buildMove ClauseList( catch_, aststmt );296 buildMoveList( catch_, aststmt ); 347 297 ast::CompoundStmt * tryBlock = strict_dynamic_cast<ast::CompoundStmt *>( maybeMoveBuild( try_ ) ); 348 298 ast::FinallyClause * finallyBlock = nullptr; … … 358 308 359 309 ast::CatchClause * build_catch( const CodeLocation & location, ast::ExceptionKind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ) { 360 std::vector<ast::ptr<ast::Stmt>> aststmt;361 buildMoveList( body, aststmt );362 assert( aststmt.size() == 1 );363 310 return new ast::CatchClause( location, 364 311 kind, 365 312 maybeMoveBuild( decl ), 366 313 maybeMoveBuild( cond ), 367 aststmt.front().release()314 buildMoveSingle( body ) 368 315 ); 369 316 } // build_catch 370 317 371 318 ast::FinallyClause * build_finally( const CodeLocation & location, StatementNode * stmt ) { 372 std::vector<ast::ptr<ast::Stmt>> aststmt;373 buildMoveList( stmt, aststmt );374 assert( aststmt.size() == 1 );375 319 return new ast::FinallyClause( location, 376 aststmt.front().strict_as<ast::CompoundStmt>() 320 strict_dynamic_cast<const ast::CompoundStmt *>( 321 buildMoveSingle( stmt ) 322 ) 377 323 ); 378 324 } // build_finally 379 325 380 326 ast::SuspendStmt * build_suspend( const CodeLocation & location, StatementNode * then, ast::SuspendStmt::Kind kind ) { 381 std::vector<ast::ptr<ast::Stmt>> stmts; 382 buildMoveList( then, stmts ); 383 ast::CompoundStmt const * then2 = nullptr; 384 if(!stmts.empty()) { 385 assert( stmts.size() == 1 ); 386 then2 = stmts.front().strict_as<ast::CompoundStmt>(); 387 } 388 return new ast::SuspendStmt( location, then2, kind ); 327 return new ast::SuspendStmt( location, 328 strict_dynamic_cast<const ast::CompoundStmt *, nullptr>( 329 buildMoveOptional( then ) 330 ), 331 kind 332 ); 389 333 } // build_suspend 390 334 -
src/Parser/StatementNode.h
r9921573 r6611177 10 10 // Created On : Wed Apr 5 11:42:00 2023 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Apr 5 11:57:00 202313 // Update Count : 012 // Last Modified On : Tue Apr 11 9:43:00 2023 13 // Update Count : 1 14 14 // 15 15 … … 19 19 20 20 struct StatementNode final : public ParseNode { 21 StatementNode() : 22 stmt( nullptr ), clause( nullptr ) {} 23 StatementNode( ast::Stmt * stmt ) : 24 stmt( stmt ), clause( nullptr ) {} 25 StatementNode( ast::StmtClause * clause ) : 26 stmt( nullptr ), clause( clause ) {} 21 StatementNode() : stmt( nullptr ) {} 22 StatementNode( ast::Stmt * stmt ) : stmt( stmt ) {} 27 23 StatementNode( DeclarationNode * decl ); 28 24 virtual ~StatementNode() {} 29 25 30 26 virtual StatementNode * clone() const final { assert( false ); return nullptr; } 31 ast::Stmt * build() const { return const_cast<StatementNode *>(this)->stmt.release(); }27 ast::Stmt * build() { return stmt.release(); } 32 28 33 29 StatementNode * add_label( 34 30 const CodeLocation & location, 35 31 const std::string * name, 36 DeclarationNode * attr = nullptr );/* { 37 stmt->labels.emplace_back( location, 38 *name, 39 attr ? std::move( attr->attributes ) 40 : std::vector<ast::ptr<ast::Attribute>>{} ); 41 delete attr; 42 delete name; 43 return this; 44 }*/ 45 46 virtual StatementNode * append_last_case( StatementNode * ); 32 DeclarationNode * attr = nullptr ); 47 33 48 34 virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override { … … 51 37 52 38 std::unique_ptr<ast::Stmt> stmt; 39 }; // StatementNode 40 41 struct ClauseNode final : public ParseNode { 42 ClauseNode( ast::StmtClause * clause ) : clause( clause ) {} 43 virtual ~ClauseNode() {} 44 45 ClauseNode * set_last( ParseNode * newlast ) { 46 ParseNode::set_last( newlast ); 47 return this; 48 } 49 50 virtual ClauseNode * clone() const final { assert( false ); return nullptr; } 51 ast::StmtClause * build() { return clause.release(); } 52 53 virtual ClauseNode * append_last_case( StatementNode * ); 54 53 55 std::unique_ptr<ast::StmtClause> clause; 54 }; // StatementNode56 }; 55 57 56 58 ast::Stmt * build_expr( CodeLocation const &, ExpressionNode * ctl ); … … 74 76 75 77 ast::Stmt * build_if( const CodeLocation &, CondCtl * ctl, StatementNode * then, StatementNode * else_ ); 76 ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctl, StatementNode * stmt );77 ast::CaseClause * build_case( ExpressionNode * ctl );78 ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt ); 79 ast::CaseClause * build_case( const CodeLocation &, ExpressionNode * ctl ); 78 80 ast::CaseClause * build_default( const CodeLocation & ); 79 81 ast::Stmt * build_while( const CodeLocation &, CondCtl * ctl, StatementNode * stmt, StatementNode * else_ = nullptr ); … … 87 89 ast::Stmt * build_resume( const CodeLocation &, ExpressionNode * ctl ); 88 90 ast::Stmt * build_resume_at( ExpressionNode * ctl , ExpressionNode * target ); 89 ast::Stmt * build_try( const CodeLocation &, StatementNode * try_, StatementNode * catch_, StatementNode * finally_ );91 ast::Stmt * build_try( const CodeLocation &, StatementNode * try_, ClauseNode * catch_, ClauseNode * finally_ ); 90 92 ast::CatchClause * build_catch( const CodeLocation &, ast::ExceptionKind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body ); 91 93 ast::FinallyClause * build_finally( const CodeLocation &, StatementNode * stmt ); -
src/Parser/parser.yy
r9921573 r6611177 306 306 ast::TypeDecl::Kind tclass; 307 307 StatementNode * sn; 308 ClauseNode * clause; 308 309 ast::WaitForStmt * wfs; 309 310 ast::Expr * constant; … … 416 417 %type<sn> statement_decl statement_decl_list statement_list_nodecl 417 418 %type<sn> selection_statement if_statement 418 %type< sn> switch_clause_list_opt switch_clause_list419 %type<clause> switch_clause_list_opt switch_clause_list 419 420 %type<en> case_value 420 %type< sn> case_clausecase_value_list case_label case_label_list421 %type<clause> case_clause case_value_list case_label case_label_list 421 422 %type<sn> iteration_statement jump_statement 422 423 %type<sn> expression_statement asm_statement 423 424 %type<sn> with_statement 424 425 %type<en> with_clause_opt 425 %type<sn> exception_statement handler_clause finally_clause 426 %type<sn> exception_statement 427 %type<clause> handler_clause finally_clause 426 428 %type<catch_kind> handler_key 427 429 %type<sn> mutex_statement … … 1261 1263 1262 1264 case_value_list: // CFA 1263 case_value { $$ = new StatementNode( build_case($1 ) ); }1265 case_value { $$ = new ClauseNode( build_case( yylloc, $1 ) ); } 1264 1266 // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5" 1265 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 )) ) ); }1267 | case_value_list ',' case_value { $$ = $1->set_last( new ClauseNode( build_case( yylloc, $3 ) ) ); } 1266 1268 ; 1267 1269 … … 1272 1274 | CASE case_value_list error // syntax error 1273 1275 { SemanticError( yylloc, "Missing colon after case list." ); $$ = nullptr; } 1274 | DEFAULT ':' { $$ = new StatementNode( build_default( yylloc ) ); }1276 | DEFAULT ':' { $$ = new ClauseNode( build_default( yylloc ) ); } 1275 1277 // A semantic check is required to ensure only one default clause per switch/choose statement. 1276 1278 | DEFAULT error // syntax error … … 1280 1282 case_label_list: // CFA 1281 1283 case_label 1282 | case_label_list case_label { $$ = (StatementNode *)( $1->set_last( $2 )); }1284 | case_label_list case_label { $$ = $1->set_last( $2 ); } 1283 1285 ; 1284 1286 … … 1297 1299 { $$ = $1->append_last_case( new StatementNode( build_compound( yylloc, $2 ) ) ); } 1298 1300 | switch_clause_list case_label_list statement_list_nodecl 1299 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 )) ) ) ); }1301 { $$ = $1->set_last( $2->append_last_case( new StatementNode( build_compound( yylloc, $3 ) ) ) ); } 1300 1302 ; 1301 1303 … … 1731 1733 handler_clause: 1732 1734 handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement 1733 { $$ = new StatementNode( build_catch( yylloc, $1, $4, $6, $8 ) ); }1735 { $$ = new ClauseNode( build_catch( yylloc, $1, $4, $6, $8 ) ); } 1734 1736 | handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement 1735 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); }1737 { $$ = $1->set_last( new ClauseNode( build_catch( yylloc, $2, $5, $7, $9 ) ) ); } 1736 1738 ; 1737 1739 … … 1750 1752 1751 1753 finally_clause: 1752 FINALLY compound_statement { $$ = new StatementNode( build_finally( yylloc, $2 ) ); }1754 FINALLY compound_statement { $$ = new ClauseNode( build_finally( yylloc, $2 ) ); } 1753 1755 ; 1754 1756 -
src/Parser/parserutility.h
r9921573 r6611177 24 24 25 25 template< typename T > 26 static inline auto maybeBuild( const T *orig ) -> decltype(orig->build()) {26 static inline auto maybeBuild( T * orig ) -> decltype(orig->build()) { 27 27 return (orig) ? orig->build() : nullptr; 28 28 } 29 29 30 30 template< typename T > 31 static inline auto maybeMoveBuild( const T *orig ) -> decltype(orig->build()) {31 static inline auto maybeMoveBuild( T * orig ) -> decltype(orig->build()) { 32 32 auto ret = maybeBuild<T>(orig); 33 33 delete orig;
Note: See TracChangeset
for help on using the changeset viewer.