Changeset e82aa9df
- Timestamp:
- Aug 15, 2016, 4:13:38 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- b1848a0
- Parents:
- 797347f
- Files:
-
- 3 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r797347f re82aa9df 34 34 # generated by bison and lex from cfa.yy and lex.ll, respectively 35 35 src/Parser/parser.output 36 37 # generated by xfig for user manual 38 doc/user/Cdecl.tex 39 doc/user/pointer1.tex 40 doc/user/pointer2.tex -
src/Parser/DeclarationNode.cc
r797347f re82aa9df 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 13 18:56:58201613 // Update Count : 17 112 // Last Modified On : Mon Aug 15 14:30:25 2016 13 // Update Count : 172 14 14 // 15 15 -
src/Parser/ExpressionNode.cc
r797347f re82aa9df 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 11 20:24:36201613 // Update Count : 4 8712 // Last Modified On : Mon Aug 15 14:30:42 2016 13 // Update Count : 490 14 14 // 15 15 … … 292 292 //############################################################################## 293 293 294 Expression *build_asm ( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) {294 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ) { 295 295 return new AsmExpr( maybeBuild< Expression >( inout ), constraint, maybeBuild<Expression>(operand) ); 296 296 } … … 298 298 //############################################################################## 299 299 300 void LabelNode::print( std::ostream &os, int indent ) const {}301 302 void LabelNode::printOneLine( std::ostream &os, int indent ) const {}300 //void LabelNode::print( std::ostream &os, int indent ) const {} 301 302 //void LabelNode::printOneLine( std::ostream &os, int indent ) const {} 303 303 304 304 //############################################################################## -
src/Parser/ParseNode.cc
r797347f re82aa9df 10 10 // Created On : Sat May 16 13:26:29 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 13 18:55:35201613 // Update Count : 9 812 // Last Modified On : Mon Aug 15 14:49:06 2016 13 // Update Count : 99 14 14 // 15 15 … … 52 52 } 53 53 54 ParseNode &ParseNode::operator,( ParseNode &p ) {55 set_last( &p );56 return *this;57 }58 59 ParseNode *mkList( ParseNode &pn ) {60 // it just relies on `operator,' to take care of the "arguments" and provides a nice interface to an awful-looking61 // address-of, rendering, for example (StatementNode *)(&(*$5 + *$7)) into (StatementNode *)mkList(($5, $7))62 // (although "nice" is probably not the word)63 return &pn;64 }65 66 54 // Local Variables: // 67 55 // tab-width: 4 // -
src/Parser/ParseNode.h
r797347f re82aa9df 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 14 16:29:20201613 // Update Count : 48312 // Last Modified On : Mon Aug 15 14:52:12 2016 13 // Update Count : 512 14 14 // 15 15 … … 64 64 ParseNode *next; 65 65 }; 66 67 ParseNode *mkList( ParseNode & );68 66 69 67 //############################################################################## … … 133 131 }; 134 132 135 //##############################################################################136 137 Expression *build_constantInteger( std::string &str );138 Expression *build_constantFloat( std::string &str );139 Expression *build_constantChar( std::string &str );140 ConstantExpr *build_constantStr( std::string &str );141 142 //##############################################################################143 144 NameExpr *build_varref( const std::string *name, bool labelp = false );145 146 //##############################################################################147 148 Expression *build_typevalue( DeclarationNode *decl );149 150 //##############################################################################151 152 133 enum class OperKinds { 153 134 // diadic … … 160 141 Ctor, Dtor, 161 142 }; 143 144 struct LabelNode { 145 std::list< Label > labels; 146 }; 147 148 Expression *build_constantInteger( std::string &str ); 149 Expression *build_constantFloat( std::string &str ); 150 Expression *build_constantChar( std::string &str ); 151 ConstantExpr *build_constantStr( std::string &str ); 152 153 NameExpr *build_varref( const std::string *name, bool labelp = false ); 154 Expression *build_typevalue( DeclarationNode *decl ); 162 155 163 156 Expression *build_cast( DeclarationNode * decl_node, ExpressionNode *expr_node ); … … 183 176 Expression *build_func( ExpressionNode * function, ExpressionNode * expr_node ); 184 177 Expression *build_range( ExpressionNode * low, ExpressionNode *high ); 185 186 //############################################################################## 187 188 Expression *build_asm( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ); 189 190 //############################################################################## 191 192 class LabelNode : public ExpressionNode { 193 public: 194 virtual Expression *build() const { return NULL; } 195 virtual LabelNode *clone() const { assert( false ); return new LabelNode( *this ); } 196 197 virtual void print( std::ostream &os, int indent = 0) const; 198 virtual void printOneLine( std::ostream &os, int indent = 0) const; 199 200 const std::list< Label > &get_labels() const { return labels; }; 201 void append_label( std::string * label ) { labels.push_back( *label ); delete label; } 202 private: 203 std::list< Label > labels; 204 }; 205 206 //############################################################################## 207 178 Expression *build_asmexpr( ExpressionNode *inout, ConstantExpr *constraint, ExpressionNode *operand ); 208 179 Expression *build_valexpr( StatementNode *s ); 209 210 //##############################################################################211 212 180 Expression *build_compoundLiteral( DeclarationNode *decl_node, InitializerNode *kids ); 213 181 … … 275 243 DeclarationNode *addNewArray( DeclarationNode *array ); 276 244 DeclarationNode *addParamList( DeclarationNode *list ); 277 DeclarationNode *addIdList( DeclarationNode *list ); 245 DeclarationNode *addIdList( DeclarationNode *list ); // old-style functions 278 246 DeclarationNode *addInitializer( InitializerNode *init ); 279 247 … … 328 296 class StatementNode : public ParseNode { 329 297 public: 330 enum Type { Exp, If, Switch, Case, Default, Choose, Fallthru, 331 While, Do, For, 332 Goto, Continue, Break, Return, Throw, 333 Try, Catch, Finally, Asm, 334 Decl 335 }; 336 337 StatementNode(); 298 StatementNode() { stmt = nullptr; } 299 StatementNode( Statement *stmt ) : stmt( stmt ) {} 338 300 StatementNode( DeclarationNode *decl ); 339 ~StatementNode(); 340 341 StatementNode::Type get_type() const { return type; } 342 343 virtual StatementNode *add_label( const std::string * ); 344 virtual std::list<std::string> get_labels() const { return labels; } 345 346 void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; } 347 348 virtual StatementNode *append_last_case( StatementNode * ); 349 350 virtual void print( std::ostream &os, int indent = 0) const {} 351 virtual StatementNode *clone() const; 352 virtual Statement *build() const; 353 public: 354 static const char *StType[]; 355 Type type; 356 std::list<std::string> labels; 357 DeclarationNode *decl; 358 }; // StatementNode 359 360 class StatementNode2 : public StatementNode { 361 public: 362 StatementNode2() { stmt = nullptr; } 363 StatementNode2( Statement *stmt ) : stmt( stmt ) {} 364 StatementNode2( DeclarationNode *decl ); 365 virtual ~StatementNode2() {} 366 367 virtual StatementNode2 *clone() const { assert( false ); return nullptr; } 301 virtual ~StatementNode() {} 302 303 virtual StatementNode *clone() const { assert( false ); return nullptr; } 368 304 virtual Statement *build() const { return stmt; } 369 305 370 virtual StatementNode 2*add_label( const std::string * name ) {306 virtual StatementNode *add_label( const std::string * name ) { 371 307 stmt->get_labels().emplace_back( *name ); 372 308 return this; 373 309 } 374 virtual std::list<std::string> get_labels() const { assert( false ); return StatementNode::get_labels(); }375 310 376 311 virtual StatementNode *append_last_case( StatementNode * ); … … 386 321 struct ForCtl { 387 322 ForCtl( ExpressionNode *expr, ExpressionNode *condition, ExpressionNode *change ) : 388 init( new StatementNode 2( build_expr( expr ) ) ), condition( condition ), change( change ) {}323 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {} 389 324 ForCtl( DeclarationNode *decl, ExpressionNode *condition, ExpressionNode *change ) : 390 init( new StatementNode 2( decl ) ), condition( condition ), change( change ) {}325 init( new StatementNode( decl ) ), condition( condition ), change( change ) {} 391 326 392 327 StatementNode *init; … … 408 343 Statement *build_catch( DeclarationNode *decl, StatementNode *stmt, bool catchAny = false ); 409 344 Statement *build_finally( StatementNode *stmt ); 410 411 //############################################################################## 412 413 class CompoundStmtNode : public StatementNode { 414 public: 415 CompoundStmtNode(); 416 CompoundStmtNode( StatementNode * ); 417 ~CompoundStmtNode(); 418 419 void add_statement( StatementNode * ); 420 421 void print( std::ostream &os, int indent = 0 ) const; 422 virtual Statement *build() const; 423 private: 424 StatementNode *first, *last; 425 }; 426 427 //############################################################################## 428 429 class AsmStmtNode : public StatementNode { 430 public: 431 AsmStmtNode( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 ); 432 ~AsmStmtNode(); 433 434 void print( std::ostream &os, int indent = 0 ) const {} 435 Statement *build() const; 436 private: 437 bool voltile; 438 ConstantExpr *instruction; 439 ExpressionNode *output, *input; 440 ExpressionNode *clobber; 441 std::list< Label > gotolabels; 442 }; 345 Statement *build_compound( StatementNode *first ); 346 Statement *build_asmstmt( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 ); 443 347 444 348 //############################################################################## -
src/Parser/StatementNode.cc
r797347f re82aa9df 10 10 // Created On : Sat May 16 14:59:41 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 14 13:10:54201613 // Update Count : 28812 // Last Modified On : Mon Aug 15 14:40:05 2016 13 // Update Count : 317 14 14 // 15 15 … … 26 26 using namespace std; 27 27 28 const char *StatementNode::StType[] = {29 "Exp", "If", "Switch", "Case", "Default", "Choose", "Fallthru",30 "While", "Do", "For",31 "Goto", "Continue", "Break", "Return", "Throw",32 "Try", "Catch", "Finally", "Asm",33 "Decl"34 };35 28 36 StatementNode::StatementNode() : ParseNode(), labels( 0 ), decl( 0 ) {} 37 38 StatementNode::StatementNode( DeclarationNode *decl ) : type( Decl ), labels( 0 ) { 39 assert( false ); 29 StatementNode::StatementNode( DeclarationNode *decl ) { 40 30 if ( decl ) { 41 if ( DeclarationNode *agg = decl->extractAggregate() ) { 42 this->decl = agg; 43 StatementNode *nextStmt = new StatementNode; 44 nextStmt->type = Decl; 45 nextStmt->decl = decl; 31 DeclarationNode *agg = decl->extractAggregate(); 32 if ( agg ) { 33 StatementNode *nextStmt = new StatementNode( new DeclStmt( noLabels, maybeBuild< Declaration >( decl ) ) ); 46 34 next = nextStmt; 47 35 if ( decl->get_next() ) { 48 next->set_next( new StatementNode( dynamic_cast<DeclarationNode *>( decl->get_next()) ) );36 next->set_next( new StatementNode( dynamic_cast<DeclarationNode *>(decl->get_next()) ) ); 49 37 decl->set_next( 0 ); 50 38 } // if … … 52 40 if ( decl->get_next() ) { 53 41 next = new StatementNode( dynamic_cast<DeclarationNode *>( decl->get_next() ) ); 54 decl->set_next( 0 );55 } // if56 this->decl = decl;57 } // if58 } // if59 }60 61 StatementNode2::StatementNode2( DeclarationNode *decl ) {62 if ( decl ) {63 DeclarationNode *agg = decl->extractAggregate();64 if ( agg ) {65 StatementNode *nextStmt = new StatementNode;66 nextStmt->type = Decl;67 nextStmt->decl = decl;68 next = nextStmt;69 if ( decl->get_next() ) {70 next->set_next( new StatementNode2( dynamic_cast<DeclarationNode *>(decl->get_next()) ) );71 decl->set_next( 0 );72 } // if73 } else {74 if ( decl->get_next() ) {75 next = new StatementNode2( dynamic_cast<DeclarationNode *>( decl->get_next() ) );76 42 decl->set_next( 0 ); 77 43 } // if … … 84 50 } 85 51 86 StatementNode::~StatementNode() {87 delete decl;88 }89 90 StatementNode * StatementNode::clone() const {91 assert( false );92 return 0;93 }94 95 StatementNode *StatementNode::add_label( const std::string *l ) {96 if ( l != 0 ) {97 labels.push_front( *l );98 delete l;99 } // if100 return this;101 }102 103 52 StatementNode *StatementNode::append_last_case( StatementNode *stmt ) { 104 assert( false );105 return this;106 }107 108 StatementNode *StatementNode2::append_last_case( StatementNode *stmt ) {109 53 StatementNode *prev = this; 110 54 // find end of list and maintain previous pointer 111 55 for ( StatementNode * curr = prev; curr != nullptr; curr = (StatementNode *)curr->get_next() ) { 112 StatementNode 2 *node = dynamic_cast<StatementNode2*>(curr);56 StatementNode *node = dynamic_cast<StatementNode *>(curr); 113 57 assert( node ); 114 58 assert( dynamic_cast<CaseStmt *>(node->stmt) ); 115 59 prev = curr; 116 60 } // for 117 // conver from StatementNode list to Statement list118 StatementNode 2 *node = dynamic_cast<StatementNode2*>(prev);61 // convert from StatementNode list to Statement list 62 StatementNode *node = dynamic_cast<StatementNode *>(prev); 119 63 std::list<Statement *> stmts; 120 64 buildList( stmt, stmts ); 121 // splice any new Statements to end of current sStatements65 // splice any new Statements to end of current Statements 122 66 CaseStmt * caseStmt = dynamic_cast<CaseStmt *>(node->stmt); 123 67 caseStmt->get_statements().splice( caseStmt->get_statements().end(), stmts ); 124 68 return this; 125 }126 127 Statement *StatementNode::build() const {128 switch ( type ) {129 case Decl:130 return new DeclStmt( noLabels, maybeBuild< Declaration >( decl ) );131 assert( false );132 case Exp:133 case If:134 case Switch:135 case Case:136 case Default:137 case While:138 case Do:139 case For:140 case Goto:141 case Break:142 case Continue:143 case Return:144 case Throw :145 case Try:146 case Catch:147 case Finally:148 case Asm:149 default:150 assert( false );151 return 0;152 } // switch153 69 } 154 70 … … 261 177 } 262 178 263 264 CompoundStmtNode::CompoundStmtNode() : first( 0 ), last( 0 ) {} 265 266 CompoundStmtNode::CompoundStmtNode( StatementNode *stmt ) : first( stmt ) { 267 if ( first ) { 268 last = ( StatementNode *)( stmt->get_last()); 269 } else { 270 last = 0; 271 } // if 272 } 273 274 CompoundStmtNode::~CompoundStmtNode() { 275 delete first; 276 } 277 278 void CompoundStmtNode::add_statement( StatementNode *stmt ) { 279 if ( stmt != 0 ) { 280 last->set_last( stmt ); 281 last = ( StatementNode *)( stmt->get_next()); 282 } // if 283 } 284 285 void CompoundStmtNode::print( ostream &os, int indent ) const { 286 if ( first ) { 287 first->printList( os, indent+2 ); 288 } // if 289 } 290 291 Statement *CompoundStmtNode::build() const { 292 std::list<Label> labs; 293 const std::list<std::string> &labels = get_labels(); 294 295 if ( ! labels.empty() ) { 296 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 297 copy( labels.begin(), labels.end(), lab_it ); 298 } // if 299 300 CompoundStmt *cs = new CompoundStmt( labs ); 179 Statement *build_compound( StatementNode *first ) { 180 CompoundStmt *cs = new CompoundStmt( noLabels ); 301 181 buildList( first, cs->get_kids() ); 302 182 return cs; 303 183 } 304 184 305 306 AsmStmtNode::AsmStmtNode( bool voltile, ConstantExpr *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) : 307 voltile( voltile ), instruction( instruction ), output( output ), input( input ), clobber( clobber ) { 308 type = Asm; 309 if ( gotolabels ) { 310 this->gotolabels = gotolabels->get_labels(); 311 delete gotolabels; 312 } // if 313 } 314 315 AsmStmtNode::~AsmStmtNode() { 316 delete output; delete input; delete clobber; 317 } 318 319 Statement *AsmStmtNode::build() const { 320 std::list<Label> labs; 321 322 if ( ! get_labels().empty() ) { 323 std::back_insert_iterator< std::list<Label> > lab_it( labs ); 324 copy( get_labels().begin(), get_labels().end(), lab_it ); 325 } // if 326 185 Statement *build_asmstmt( bool voltile, ConstantExpr *instruction, ExpressionNode *output, ExpressionNode *input, ExpressionNode *clobber, LabelNode *gotolabels ) { 327 186 std::list< Expression * > out, in; 328 187 std::list< ConstantExpr * > clob; 188 329 189 buildList( output, out ); 330 190 buildList( input, in ); 331 191 buildList( clobber, clob ); 332 std::list< Label > gotolabs = gotolabels; 333 return new AsmStmt( labs, voltile, instruction, out, in, clob, gotolabs ); 192 return new AsmStmt( noLabels, voltile, instruction, out, in, clob, gotolabels ? gotolabels->labels : noLabels ); 334 193 } 335 336 // Statement *build_asm( bool voltile, ConstantExpr *instruction, ExpressionNode *output = 0, ExpressionNode *input = 0, ExpressionNode *clobber = 0, LabelNode *gotolabels = 0 ) {337 // std::list<Label> labs;338 339 // if ( ! get_labels().empty() ) {340 // std::back_insert_iterator< std::list<Label> > lab_it( labs );341 // copy( get_labels().begin(), get_labels().end(), lab_it );342 // } // if343 344 // std::list< Expression * > out, in;345 // std::list< ConstantExpr * > clob;346 // buildList( output, out );347 // buildList( input, in );348 // buildList( clobber, clob );349 // std::list< Label > gotolabs = gotolabels;350 // return new AsmStmt( labs, voltile, instruction, out, in, clob, gotolabs );351 // }352 194 353 195 // Local Variables: // -
src/Parser/TypeData.h
r797347f re82aa9df 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 20:52:02 201613 // Update Count : 2 012 // Last Modified On : Mon Aug 15 14:28:32 2016 13 // Update Count : 21 14 14 // 15 15 -
src/Parser/parser.cc
r797347f re82aa9df 5638 5638 Token fn; 5639 5639 fn.str = new std::string( "^?{}" ); // location undefined 5640 (yyval.sn) = new StatementNode 2( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( (yyvsp[(2) - (6)].en) )->set_last( (yyvsp[(4) - (6)].en) ) ) ) ) );5640 (yyval.sn) = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( (yyvsp[(2) - (6)].en) )->set_last( (yyvsp[(4) - (6)].en) ) ) ) ) ); 5641 5641 } 5642 5642 break; … … 5655 5655 /* Line 1806 of yacc.c */ 5656 5656 #line 680 "parser.yy" 5657 { (yyval.sn) = new CompoundStmtNode( (StatementNode *)0); }5657 { (yyval.sn) = new StatementNode( build_compound( (StatementNode *)0 ) ); } 5658 5658 break; 5659 5659 … … 5662 5662 /* Line 1806 of yacc.c */ 5663 5663 #line 687 "parser.yy" 5664 { (yyval.sn) = new CompoundStmtNode( (yyvsp[(5) - (7)].sn) ); }5664 { (yyval.sn) = new StatementNode( build_compound( (yyvsp[(5) - (7)].sn) ) ); } 5665 5665 break; 5666 5666 … … 5676 5676 /* Line 1806 of yacc.c */ 5677 5677 #line 698 "parser.yy" 5678 { (yyval.sn) = new StatementNode 2( (yyvsp[(1) - (1)].decl) ); }5678 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5679 5679 break; 5680 5680 … … 5686 5686 for ( DeclarationNode *iter = (yyvsp[(2) - (2)].decl); iter != NULL; iter = (DeclarationNode *)iter->get_next() ) 5687 5687 iter->set_extension( true ); 5688 (yyval.sn) = new StatementNode 2( (yyvsp[(2) - (2)].decl) );5688 (yyval.sn) = new StatementNode( (yyvsp[(2) - (2)].decl) ); 5689 5689 } 5690 5690 break; … … 5694 5694 /* Line 1806 of yacc.c */ 5695 5695 #line 706 "parser.yy" 5696 { (yyval.sn) = new StatementNode 2( (yyvsp[(1) - (1)].decl) ); }5696 { (yyval.sn) = new StatementNode( (yyvsp[(1) - (1)].decl) ); } 5697 5697 break; 5698 5698 … … 5708 5708 /* Line 1806 of yacc.c */ 5709 5709 #line 718 "parser.yy" 5710 { (yyval.sn) = new StatementNode 2( build_expr( (yyvsp[(1) - (2)].en) ) ); }5710 { (yyval.sn) = new StatementNode( build_expr( (yyvsp[(1) - (2)].en) ) ); } 5711 5711 break; 5712 5712 … … 5715 5715 /* Line 1806 of yacc.c */ 5716 5716 #line 724 "parser.yy" 5717 { (yyval.sn) = new StatementNode 2( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); }5717 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn), nullptr ) ); } 5718 5718 break; 5719 5719 … … 5722 5722 /* Line 1806 of yacc.c */ 5723 5723 #line 726 "parser.yy" 5724 { (yyval.sn) = new StatementNode 2( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); }5724 { (yyval.sn) = new StatementNode( build_if( (yyvsp[(3) - (7)].en), (yyvsp[(5) - (7)].sn), (yyvsp[(7) - (7)].sn) ) ); } 5725 5725 break; 5726 5726 … … 5729 5729 /* Line 1806 of yacc.c */ 5730 5730 #line 728 "parser.yy" 5731 { (yyval.sn) = new StatementNode 2( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }5731 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5732 5732 break; 5733 5733 … … 5737 5737 #line 730 "parser.yy" 5738 5738 { 5739 StatementNode *sw = new StatementNode 2( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );5739 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); 5740 5740 // The semantics of the declaration list is changed to include associated initialization, which is performed 5741 5741 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 5743 5743 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 5744 5744 // statement. 5745 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) : sw;5745 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) ) : sw; 5746 5746 } 5747 5747 break; … … 5751 5751 /* Line 1806 of yacc.c */ 5752 5752 #line 740 "parser.yy" 5753 { (yyval.sn) = new StatementNode 2( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }5753 { (yyval.sn) = new StatementNode( build_switch( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5754 5754 break; 5755 5755 … … 5759 5759 #line 742 "parser.yy" 5760 5760 { 5761 StatementNode *sw = new StatementNode 2( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) );5762 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) : sw;5761 StatementNode *sw = new StatementNode( build_switch( (yyvsp[(3) - (9)].en), (yyvsp[(8) - (9)].sn) ) ); 5762 (yyval.sn) = (yyvsp[(7) - (9)].decl) != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( (yyvsp[(7) - (9)].decl) ))->set_last( sw )) ) ) : sw; 5763 5763 } 5764 5764 break; … … 5782 5782 /* Line 1806 of yacc.c */ 5783 5783 #line 759 "parser.yy" 5784 { (yyval.sn) = new StatementNode 2( build_case( (yyvsp[(1) - (1)].en) ) ); }5784 { (yyval.sn) = new StatementNode( build_case( (yyvsp[(1) - (1)].en) ) ); } 5785 5785 break; 5786 5786 … … 5789 5789 /* Line 1806 of yacc.c */ 5790 5790 #line 761 "parser.yy" 5791 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode 2( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); }5791 { (yyval.sn) = (StatementNode *)((yyvsp[(1) - (3)].sn)->set_last( new StatementNode( build_case( (yyvsp[(3) - (3)].en) ) ) ) ); } 5792 5792 break; 5793 5793 … … 5803 5803 /* Line 1806 of yacc.c */ 5804 5804 #line 766 "parser.yy" 5805 { (yyval.sn) = new StatementNode 2( build_default() ); }5805 { (yyval.sn) = new StatementNode( build_default() ); } 5806 5806 break; 5807 5807 … … 5817 5817 /* Line 1806 of yacc.c */ 5818 5818 #line 776 "parser.yy" 5819 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(2) - (2)].sn) ) ); }5819 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5820 5820 break; 5821 5821 … … 5831 5831 /* Line 1806 of yacc.c */ 5832 5832 #line 787 "parser.yy" 5833 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(2) - (2)].sn) ) ); }5833 { (yyval.sn) = (yyvsp[(1) - (2)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(2) - (2)].sn) ) ) ); } 5834 5834 break; 5835 5835 … … 5838 5838 /* Line 1806 of yacc.c */ 5839 5839 #line 789 "parser.yy" 5840 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new CompoundStmtNode( (yyvsp[(3) - (3)].sn) ) ) ) ); }5840 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (3)].sn)->set_last( (yyvsp[(2) - (3)].sn)->append_last_case( new StatementNode( build_compound( (yyvsp[(3) - (3)].sn) ) ) ) ) ); } 5841 5841 break; 5842 5842 … … 5859 5859 /* Line 1806 of yacc.c */ 5860 5860 #line 802 "parser.yy" 5861 { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*(yyvsp[(2) - (3)].sn), *(yyvsp[(3) - (3)].sn) ) ) ) ); }5861 { (yyval.sn) = (yyvsp[(1) - (3)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(2) - (3)].sn)->set_last( (yyvsp[(3) - (3)].sn) ) ) ) ); } 5862 5862 break; 5863 5863 … … 5873 5873 /* Line 1806 of yacc.c */ 5874 5874 #line 806 "parser.yy" 5875 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*(yyvsp[(3) - (4)].sn), *(yyvsp[(4) - (4)].sn) ) ) ) ) ) ); }5875 { (yyval.sn) = (StatementNode *)( (yyvsp[(1) - (4)].sn)->set_last( (yyvsp[(2) - (4)].sn)->append_last_case( new StatementNode( build_compound( (StatementNode *)(yyvsp[(3) - (4)].sn)->set_last( (yyvsp[(4) - (4)].sn) ) ) ) ) ) ); } 5876 5876 break; 5877 5877 … … 5880 5880 /* Line 1806 of yacc.c */ 5881 5881 #line 811 "parser.yy" 5882 { (yyval.sn) = new StatementNode 2( build_branch( "", BranchStmt::Break ) ); }5882 { (yyval.sn) = new StatementNode( build_branch( "", BranchStmt::Break ) ); } 5883 5883 break; 5884 5884 … … 5901 5901 /* Line 1806 of yacc.c */ 5902 5902 #line 824 "parser.yy" 5903 { (yyval.sn) = new StatementNode 2( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); }5903 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(3) - (5)].en), (yyvsp[(5) - (5)].sn) ) ); } 5904 5904 break; 5905 5905 … … 5908 5908 /* Line 1806 of yacc.c */ 5909 5909 #line 826 "parser.yy" 5910 { (yyval.sn) = new StatementNode 2( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn) ) ); }5910 { (yyval.sn) = new StatementNode( build_while( (yyvsp[(5) - (7)].en), (yyvsp[(2) - (7)].sn) ) ); } 5911 5911 break; 5912 5912 … … 5915 5915 /* Line 1806 of yacc.c */ 5916 5916 #line 828 "parser.yy" 5917 { (yyval.sn) = new StatementNode 2( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); }5917 { (yyval.sn) = new StatementNode( build_for( (yyvsp[(4) - (6)].fctl), (yyvsp[(6) - (6)].sn) ) ); } 5918 5918 break; 5919 5919 … … 5936 5936 /* Line 1806 of yacc.c */ 5937 5937 #line 840 "parser.yy" 5938 { (yyval.sn) = new StatementNode 2( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); }5938 { (yyval.sn) = new StatementNode( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Goto ) ); } 5939 5939 break; 5940 5940 … … 5943 5943 /* Line 1806 of yacc.c */ 5944 5944 #line 844 "parser.yy" 5945 { (yyval.sn) = new StatementNode 2( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); }5945 { (yyval.sn) = new StatementNode( build_computedgoto( (yyvsp[(3) - (4)].en) ) ); } 5946 5946 break; 5947 5947 … … 5950 5950 /* Line 1806 of yacc.c */ 5951 5951 #line 847 "parser.yy" 5952 { (yyval.sn) = new StatementNode 2( build_branch( "", BranchStmt::Continue ) ); }5952 { (yyval.sn) = new StatementNode( build_branch( "", BranchStmt::Continue ) ); } 5953 5953 break; 5954 5954 … … 5957 5957 /* Line 1806 of yacc.c */ 5958 5958 #line 851 "parser.yy" 5959 { (yyval.sn) = new StatementNode 2( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); delete (yyvsp[(2) - (3)].tok); }5959 { (yyval.sn) = new StatementNode( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Continue ) ); delete (yyvsp[(2) - (3)].tok); } 5960 5960 break; 5961 5961 … … 5964 5964 /* Line 1806 of yacc.c */ 5965 5965 #line 854 "parser.yy" 5966 { (yyval.sn) = new StatementNode 2( build_branch( "", BranchStmt::Break ) ); }5966 { (yyval.sn) = new StatementNode( build_branch( "", BranchStmt::Break ) ); } 5967 5967 break; 5968 5968 … … 5971 5971 /* Line 1806 of yacc.c */ 5972 5972 #line 858 "parser.yy" 5973 { (yyval.sn) = new StatementNode 2( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); delete (yyvsp[(2) - (3)].tok); }5973 { (yyval.sn) = new StatementNode( build_branch( *(yyvsp[(2) - (3)].tok), BranchStmt::Break ) ); delete (yyvsp[(2) - (3)].tok); } 5974 5974 break; 5975 5975 … … 5978 5978 /* Line 1806 of yacc.c */ 5979 5979 #line 860 "parser.yy" 5980 { (yyval.sn) = new StatementNode 2( build_return( (yyvsp[(2) - (3)].en) ) ); }5980 { (yyval.sn) = new StatementNode( build_return( (yyvsp[(2) - (3)].en) ) ); } 5981 5981 break; 5982 5982 … … 5985 5985 /* Line 1806 of yacc.c */ 5986 5986 #line 862 "parser.yy" 5987 { (yyval.sn) = new StatementNode 2( build_throw( (yyvsp[(2) - (3)].en) ) ); }5987 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 5988 5988 break; 5989 5989 … … 5992 5992 /* Line 1806 of yacc.c */ 5993 5993 #line 864 "parser.yy" 5994 { (yyval.sn) = new StatementNode 2( build_throw( (yyvsp[(2) - (3)].en) ) ); }5994 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (3)].en) ) ); } 5995 5995 break; 5996 5996 … … 5999 5999 /* Line 1806 of yacc.c */ 6000 6000 #line 866 "parser.yy" 6001 { (yyval.sn) = new StatementNode 2( build_throw( (yyvsp[(2) - (5)].en) ) ); }6001 { (yyval.sn) = new StatementNode( build_throw( (yyvsp[(2) - (5)].en) ) ); } 6002 6002 break; 6003 6003 … … 6006 6006 /* Line 1806 of yacc.c */ 6007 6007 #line 871 "parser.yy" 6008 { (yyval.sn) = new StatementNode 2( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); }6008 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), (yyvsp[(3) - (3)].sn), 0 ) ); } 6009 6009 break; 6010 6010 … … 6013 6013 /* Line 1806 of yacc.c */ 6014 6014 #line 873 "parser.yy" 6015 { (yyval.sn) = new StatementNode 2( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); }6015 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (3)].sn), 0, (yyvsp[(3) - (3)].sn) ) ); } 6016 6016 break; 6017 6017 … … 6020 6020 /* Line 1806 of yacc.c */ 6021 6021 #line 875 "parser.yy" 6022 { (yyval.sn) = new StatementNode 2( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); }6022 { (yyval.sn) = new StatementNode( build_try( (yyvsp[(2) - (4)].sn), (yyvsp[(3) - (4)].sn), (yyvsp[(4) - (4)].sn) ) ); } 6023 6023 break; 6024 6024 … … 6027 6027 /* Line 1806 of yacc.c */ 6028 6028 #line 882 "parser.yy" 6029 { (yyval.sn) = new StatementNode 2( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }6029 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 6030 6030 break; 6031 6031 … … 6034 6034 /* Line 1806 of yacc.c */ 6035 6035 #line 884 "parser.yy" 6036 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode 2( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }6036 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 6037 6037 break; 6038 6038 … … 6041 6041 /* Line 1806 of yacc.c */ 6042 6042 #line 886 "parser.yy" 6043 { (yyval.sn) = new StatementNode 2( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); }6043 { (yyval.sn) = new StatementNode( build_catch( 0, (yyvsp[(5) - (5)].sn), true ) ); } 6044 6044 break; 6045 6045 … … 6048 6048 /* Line 1806 of yacc.c */ 6049 6049 #line 888 "parser.yy" 6050 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode 2( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); }6050 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (6)].sn)->set_last( new StatementNode( build_catch( 0, (yyvsp[(6) - (6)].sn), true ) ) ); } 6051 6051 break; 6052 6052 … … 6055 6055 /* Line 1806 of yacc.c */ 6056 6056 #line 893 "parser.yy" 6057 { (yyval.sn) = new StatementNode 2( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }6057 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 6058 6058 break; 6059 6059 … … 6062 6062 /* Line 1806 of yacc.c */ 6063 6063 #line 895 "parser.yy" 6064 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode 2( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }6064 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 6065 6065 break; 6066 6066 … … 6069 6069 /* Line 1806 of yacc.c */ 6070 6070 #line 897 "parser.yy" 6071 { (yyval.sn) = new StatementNode 2( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); }6071 { (yyval.sn) = new StatementNode( build_catch( (yyvsp[(5) - (9)].decl), (yyvsp[(8) - (9)].sn) ) ); } 6072 6072 break; 6073 6073 … … 6076 6076 /* Line 1806 of yacc.c */ 6077 6077 #line 899 "parser.yy" 6078 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode 2( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); }6078 { (yyval.sn) = (StatementNode *)(yyvsp[(1) - (10)].sn)->set_last( new StatementNode( build_catch( (yyvsp[(6) - (10)].decl), (yyvsp[(9) - (10)].sn) ) ) ); } 6079 6079 break; 6080 6080 … … 6084 6084 #line 904 "parser.yy" 6085 6085 { 6086 (yyval.sn) = new StatementNode 2( build_finally( (yyvsp[(2) - (2)].sn) ) );6086 (yyval.sn) = new StatementNode( build_finally( (yyvsp[(2) - (2)].sn) ) ); 6087 6087 } 6088 6088 break; … … 6119 6119 /* Line 1806 of yacc.c */ 6120 6120 #line 933 "parser.yy" 6121 { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0); }6121 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (6)].flag), (yyvsp[(4) - (6)].constant), 0 ) ); } 6122 6122 break; 6123 6123 … … 6126 6126 /* Line 1806 of yacc.c */ 6127 6127 #line 935 "parser.yy" 6128 { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ); }6128 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (8)].flag), (yyvsp[(4) - (8)].constant), (yyvsp[(6) - (8)].en) ) ); } 6129 6129 break; 6130 6130 … … 6133 6133 /* Line 1806 of yacc.c */ 6134 6134 #line 937 "parser.yy" 6135 { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ); }6135 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (10)].flag), (yyvsp[(4) - (10)].constant), (yyvsp[(6) - (10)].en), (yyvsp[(8) - (10)].en) ) ); } 6136 6136 break; 6137 6137 … … 6140 6140 /* Line 1806 of yacc.c */ 6141 6141 #line 939 "parser.yy" 6142 { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ); }6142 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (12)].flag), (yyvsp[(4) - (12)].constant), (yyvsp[(6) - (12)].en), (yyvsp[(8) - (12)].en), (yyvsp[(10) - (12)].en) ) ); } 6143 6143 break; 6144 6144 … … 6147 6147 /* Line 1806 of yacc.c */ 6148 6148 #line 941 "parser.yy" 6149 { (yyval.sn) = new AsmStmtNode( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ); }6149 { (yyval.sn) = new StatementNode( build_asmstmt( (yyvsp[(2) - (14)].flag), (yyvsp[(5) - (14)].constant), 0, (yyvsp[(8) - (14)].en), (yyvsp[(10) - (14)].en), (yyvsp[(12) - (14)].label) ) ); } 6150 6150 break; 6151 6151 … … 6182 6182 /* Line 1806 of yacc.c */ 6183 6183 #line 965 "parser.yy" 6184 { (yyval.en) = new ExpressionNode( build_asm ( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); }6184 { (yyval.en) = new ExpressionNode( build_asmexpr( 0, (yyvsp[(1) - (4)].constant), (yyvsp[(3) - (4)].en) ) ); } 6185 6185 break; 6186 6186 … … 6189 6189 /* Line 1806 of yacc.c */ 6190 6190 #line 967 "parser.yy" 6191 { (yyval.en) = new ExpressionNode( build_asm ( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); }6191 { (yyval.en) = new ExpressionNode( build_asmexpr( (yyvsp[(2) - (7)].en), (yyvsp[(4) - (7)].constant), (yyvsp[(6) - (7)].en) ) ); } 6192 6192 break; 6193 6193 … … 6217 6217 /* Line 1806 of yacc.c */ 6218 6218 #line 981 "parser.yy" 6219 { (yyval.label) = new LabelNode(); (yyval.label)-> append_label((yyvsp[(1) - (1)].tok) ); }6219 { (yyval.label) = new LabelNode(); (yyval.label)->labels.push_back( *(yyvsp[(1) - (1)].tok) ); } 6220 6220 break; 6221 6221 … … 6224 6224 /* Line 1806 of yacc.c */ 6225 6225 #line 983 "parser.yy" 6226 { (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)-> append_label((yyvsp[(3) - (3)].tok) ); }6226 { (yyval.label) = (yyvsp[(1) - (3)].label); (yyvsp[(1) - (3)].label)->labels.push_back( *(yyvsp[(3) - (3)].tok) ); } 6227 6227 break; 6228 6228 -
src/Parser/parser.yy
r797347f re82aa9df 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 14 11:03:22201613 // Update Count : 18 7912 // Last Modified On : Mon Aug 15 15:18:19 2016 13 // Update Count : 1891 14 14 // 15 15 … … 664 664 Token fn; 665 665 fn.str = new std::string( "^?{}" ); // location undefined 666 $$ = new StatementNode 2( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) );666 $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) ); 667 667 } 668 668 ; … … 678 678 compound_statement: 679 679 '{' '}' 680 { $$ = new CompoundStmtNode( (StatementNode *)0); }680 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); } 681 681 | '{' 682 682 // Two scopes are necessary because the block itself has a scope, but every declaration within the block also … … 685 685 local_label_declaration_opt // GCC, local labels 686 686 block_item_list pop '}' // C99, intermix declarations and statements 687 { $$ = new CompoundStmtNode( $5); }687 { $$ = new StatementNode( build_compound( $5 ) ); } 688 688 ; 689 689 … … 696 696 block_item: 697 697 declaration // CFA, new & old style declarations 698 { $$ = new StatementNode 2( $1 ); }698 { $$ = new StatementNode( $1 ); } 699 699 | EXTENSION declaration // GCC 700 700 { // mark all fields in list 701 701 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_next() ) 702 702 iter->set_extension( true ); 703 $$ = new StatementNode 2( $2 );703 $$ = new StatementNode( $2 ); 704 704 } 705 705 | function_definition 706 { $$ = new StatementNode 2( $1 ); }706 { $$ = new StatementNode( $1 ); } 707 707 | statement pop 708 708 ; … … 716 716 expression_statement: 717 717 comma_expression_opt ';' 718 { $$ = new StatementNode 2( build_expr( $1 ) ); }718 { $$ = new StatementNode( build_expr( $1 ) ); } 719 719 ; 720 720 … … 722 722 IF '(' comma_expression ')' statement %prec THEN 723 723 // explicitly deal with the shift/reduce conflict on if/else 724 { $$ = new StatementNode 2( build_if( $3, $5, nullptr ) ); }724 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); } 725 725 | IF '(' comma_expression ')' statement ELSE statement 726 { $$ = new StatementNode 2( build_if( $3, $5, $7 ) ); }726 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); } 727 727 | SWITCH '(' comma_expression ')' case_clause // CFA 728 { $$ = new StatementNode 2( build_switch( $3, $5 ) ); }728 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 729 729 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 730 730 { 731 StatementNode *sw = new StatementNode 2( build_switch( $3, $8 ) );731 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) ); 732 732 // The semantics of the declaration list is changed to include associated initialization, which is performed 733 733 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 735 735 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 736 736 // statement. 737 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( $7 ))->set_last( sw )) ) : sw;737 $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 738 738 } 739 739 | CHOOSE '(' comma_expression ')' case_clause // CFA 740 { $$ = new StatementNode 2( build_switch( $3, $5 ) ); }740 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 741 741 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA 742 742 { 743 StatementNode *sw = new StatementNode 2( build_switch( $3, $8 ) );744 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode2( $7 ))->set_last( sw )) ) : sw;743 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) ); 744 $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 745 745 } 746 746 ; … … 757 757 758 758 case_value_list: // CFA 759 case_value { $$ = new StatementNode 2( build_case( $1 ) ); }759 case_value { $$ = new StatementNode( build_case( $1 ) ); } 760 760 // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5" 761 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_last( new StatementNode 2( build_case( $3 ) ) ) ); }761 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 ) ) ) ); } 762 762 ; 763 763 764 764 case_label: // CFA 765 765 CASE case_value_list ':' { $$ = $2; } 766 | DEFAULT ':' { $$ = new StatementNode 2( build_default() ); }766 | DEFAULT ':' { $$ = new StatementNode( build_default() ); } 767 767 // A semantic check is required to ensure only one default clause per switch/choose statement. 768 768 ; … … 774 774 775 775 case_clause: // CFA 776 case_label_list statement { $$ = $1->append_last_case( new CompoundStmtNode( $2) ); }776 case_label_list statement { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); } 777 777 ; 778 778 … … 785 785 switch_clause_list: // CFA 786 786 case_label_list statement_list 787 { $$ = $1->append_last_case( new CompoundStmtNode( $2) ); }787 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); } 788 788 | switch_clause_list case_label_list statement_list 789 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new CompoundStmtNode( $3) ) ) ); }789 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 790 790 ; 791 791 … … 800 800 { $$ = $1->append_last_case( $2 ); } 801 801 | case_label_list statement_list fall_through_opt 802 { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }802 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); } 803 803 | choose_clause_list case_label_list fall_through 804 804 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); } 805 805 | choose_clause_list case_label_list statement_list fall_through_opt 806 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); }806 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( (StatementNode *)$3->set_last( $4 ) ) ) ) ) ); } 807 807 ; 808 808 809 809 fall_through_opt: // CFA 810 810 // empty 811 { $$ = new StatementNode 2( build_branch( "", BranchStmt::Break ) ); } // insert implicit break811 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } // insert implicit break 812 812 | fall_through 813 813 ; … … 822 822 iteration_statement: 823 823 WHILE '(' comma_expression ')' statement 824 { $$ = new StatementNode 2( build_while( $3, $5 ) ); }824 { $$ = new StatementNode( build_while( $3, $5 ) ); } 825 825 | DO statement WHILE '(' comma_expression ')' ';' 826 { $$ = new StatementNode 2( build_while( $5, $2 ) ); }826 { $$ = new StatementNode( build_while( $5, $2 ) ); } 827 827 | FOR '(' push for_control_expression ')' statement 828 { $$ = new StatementNode 2( build_for( $4, $6 ) ); }828 { $$ = new StatementNode( build_for( $4, $6 ) ); } 829 829 ; 830 830 … … 838 838 jump_statement: 839 839 GOTO IDENTIFIER ';' 840 { $$ = new StatementNode 2( build_branch( *$2, BranchStmt::Goto ) ); }840 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Goto ) ); } 841 841 | GOTO '*' comma_expression ';' // GCC, computed goto 842 842 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3); 843 843 // whereas normal operator precedence yields goto (*i)+3; 844 { $$ = new StatementNode 2( build_computedgoto( $3 ) ); }844 { $$ = new StatementNode( build_computedgoto( $3 ) ); } 845 845 | CONTINUE ';' 846 846 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 847 { $$ = new StatementNode 2( build_branch( "", BranchStmt::Continue ) ); }847 { $$ = new StatementNode( build_branch( "", BranchStmt::Continue ) ); } 848 848 | CONTINUE IDENTIFIER ';' // CFA, multi-level continue 849 849 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 850 850 // the target of the transfer appears only at the start of an iteration statement. 851 { $$ = new StatementNode 2( build_branch( *$2, BranchStmt::Continue ) ); delete $2; }851 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Continue ) ); delete $2; } 852 852 | BREAK ';' 853 853 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 854 { $$ = new StatementNode 2( build_branch( "", BranchStmt::Break ) ); }854 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } 855 855 | BREAK IDENTIFIER ';' // CFA, multi-level exit 856 856 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 857 857 // the target of the transfer appears only at the start of an iteration statement. 858 { $$ = new StatementNode 2( build_branch( *$2, BranchStmt::Break ) ); delete $2; }858 { $$ = new StatementNode( build_branch( *$2, BranchStmt::Break ) ); delete $2; } 859 859 | RETURN comma_expression_opt ';' 860 { $$ = new StatementNode 2( build_return( $2 ) ); }860 { $$ = new StatementNode( build_return( $2 ) ); } 861 861 | THROW assignment_expression_opt ';' // handles rethrow 862 { $$ = new StatementNode 2( build_throw( $2 ) ); }862 { $$ = new StatementNode( build_throw( $2 ) ); } 863 863 | THROWRESUME assignment_expression_opt ';' // handles reresume 864 { $$ = new StatementNode 2( build_throw( $2 ) ); }864 { $$ = new StatementNode( build_throw( $2 ) ); } 865 865 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 866 { $$ = new StatementNode 2( build_throw( $2 ) ); }866 { $$ = new StatementNode( build_throw( $2 ) ); } 867 867 ; 868 868 869 869 exception_statement: 870 870 TRY compound_statement handler_list 871 { $$ = new StatementNode 2( build_try( $2, $3, 0 ) ); }871 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 872 872 | TRY compound_statement finally_clause 873 { $$ = new StatementNode 2( build_try( $2, 0, $3 ) ); }873 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 874 874 | TRY compound_statement handler_list finally_clause 875 { $$ = new StatementNode 2( build_try( $2, $3, $4 ) ); }875 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } 876 876 ; 877 877 … … 880 880 // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block. 881 881 | CATCH '(' ELLIPSIS ')' compound_statement 882 { $$ = new StatementNode 2( build_catch( 0, $5, true ) ); }882 { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 883 883 | handler_clause CATCH '(' ELLIPSIS ')' compound_statement 884 { $$ = (StatementNode *)$1->set_last( new StatementNode 2( build_catch( 0, $6, true ) ) ); }884 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 885 885 | CATCHRESUME '(' ELLIPSIS ')' compound_statement 886 { $$ = new StatementNode 2( build_catch( 0, $5, true ) ); }886 { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 887 887 | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement 888 { $$ = (StatementNode *)$1->set_last( new StatementNode 2( build_catch( 0, $6, true ) ) ); }888 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 889 889 ; 890 890 891 891 handler_clause: 892 892 CATCH '(' push push exception_declaration pop ')' compound_statement pop 893 { $$ = new StatementNode 2( build_catch( $5, $8 ) ); }893 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 894 894 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 895 { $$ = (StatementNode *)$1->set_last( new StatementNode 2( build_catch( $6, $9 ) ) ); }895 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 896 896 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 897 { $$ = new StatementNode 2( build_catch( $5, $8 ) ); }897 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 898 898 | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 899 { $$ = (StatementNode *)$1->set_last( new StatementNode 2( build_catch( $6, $9 ) ) ); }899 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 900 900 ; 901 901 … … 903 903 FINALLY compound_statement 904 904 { 905 $$ = new StatementNode 2( build_finally( $2 ) );905 $$ = new StatementNode( build_finally( $2 ) ); 906 906 } 907 907 ; … … 931 931 asm_statement: 932 932 ASM asm_volatile_opt '(' string_literal_list ')' ';' 933 { $$ = new AsmStmtNode( $2, $4, 0); }933 { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); } 934 934 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC 935 { $$ = new AsmStmtNode( $2, $4, $6); }935 { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); } 936 936 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';' 937 { $$ = new AsmStmtNode( $2, $4, $6, $8); }937 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); } 938 938 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 939 { $$ = new AsmStmtNode( $2, $4, $6, $8, $10); }939 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); } 940 940 | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 941 { $$ = new AsmStmtNode( $2, $5, 0, $8, $10, $12); }941 { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); } 942 942 ; 943 943 … … 963 963 asm_operand: // GCC 964 964 string_literal_list '(' constant_expression ')' 965 { $$ = new ExpressionNode( build_asm ( 0, $1, $3 ) ); }965 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); } 966 966 | '[' constant_expression ']' string_literal_list '(' constant_expression ')' 967 { $$ = new ExpressionNode( build_asm ( $2, $4, $6 ) ); }967 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); } 968 968 ; 969 969 … … 974 974 { $$ = new ExpressionNode( $1 ); } 975 975 | asm_clobbers_list_opt ',' string_literal_list 976 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); }976 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 977 977 ; 978 978 979 979 label_list: 980 980 no_attr_identifier 981 { $$ = new LabelNode(); $$-> append_label($1 ); }981 { $$ = new LabelNode(); $$->labels.push_back( *$1 ); } 982 982 | label_list ',' no_attr_identifier 983 { $$ = $1; $1-> append_label($3 ); }983 { $$ = $1; $1->labels.push_back( *$3 ); } 984 984 ; 985 985 -
src/Parser/parseutility.cc
r797347f re82aa9df 10 10 // Created On : Sat May 16 15:30:39 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : S at May 16 15:31:33 201513 // Update Count : 212 // Last Modified On : Sun Aug 14 23:45:03 2016 13 // Update Count : 3 14 14 // 15 15 … … 17 17 #include "SynTree/Type.h" 18 18 #include "SynTree/Expression.h" 19 20 // rewrite 21 // if ( x ) ... 22 // as 23 // if ( (int)(x != 0) ) ... 19 24 20 25 Expression *notZeroExpr( Expression *orig ) { -
src/tests/.expect/64/gccExtensions.txt
r797347f re82aa9df 17 17 asm volatile ( "mov %1, %0\n\tadd $1, %0" : "=r" ( __dst__i_2 ) : "r" ( __src__i_2 ) : ); 18 18 asm ( "mov %1, %0\n\tadd $1, %0" : "=r" ( __dst__i_2 ), "=r" ( __src__i_2 ) : [ __src__i_2 ] "r" ( __dst__i_2 ) : "r0" ); 19 L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" : : "r" ( __src__i_2 ), "r" ( (&__dst__i_2) ) : "r5", "memory" : L1, L2 ); 19 20 double _Complex __c1__Xd_2; 20 21 double _Complex __c2__Xd_2; -
src/tests/Makefile.am
r797347f re82aa9df 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Tue Aug 9 15:34:57201614 ## Update Count : 3 813 ## Last Modified On : Mon Aug 15 12:24:54 2016 14 ## Update Count : 39 15 15 ############################################################################### 16 16 … … 27 27 28 28 all-local : 29 @+python test.py vector_test avl_test operators numericConstants expression enum a smName array typeof cast dtor-early-exit init_once29 @+python test.py vector_test avl_test operators numericConstants expression enum array typeof cast dtor-early-exit init_once 30 30 31 31 all-tests : -
src/tests/Makefile.in
r797347f re82aa9df 635 635 636 636 all-local : 637 @+python test.py vector_test avl_test operators numericConstants expression enum a smName array typeof cast dtor-early-exit init_once637 @+python test.py vector_test avl_test operators numericConstants expression enum array typeof cast dtor-early-exit init_once 638 638 639 639 all-tests : -
src/tests/gccExtensions.c
r797347f re82aa9df 10 10 // Created On : Sun Aug 14 17:28:17 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 14 17:36:28201613 // Update Count : 312 // Last Modified On : Mon Aug 15 12:44:35 2016 13 // Update Count : 5 14 14 // 15 15 … … 44 44 : [src] "r" (dst) 45 45 : "r0"); 46 #if 0 46 47 47 L1: L2: 48 48 asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" … … 51 51 : "r5", "memory" 52 52 : L1, L2 ); 53 #endif 53 54 54 __complex__ c1; 55 55 _Complex c2;
Note: See TracChangeset
for help on using the changeset viewer.