Changes in src/Parser/parser.yy [7bf7fb9:ac71a86]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r7bf7fb9 rac71a86 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 7 09:37:48201613 // Update Count : 1 76412 // Last Modified On : Thu Aug 18 23:49:10 2016 13 // Update Count : 1909 14 14 // 15 15 … … 43 43 #define YYDEBUG_LEXER_TEXT (yylval) // lexer loads this up each time 44 44 #define YYDEBUG 1 // get the pretty debugging code to compile 45 extern char *yytext;46 45 47 46 #undef __GNUC_MINOR__ … … 56 55 #include "LinkageSpec.h" 57 56 58 DeclarationNode *theTree = 0; // the resulting parse tree 59 LinkageSpec::Type linkage = LinkageSpec::Cforall; 60 std::stack< LinkageSpec::Type > linkageStack; 61 TypedefTable typedefTable; 57 extern DeclarationNode * parseTree; 58 extern LinkageSpec::Spec linkage; 59 extern TypedefTable typedefTable; 60 61 std::stack< LinkageSpec::Spec > linkageStack; 62 62 63 63 void appendStr( std::string &to, std::string *from ) { … … 121 121 DeclarationNode::TypeClass tclass; 122 122 StatementNode *sn; 123 ConstantNode *constant; 123 ConstantExpr *constant; 124 ForCtl *fctl; 124 125 LabelNode *label; 125 126 InitializerNode *in; … … 133 134 134 135 // expressions 135 %type< constant> constant136 %type<en> constant 136 137 %type<en> tuple tuple_expression_list 137 138 %type<op> ptrref_operator unary_operator assignment_operator … … 142 143 %type<en> constant_expression assignment_expression assignment_expression_opt 143 144 %type<en> comma_expression comma_expression_opt 144 %type<en> argument_expression_list argument_expression for_control_expression assignment_opt 145 %type<en> argument_expression_list argument_expression assignment_opt 146 %type<fctl> for_control_expression 145 147 %type<en> subrange 146 148 %type<en> asm_operands_opt asm_operands_list asm_operand 147 149 %type<label> label_list 148 %type< constant> asm_clobbers_list_opt150 %type<en> asm_clobbers_list_opt 149 151 %type<flag> asm_volatile_opt 150 152 … … 159 161 %type<sn> case_value_list case_label case_label_list 160 162 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 161 %type< pn> handler_list handler_clause finally_clause163 %type<sn> handler_list handler_clause finally_clause 162 164 163 165 // declarations … … 221 223 %type<decl> paren_identifier paren_type 222 224 223 %type<decl> storage_class storage_class_ name storage_class_list225 %type<decl> storage_class storage_class_list 224 226 225 227 %type<decl> sue_declaration_specifier sue_type_specifier … … 309 311 constant: 310 312 // ENUMERATIONconstant is not included here; it is treated as a variable with type "enumeration constant". 311 INTEGERconstant { $$ = build_constantInteger( *$1); }312 | FLOATINGconstant { $$ = build_constantFloat( *$1); }313 | CHARACTERconstant { $$ = build_constantChar( *$1); }313 INTEGERconstant { $$ = new ExpressionNode( build_constantInteger( assign_strptr($1) ) ); } 314 | FLOATINGconstant { $$ = new ExpressionNode( build_constantFloat( assign_strptr($1) ) ); } 315 | CHARACTERconstant { $$ = new ExpressionNode( build_constantChar( assign_strptr($1) ) ); } 314 316 ; 315 317 … … 336 338 337 339 string_literal_list: // juxtaposed strings are concatenated 338 STRINGliteral { $$ = build_constantStr( *$1); }340 STRINGliteral { $$ = build_constantStr( assign_strptr($1) ); } 339 341 | string_literal_list STRINGliteral 340 342 { 341 appendStr( $1->get_ expr()->get_constant()->get_value(), $2 );343 appendStr( $1->get_constant()->get_value(), $2 ); 342 344 delete $2; // allocated by lexer 343 345 $$ = $1; … … 349 351 primary_expression: 350 352 IDENTIFIER // typedef name cannot be used as a variable name 351 { $$ = new VarRefNode( $1); }353 { $$ = new ExpressionNode( build_varref( $1 ) ); } 352 354 | zero_one 353 { $$ = new VarRefNode( $1); }355 { $$ = new ExpressionNode( build_varref( $1 ) ); } 354 356 | '(' comma_expression ')' 355 357 { $$ = $2; } 356 358 | '(' compound_statement ')' // GCC, lambda expression 357 { $$ = new ValofExprNode( $2); }359 { $$ = new ExpressionNode( build_valexpr( $2 ) ); } 358 360 ; 359 361 … … 365 367 // little advantage to this feature and many disadvantages. It is possible to write x[(i,j)] in CFA, which is 366 368 // equivalent to the old x[i,j]. 367 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Index, $1, $4 ) ); }369 { $$ = new ExpressionNode( build_binary_val( OperKinds::Index, $1, $4 ) ); } 368 370 | postfix_expression '(' argument_expression_list ')' 369 { $$ = new CompositeExprNode( build_func( $1, $3 ) ); }371 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 370 372 // ambiguity with .0 so space required after field-selection, e.g. 371 373 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1; 372 374 | postfix_expression '.' no_attr_identifier 373 { $$ = new CompositeExprNode( build_fieldSel( $1, new VarRefNode( $3 ) ) ); }375 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 374 376 | postfix_expression '.' '[' push field_list pop ']' // CFA, tuple field selector 375 377 | postfix_expression ARROW no_attr_identifier 376 { $$ = new CompositeExprNode( build_pfieldSel( $1, new VarRefNode( $3 ) ) ); }378 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 377 379 | postfix_expression ARROW '[' push field_list pop ']' // CFA, tuple field selector 378 380 | postfix_expression ICR 379 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); }381 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::IncrPost, $1 ) ); } 380 382 | postfix_expression DECR 381 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); }383 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::DecrPost, $1 ) ); } 382 384 | '(' type_name_no_function ')' '{' initializer_list comma_opt '}' // C99 383 { $$ = new CompoundLiteralNode( $2, new InitializerNode( $5, true) ); }385 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } 384 386 | postfix_expression '{' argument_expression_list '}' // CFA 385 387 { 386 388 Token fn; 387 389 fn.str = new std::string( "?{}" ); // location undefined 388 $$ = new CompositeExprNode( build_func( new VarRefNode( fn ), (ExpressionNode *)( $1 )->set_link( $3 ) ) );390 $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ); 389 391 } 390 392 ; … … 393 395 argument_expression 394 396 | argument_expression_list ',' argument_expression 395 { $$ = (ExpressionNode *)( $1->set_l ink( $3 )); }397 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 396 398 ; 397 399 … … 400 402 { $$ = 0; } // use default argument 401 403 | assignment_expression 402 | no_attr_identifier ':' assignment_expression403 { $$ = $3->set_argName( $1 ); }404 // Only a list of no_attr_identifier_or_type_name is allowed in this context. However, there is insufficient405 // look ahead to distinguish between this list of parameter names and a tuple, so the tuple form must be used406 // with an appropriate semantic check.407 | '[' push assignment_expression pop ']' ':' assignment_expression408 { $$ = $7->set_argName( $3 ); }409 | '[' push assignment_expression ',' tuple_expression_list pop ']' ':' assignment_expression410 { $$ = $9->set_argName( new CompositeExprNode( build_tuple( (ExpressionNode *)$3->set_link( $5 ) ) ) ); }411 404 ; 412 405 413 406 field_list: // CFA, tuple field selector 414 407 field 415 | field_list ',' field { $$ = (ExpressionNode *)$1->set_l ink( $3 ); }408 | field_list ',' field { $$ = (ExpressionNode *)$1->set_last( $3 ); } 416 409 ; 417 410 418 411 field: // CFA, tuple field selector 419 412 no_attr_identifier 420 { $$ = new VarRefNode( $1); }413 { $$ = new ExpressionNode( build_varref( $1 ) ); } 421 414 // ambiguity with .0 so space required after field-selection, e.g. 422 415 // struct S { int 0, 1; } s; s. 0 = 0; s. 1 = 1; 423 416 | no_attr_identifier '.' field 424 { $$ = new CompositeExprNode( build_fieldSel( $3, new VarRefNode( $1 ) ) ); }417 { $$ = new ExpressionNode( build_fieldSel( $3, build_varref( $1 ) ) ); } 425 418 | no_attr_identifier '.' '[' push field_list pop ']' 426 { $$ = new CompositeExprNode( build_fieldSel( $5, new VarRefNode( $1 ) ) ); }419 { $$ = new ExpressionNode( build_fieldSel( $5, build_varref( $1 ) ) ); } 427 420 | no_attr_identifier ARROW field 428 { $$ = new CompositeExprNode( build_pfieldSel( $3, new VarRefNode( $1 ) ) ); }421 { $$ = new ExpressionNode( build_pfieldSel( $3, build_varref( $1 ) ) ); } 429 422 | no_attr_identifier ARROW '[' push field_list pop ']' 430 { $$ = new CompositeExprNode( build_pfieldSel( $5, new VarRefNode( $1 ) ) ); }423 { $$ = new ExpressionNode( build_pfieldSel( $5, build_varref( $1 ) ) ); } 431 424 ; 432 425 … … 438 431 { $$ = $1; } 439 432 | string_literal_list 440 { $$ = $1; }433 { $$ = new ExpressionNode( $1 ); } 441 434 | EXTENSION cast_expression // GCC 442 435 { $$ = $2->set_extension( true ); } … … 448 441 switch ( $1 ) { 449 442 case OperKinds::AddressOf: 450 $$ = new CompositeExprNode( build_addressOf( $2 ) );443 $$ = new ExpressionNode( build_addressOf( $2 ) ); 451 444 break; 452 445 case OperKinds::PointTo: 453 $$ = new CompositeExprNode( build_unary_val( $1, $2 ) );446 $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); 454 447 break; 455 448 default: … … 458 451 } 459 452 | unary_operator cast_expression 460 { $$ = new CompositeExprNode( build_unary_val( $1, $2 ) ); }453 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); } 461 454 | ICR unary_expression 462 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::Incr, $2 ) ); }455 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Incr, $2 ) ); } 463 456 | DECR unary_expression 464 { $$ = new CompositeExprNode( build_unary_ptr( OperKinds::Decr, $2 ) ); }457 { $$ = new ExpressionNode( build_unary_ptr( OperKinds::Decr, $2 ) ); } 465 458 | SIZEOF unary_expression 466 { $$ = new CompositeExprNode( build_sizeOf( $2 ) ); }459 { $$ = new ExpressionNode( build_sizeOfexpr( $2 ) ); } 467 460 | SIZEOF '(' type_name_no_function ')' 468 { $$ = new CompositeExprNode( build_sizeOf( new TypeValueNode( $3 ) ) ); } 461 { $$ = new ExpressionNode( build_sizeOftype( $3 ) ); } 462 | ALIGNOF unary_expression // GCC, variable alignment 463 { $$ = new ExpressionNode( build_alignOfexpr( $2 ) ); } 464 | ALIGNOF '(' type_name_no_function ')' // GCC, type alignment 465 { $$ = new ExpressionNode( build_alignOftype( $3 ) ); } 469 466 | OFFSETOF '(' type_name_no_function ',' no_attr_identifier ')' 470 { $$ = new CompositeExprNode( build_offsetOf( new TypeValueNode( $3 ), new VarRefNode( $5 ) ) ); }467 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 471 468 | ATTR_IDENTIFIER 472 { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ) ) ); } 469 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), nullptr ) ); } 470 | ATTR_IDENTIFIER '(' argument_expression ')' 471 { $$ = new ExpressionNode( build_attrexpr( build_varref( $1 ), $3 ) ); } 473 472 | ATTR_IDENTIFIER '(' type_name ')' 474 { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ), new TypeValueNode( $3 ) ) ); } 475 | ATTR_IDENTIFIER '(' argument_expression ')' 476 { $$ = new CompositeExprNode( build_attr( new VarRefNode( $1 ), $3 ) ); } 477 | ALIGNOF unary_expression // GCC, variable alignment 478 { $$ = new CompositeExprNode( build_alignOf( $2 ) ); } 479 | ALIGNOF '(' type_name_no_function ')' // GCC, type alignment 480 { $$ = new CompositeExprNode( build_alignOf( new TypeValueNode( $3 ) ) ); } 473 { $$ = new ExpressionNode( build_attrtype( build_varref( $1 ), $3 ) ); } 481 474 // | ANDAND IDENTIFIER // GCC, address of label 482 // { $$ = new CompositeExprNode( new OperatorNode( OperKinds::LabelAddress ), new VarRefNode( $2, true ) ); }475 // { $$ = new ExpressionNode( new OperatorNode( OperKinds::LabelAddress ), new ExpressionNode( build_varref( $2, true ) ); } 483 476 ; 484 477 … … 500 493 unary_expression 501 494 | '(' type_name_no_function ')' cast_expression 502 { $$ = new CompositeExprNode( build_cast( new TypeValueNode( $2 ), $4 ) ); }495 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 503 496 | '(' type_name_no_function ')' tuple 504 { $$ = new CompositeExprNode( build_cast( new TypeValueNode( $2 ), $4 ) ); }497 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 505 498 ; 506 499 … … 508 501 cast_expression 509 502 | multiplicative_expression '*' cast_expression 510 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); }503 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 511 504 | multiplicative_expression '/' cast_expression 512 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Div, $1, $3 ) ); }505 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 513 506 | multiplicative_expression '%' cast_expression 514 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); }507 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 515 508 ; 516 509 … … 518 511 multiplicative_expression 519 512 | additive_expression '+' multiplicative_expression 520 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); }513 { $$ = new ExpressionNode( build_binary_val( OperKinds::Plus, $1, $3 ) ); } 521 514 | additive_expression '-' multiplicative_expression 522 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); }515 { $$ = new ExpressionNode( build_binary_val( OperKinds::Minus, $1, $3 ) ); } 523 516 ; 524 517 … … 526 519 additive_expression 527 520 | shift_expression LS additive_expression 528 { $$ = new CompositeExprNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); }521 { $$ = new ExpressionNode( build_binary_val( OperKinds::LShift, $1, $3 ) ); } 529 522 | shift_expression RS additive_expression 530 { $$ = new CompositeExprNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); }523 { $$ = new ExpressionNode( build_binary_val( OperKinds::RShift, $1, $3 ) ); } 531 524 ; 532 525 … … 534 527 shift_expression 535 528 | relational_expression '<' shift_expression 536 { $$ = new CompositeExprNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); }529 { $$ = new ExpressionNode( build_binary_val( OperKinds::LThan, $1, $3 ) ); } 537 530 | relational_expression '>' shift_expression 538 { $$ = new CompositeExprNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); }531 { $$ = new ExpressionNode( build_binary_val( OperKinds::GThan, $1, $3 ) ); } 539 532 | relational_expression LE shift_expression 540 { $$ = new CompositeExprNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); }533 { $$ = new ExpressionNode( build_binary_val( OperKinds::LEThan, $1, $3 ) ); } 541 534 | relational_expression GE shift_expression 542 { $$ = new CompositeExprNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); }535 { $$ = new ExpressionNode( build_binary_val( OperKinds::GEThan, $1, $3 ) ); } 543 536 ; 544 537 … … 546 539 relational_expression 547 540 | equality_expression EQ relational_expression 548 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); }541 { $$ = new ExpressionNode( build_binary_val( OperKinds::Eq, $1, $3 ) ); } 549 542 | equality_expression NE relational_expression 550 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); }543 { $$ = new ExpressionNode( build_binary_val( OperKinds::Neq, $1, $3 ) ); } 551 544 ; 552 545 … … 554 547 equality_expression 555 548 | AND_expression '&' equality_expression 556 { $$ = new CompositeExprNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); }549 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitAnd, $1, $3 ) ); } 557 550 ; 558 551 … … 560 553 AND_expression 561 554 | exclusive_OR_expression '^' AND_expression 562 { $$ = new CompositeExprNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); }555 { $$ = new ExpressionNode( build_binary_val( OperKinds::Xor, $1, $3 ) ); } 563 556 ; 564 557 … … 566 559 exclusive_OR_expression 567 560 | inclusive_OR_expression '|' exclusive_OR_expression 568 { $$ = new CompositeExprNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); }561 { $$ = new ExpressionNode( build_binary_val( OperKinds::BitOr, $1, $3 ) ); } 569 562 ; 570 563 … … 572 565 inclusive_OR_expression 573 566 | logical_AND_expression ANDAND inclusive_OR_expression 574 { $$ = new CompositeExprNode( build_and_or( $1, $3, true ) ); }567 { $$ = new ExpressionNode( build_and_or( $1, $3, true ) ); } 575 568 ; 576 569 … … 578 571 logical_AND_expression 579 572 | logical_OR_expression OROR logical_AND_expression 580 { $$ = new CompositeExprNode( build_and_or( $1, $3, false ) ); }573 { $$ = new ExpressionNode( build_and_or( $1, $3, false ) ); } 581 574 ; 582 575 … … 584 577 logical_OR_expression 585 578 | logical_OR_expression '?' comma_expression ':' conditional_expression 586 { $$ = new CompositeExprNode( build_cond( $1, $3, $5 ) ); }579 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 587 580 // FIX ME: this hack computes $1 twice 588 581 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 589 { $$ = new CompositeExprNode( build_cond( $1, $1, $4 ) ); }582 { $$ = new ExpressionNode( build_cond( $1, $1, $4 ) ); } 590 583 | logical_OR_expression '?' comma_expression ':' tuple // CFA, tuple expression 591 { $$ = new CompositeExprNode( build_cond( $1, $3, $5 ) ); }584 { $$ = new ExpressionNode( build_cond( $1, $3, $5 ) ); } 592 585 ; 593 586 … … 600 593 conditional_expression 601 594 | unary_expression assignment_operator assignment_expression 602 { $$ = new CompositeExprNode( build_binary_ptr( $2, $1, $3 ) ); }595 { $$ = new ExpressionNode( build_binary_ptr( $2, $1, $3 ) ); } 603 596 | tuple assignment_opt // CFA, tuple expression 604 { $$ = ( $2 == 0 ) ? $1 : new CompositeExprNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); }597 { $$ = ( $2 == 0 ) ? $1 : new ExpressionNode( build_binary_ptr( OperKinds::Assign, $1, $2 ) ); } 605 598 ; 606 599 607 600 assignment_expression_opt: 608 601 // empty 609 { $$ = n ew NullExprNode; }602 { $$ = nullptr; } 610 603 | assignment_expression 611 604 ; … … 629 622 // comma_expression in new_identifier_parameter_array and new_abstract_array 630 623 '[' ']' 631 { $$ = new CompositeExprNode( build_tuple() ); }624 { $$ = new ExpressionNode( build_tuple() ); } 632 625 | '[' push assignment_expression pop ']' 633 { $$ = new CompositeExprNode( build_tuple( $3 ) ); }626 { $$ = new ExpressionNode( build_tuple( $3 ) ); } 634 627 | '[' push ',' tuple_expression_list pop ']' 635 { $$ = new CompositeExprNode( build_tuple( (ExpressionNode *)(new NullExprNode)->set_link( $4 ) ) ); }628 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); } 636 629 | '[' push assignment_expression ',' tuple_expression_list pop ']' 637 { $$ = new CompositeExprNode( build_tuple( (ExpressionNode *)$3->set_link( $5 ) ) ); }630 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); } 638 631 ; 639 632 … … 641 634 assignment_expression_opt 642 635 | tuple_expression_list ',' assignment_expression_opt 643 { $$ = (ExpressionNode *)$1->set_l ink( $3 ); }636 { $$ = (ExpressionNode *)$1->set_last( $3 ); } 644 637 ; 645 638 … … 647 640 assignment_expression 648 641 | comma_expression ',' assignment_expression 649 { $$ = new CompositeExprNode( build_comma( $1, $3 ) ); }642 { $$ = new ExpressionNode( build_comma( $1, $3 ) ); } 650 643 ; 651 644 … … 671 664 Token fn; 672 665 fn.str = new std::string( "^?{}" ); // location undefined 673 $$ = new StatementNode( StatementNode::Exp, new CompositeExprNode( build_func( new VarRefNode( fn ), (ExpressionNode *)( $2 )->set_link( $4 ) ) ), 0);666 $$ = new StatementNode( build_expr( new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $2 )->set_last( $4 ) ) ) ) ); 674 667 } 675 668 ; … … 685 678 compound_statement: 686 679 '{' '}' 687 { $$ = new CompoundStmtNode( (StatementNode *)0); }680 { $$ = new StatementNode( build_compound( (StatementNode *)0 ) ); } 688 681 | '{' 689 682 // Two scopes are necessary because the block itself has a scope, but every declaration within the block also … … 692 685 local_label_declaration_opt // GCC, local labels 693 686 block_item_list pop '}' // C99, intermix declarations and statements 694 { $$ = new CompoundStmtNode( $5); }687 { $$ = new StatementNode( build_compound( $5 ) ); } 695 688 ; 696 689 … … 698 691 block_item 699 692 | block_item_list push block_item 700 { if ( $1 != 0 ) { $1->set_l ink( $3 ); $$ = $1; } }693 { if ( $1 != 0 ) { $1->set_last( $3 ); $$ = $1; } } 701 694 ; 702 695 … … 706 699 | EXTENSION declaration // GCC 707 700 { // mark all fields in list 708 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )701 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) 709 702 iter->set_extension( true ); 710 703 $$ = new StatementNode( $2 ); … … 718 711 statement 719 712 | statement_list statement 720 { if ( $1 != 0 ) { $1->set_l ink( $2 ); $$ = $1; } }713 { if ( $1 != 0 ) { $1->set_last( $2 ); $$ = $1; } } 721 714 ; 722 715 723 716 expression_statement: 724 717 comma_expression_opt ';' 725 { $$ = new StatementNode( StatementNode::Exp, $1, 0); }718 { $$ = new StatementNode( build_expr( $1 ) ); } 726 719 ; 727 720 … … 729 722 IF '(' comma_expression ')' statement %prec THEN 730 723 // explicitly deal with the shift/reduce conflict on if/else 731 { $$ = new StatementNode( StatementNode::If, $3, $5); }724 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); } 732 725 | IF '(' comma_expression ')' statement ELSE statement 733 { $$ = new StatementNode( StatementNode::If, $3, (StatementNode *)mkList((*$5, *$7 )) ); }726 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); } 734 727 | SWITCH '(' comma_expression ')' case_clause // CFA 735 { $$ = new StatementNode( StatementNode::Switch, $3, $5); }728 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 736 729 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 737 730 { 738 StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8);731 StatementNode *sw = new StatementNode( build_switch( $3, $8 ) ); 739 732 // The semantics of the declaration list is changed to include associated initialization, which is performed 740 733 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound … … 742 735 // therefore, are removed from the grammar even though C allows it. The change also applies to choose 743 736 // statement. 744 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw;737 $$ = $7 != 0 ? new StatementNode( build_compound( (StatementNode *)((new StatementNode( $7 ))->set_last( sw )) ) ) : sw; 745 738 } 746 739 | CHOOSE '(' comma_expression ')' case_clause // CFA 747 { $$ = new StatementNode( StatementNode::Switch, $3, $5); }740 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 748 741 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA 749 742 { 750 StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8);751 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( 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; 752 745 } 753 746 ; … … 759 752 constant_expression { $$ = $1; } 760 753 | constant_expression ELLIPSIS constant_expression // GCC, subrange 761 { $$ = new CompositeExprNode( build_range( $1, $3 ) ); }754 { $$ = new ExpressionNode( build_range( $1, $3 ) ); } 762 755 | subrange // CFA, subrange 763 756 ; 764 757 765 758 case_value_list: // CFA 766 case_value { $$ = new StatementNode( StatementNode::Case, $1, 0); }759 case_value { $$ = new StatementNode( build_case( $1 ) ); } 767 760 // convert case list, e.g., "case 1, 3, 5:" into "case 1: case 3: case 5" 768 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_l ink( new StatementNode( StatementNode::Case, $3, 0) ) ); }761 | case_value_list ',' case_value { $$ = (StatementNode *)($1->set_last( new StatementNode( build_case( $3 ) ) ) ); } 769 762 ; 770 763 771 764 case_label: // CFA 772 765 CASE case_value_list ':' { $$ = $2; } 773 | DEFAULT ':' { $$ = new StatementNode( StatementNode::Default); }766 | DEFAULT ':' { $$ = new StatementNode( build_default() ); } 774 767 // A semantic check is required to ensure only one default clause per switch/choose statement. 775 768 ; … … 777 770 case_label_list: // CFA 778 771 case_label 779 | case_label_list case_label { $$ = (StatementNode *)( $1->set_l ink( $2 )); }772 | case_label_list case_label { $$ = (StatementNode *)( $1->set_last( $2 )); } 780 773 ; 781 774 782 775 case_clause: // CFA 783 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 ) ) ); } 784 777 ; 785 778 … … 792 785 switch_clause_list: // CFA 793 786 case_label_list statement_list 794 { $$ = $1->append_last_case( new CompoundStmtNode( $2) ); }787 { $$ = $1->append_last_case( new StatementNode( build_compound( $2 ) ) ); } 795 788 | switch_clause_list case_label_list statement_list 796 { $$ = (StatementNode *)( $1->set_l ink( $2->append_last_case( new CompoundStmtNode( $3) ) ) ); }789 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( new StatementNode( build_compound( $3 ) ) ) ) ); } 797 790 ; 798 791 … … 807 800 { $$ = $1->append_last_case( $2 ); } 808 801 | case_label_list statement_list fall_through_opt 809 { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); }802 { $$ = $1->append_last_case( new StatementNode( build_compound( (StatementNode *)$2->set_last( $3 ) ) ) ); } 810 803 | choose_clause_list case_label_list fall_through 811 { $$ = (StatementNode *)( $1->set_l ink( $2->append_last_case( $3 ))); }804 { $$ = (StatementNode *)( $1->set_last( $2->append_last_case( $3 ))); } 812 805 | choose_clause_list case_label_list statement_list fall_through_opt 813 { $$ = (StatementNode *)( $1->set_l ink( $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 ) ) ) ) ) ); } 814 807 ; 815 808 816 809 fall_through_opt: // CFA 817 810 // empty 818 { $$ = new StatementNode( StatementNode::Break ); }// insert implicit break811 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } // insert implicit break 819 812 | fall_through 820 813 ; … … 829 822 iteration_statement: 830 823 WHILE '(' comma_expression ')' statement 831 { $$ = new StatementNode( StatementNode::While, $3, $5); }824 { $$ = new StatementNode( build_while( $3, $5 ) ); } 832 825 | DO statement WHILE '(' comma_expression ')' ';' 833 { $$ = new StatementNode( StatementNode::Do, $5, $2); }826 { $$ = new StatementNode( build_while( $5, $2 ) ); } 834 827 | FOR '(' push for_control_expression ')' statement 835 { $$ = new StatementNode( StatementNode::For, $4, $6); }828 { $$ = new StatementNode( build_for( $4, $6 ) ); } 836 829 ; 837 830 838 831 for_control_expression: 839 832 comma_expression_opt pop ';' comma_expression_opt ';' comma_expression_opt 840 { $$ = new ForCtl ExprNode( $1, $4, $6 ); }833 { $$ = new ForCtl( $1, $4, $6 ); } 841 834 | declaration comma_expression_opt ';' comma_expression_opt // C99 842 { $$ = new ForCtl ExprNode( $1, $2, $4 ); }843 ;835 { $$ = new ForCtl( $1, $2, $4 ); } 836 ; 844 837 845 838 jump_statement: 846 839 GOTO IDENTIFIER ';' 847 { $$ = new StatementNode( StatementNode::Goto, $2); }840 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Goto ) ); } 848 841 | GOTO '*' comma_expression ';' // GCC, computed goto 849 842 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3); 850 843 // whereas normal operator precedence yields goto (*i)+3; 851 { $$ = new StatementNode( StatementNode::Goto, $3); }844 { $$ = new StatementNode( build_computedgoto( $3 ) ); } 852 845 | CONTINUE ';' 853 846 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 854 { $$ = new StatementNode( StatementNode::Continue); }847 { $$ = new StatementNode( build_branch( "", BranchStmt::Continue ) ); } 855 848 | CONTINUE IDENTIFIER ';' // CFA, multi-level continue 856 849 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 857 850 // the target of the transfer appears only at the start of an iteration statement. 858 { $$ = new StatementNode( StatementNode::Continue, $2); }851 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Continue ) ); } 859 852 | BREAK ';' 860 853 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 861 { $$ = new StatementNode( StatementNode::Break); }854 { $$ = new StatementNode( build_branch( "", BranchStmt::Break ) ); } 862 855 | BREAK IDENTIFIER ';' // CFA, multi-level exit 863 856 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 864 857 // the target of the transfer appears only at the start of an iteration statement. 865 { $$ = new StatementNode( StatementNode::Break, $2); }858 { $$ = new StatementNode( build_branch( assign_strptr($2), BranchStmt::Break ) ); } 866 859 | RETURN comma_expression_opt ';' 867 { $$ = new StatementNode( StatementNode::Return, $2, 0 ); } 868 | THROW assignment_expression_opt ';' 869 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); } 870 // | THROW ';' 871 // { $$ = new StatementNode( StatementNode::Throw ); } 872 | THROWRESUME assignment_expression_opt ';' 873 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); } 874 | THROWRESUME assignment_expression_opt AT assignment_expression ';' 875 { $$ = new StatementNode( StatementNode::Throw, $2, 0 ); } 876 // | THROWRESUME ';' 877 // { $$ = new StatementNode( StatementNode::Throw ); } 860 { $$ = new StatementNode( build_return( $2 ) ); } 861 | THROW assignment_expression_opt ';' // handles rethrow 862 { $$ = new StatementNode( build_throw( $2 ) ); } 863 | THROWRESUME assignment_expression_opt ';' // handles reresume 864 { $$ = new StatementNode( build_throw( $2 ) ); } 865 | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume 866 { $$ = new StatementNode( build_throw( $2 ) ); } 878 867 ; 879 868 880 869 exception_statement: 881 870 TRY compound_statement handler_list 882 { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }871 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 883 872 | TRY compound_statement finally_clause 884 { $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); }873 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 885 874 | TRY compound_statement handler_list finally_clause 886 { 887 $3->set_link( $4 ); 888 $$ = new StatementNode( StatementNode::Try, 0,(StatementNode *)(mkList((*$2,*$3 )))); 889 } 875 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } 890 876 ; 891 877 892 878 handler_list: 893 // There must be at least one catch clause894 879 handler_clause 895 880 // ISO/IEC 9899:1999 Section 15.3(6 ) If present, a "..." handler shall be the last handler for its try block. 896 881 | CATCH '(' ELLIPSIS ')' compound_statement 897 { $$ = StatementNode::newCatchStmt( 0, $5, true); }882 { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 898 883 | handler_clause CATCH '(' ELLIPSIS ')' compound_statement 899 { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true) ); }884 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 900 885 | CATCHRESUME '(' ELLIPSIS ')' compound_statement 901 { $$ = StatementNode::newCatchStmt( 0, $5, true); }886 { $$ = new StatementNode( build_catch( 0, $5, true ) ); } 902 887 | handler_clause CATCHRESUME '(' ELLIPSIS ')' compound_statement 903 { $$ = $1->set_link( StatementNode::newCatchStmt( 0, $6, true) ); }888 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( 0, $6, true ) ) ); } 904 889 ; 905 890 906 891 handler_clause: 907 892 CATCH '(' push push exception_declaration pop ')' compound_statement pop 908 { $$ = StatementNode::newCatchStmt( $5, $8); }893 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 909 894 | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop 910 { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9) ); }895 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 911 896 | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 912 { $$ = StatementNode::newCatchStmt( $5, $8); }897 { $$ = new StatementNode( build_catch( $5, $8 ) ); } 913 898 | handler_clause CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop 914 { $$ = $1->set_link( StatementNode::newCatchStmt( $6, $9) ); }899 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); } 915 900 ; 916 901 … … 918 903 FINALLY compound_statement 919 904 { 920 $$ = new StatementNode( StatementNode::Finally, 0, $2 ); 921 std::cout << "Just created a finally node" << std::endl; 905 $$ = new StatementNode( build_finally( $2 ) ); 922 906 } 923 907 ; … … 947 931 asm_statement: 948 932 ASM asm_volatile_opt '(' string_literal_list ')' ';' 949 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, 0); }933 { $$ = new StatementNode( build_asmstmt( $2, $4, 0 ) ); } 950 934 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ')' ';' // remaining GCC 951 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6); }935 { $$ = new StatementNode( build_asmstmt( $2, $4, $6 ) ); } 952 936 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ')' ';' 953 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8); }937 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8 ) ); } 954 938 | ASM asm_volatile_opt '(' string_literal_list ':' asm_operands_opt ':' asm_operands_opt ':' asm_clobbers_list_opt ')' ';' 955 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $4, $6, $8, $10); }939 { $$ = new StatementNode( build_asmstmt( $2, $4, $6, $8, $10 ) ); } 956 940 | ASM asm_volatile_opt GOTO '(' string_literal_list ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 957 { $$ = new AsmStmtNode( StatementNode::Asm, $2, $5, 0, $8, $10, $12); }941 { $$ = new StatementNode( build_asmstmt( $2, $5, 0, $8, $10, $12 ) ); } 958 942 ; 959 943 … … 974 958 asm_operand 975 959 | asm_operands_list ',' asm_operand 976 { $$ = (ExpressionNode *)$1->set_l ink( $3 ); }960 { $$ = (ExpressionNode *)$1->set_last( $3 ); } 977 961 ; 978 962 979 963 asm_operand: // GCC 980 964 string_literal_list '(' constant_expression ')' 981 { $$ = new AsmExprNode( 0, $1, $3); }965 { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); } 982 966 | '[' constant_expression ']' string_literal_list '(' constant_expression ')' 983 { $$ = new AsmExprNode( $2, $4, $6); }967 { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); } 984 968 ; 985 969 … … 988 972 { $$ = 0; } // use default argument 989 973 | string_literal_list 990 { $$ = $1; }974 { $$ = new ExpressionNode( $1 ); } 991 975 | asm_clobbers_list_opt ',' string_literal_list 992 { $$ = ( ConstantNode *)$1->set_link( $3); }976 { $$ = (ExpressionNode *)$1->set_last( new ExpressionNode( $3 ) ); } 993 977 ; 994 978 995 979 label_list: 996 980 no_attr_identifier 997 { $$ = new LabelNode(); $$-> append_label( $1); }981 { $$ = new LabelNode(); $$->labels.push_back( assign_strptr($1) ); } 998 982 | label_list ',' no_attr_identifier 999 { $$ = $1; $1-> append_label( $3); }983 { $$ = $1; $1->labels.push_back( assign_strptr($3) ); } 1000 984 ; 1001 985 … … 1340 1324 1341 1325 storage_class: 1342 storage_class_name1343 ;1344 1345 storage_class_name:1346 1326 EXTERN 1347 1327 { $$ = DeclarationNode::newStorageClass( DeclarationNode::Extern ); } … … 1513 1493 | EXTENSION field_declaring_list ';' // GCC 1514 1494 { // mark all fields in list 1515 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )1495 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) 1516 1496 iter->set_extension( true ); 1517 1497 $$ = $2; … … 1759 1739 | initializer 1760 1740 | designation initializer { $$ = $2->set_designators( $1 ); } 1761 | initializer_list ',' initializer { $$ = (InitializerNode *)( $1->set_l ink( $3 ) ); }1741 | initializer_list ',' initializer { $$ = (InitializerNode *)( $1->set_last( $3 ) ); } 1762 1742 | initializer_list ',' designation initializer 1763 { $$ = (InitializerNode *)( $1->set_l ink( $4->set_designators( $3 ) ) ); }1743 { $$ = (InitializerNode *)( $1->set_last( $4->set_designators( $3 ) ) ); } 1764 1744 ; 1765 1745 … … 1777 1757 designator_list ':' // C99, CFA uses ":" instead of "=" 1778 1758 | no_attr_identifier_or_type_name ':' // GCC, field name 1779 { $$ = new VarRefNode( $1); }1759 { $$ = new ExpressionNode( build_varref( $1 ) ); } 1780 1760 ; 1781 1761 … … 1783 1763 designator 1784 1764 | designator_list designator 1785 { $$ = (ExpressionNode *)( $1->set_l ink( $2 )); }1786 //| designator_list designator { $$ = new CompositeExprNode( $1, $2 ); }1765 { $$ = (ExpressionNode *)( $1->set_last( $2 ) ); } 1766 //| designator_list designator { $$ = new ExpressionNode( $1, $2 ); } 1787 1767 ; 1788 1768 1789 1769 designator: 1790 // lexer ambiguity: designator ".0" is floating-point constant or designator for name 0 only ".0" and ".1" 1791 // allowed => semantic check 1792 FLOATINGconstant 1793 { $$ = new DesignatorNode( new VarRefNode( $1 ) ); } 1794 | '.' no_attr_identifier_or_type_name // C99, field name 1795 { $$ = new DesignatorNode( new VarRefNode( $2 ) ); } 1770 '.' no_attr_identifier_or_type_name // C99, field name 1771 { $$ = new ExpressionNode( build_varref( $2 ) ); } 1796 1772 | '[' push assignment_expression pop ']' // C99, single array element 1797 1773 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 1798 { $$ = new DesignatorNode( $3, true ); }1774 { $$ = $3; } 1799 1775 | '[' push subrange pop ']' // CFA, multiple array elements 1800 { $$ = new DesignatorNode( $3, true ); }1776 { $$ = $3; } 1801 1777 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 1802 { $$ = new DesignatorNode( new CompositeExprNode( build_range( $3, $5 ) ), true); }1778 { $$ = new ExpressionNode( build_range( $3, $5 ) ); } 1803 1779 | '.' '[' push field_list pop ']' // CFA, tuple field selector 1804 { $$ = new DesignatorNode( $4 ); }1780 { $$ = $4; } 1805 1781 ; 1806 1782 … … 1890 1866 type_name_list: // CFA 1891 1867 type_name 1892 { $$ = new TypeValueNode( $1); }1868 { $$ = new ExpressionNode( build_typevalue( $1 ) ); } 1893 1869 | assignment_expression 1894 1870 | type_name_list ',' type_name 1895 { $$ = (ExpressionNode *)( $1->set_l ink( new TypeValueNode( $3 ))); }1871 { $$ = (ExpressionNode *)( $1->set_last( new ExpressionNode( build_typevalue( $3 ) ) ) ); } 1896 1872 | type_name_list ',' assignment_expression 1897 { $$ = (ExpressionNode *)( $1->set_l ink( $3 )); }1873 { $$ = (ExpressionNode *)( $1->set_last( $3 )); } 1898 1874 ; 1899 1875 … … 1994 1970 {} // empty input file 1995 1971 | external_definition_list 1996 { 1997 if ( theTree ) { 1998 theTree->appendList( $1 ); 1999 } else { 2000 theTree = $1; 2001 } 2002 } 1972 { parseTree = parseTree != nullptr ? parseTree->appendList( $1 ) : $1; } 2003 1973 ; 2004 1974 … … 2006 1976 external_definition 2007 1977 | external_definition_list push external_definition 2008 { $$ = ( $1 != NULL )? $1->appendList( $3 ) : $3; }1978 { $$ = $1 != nullptr ? $1->appendList( $3 ) : $3; } 2009 1979 ; 2010 1980 … … 2022 1992 | EXTERN STRINGliteral 2023 1993 { 2024 linkageStack.push( linkage ); 2025 linkage = LinkageSpec::fromString( *$2);1994 linkageStack.push( linkage ); // handle nested extern "C"/"Cforall" 1995 linkage = LinkageSpec::fromString( assign_strptr($2) ); 2026 1996 } 2027 1997 '{' external_definition_list_opt '}' // C++-style linkage specifier … … 2033 2003 | EXTENSION external_definition 2034 2004 { // mark all fields in list 2035 for ( DeclarationNode *iter = $2; iter != NULL; iter = (DeclarationNode *)iter->get_link() )2005 for ( DeclarationNode *iter = $2; iter != nullptr; iter = (DeclarationNode *)iter->get_next() ) 2036 2006 iter->set_extension( true ); 2037 2007 $$ = $2; … … 2129 2099 subrange: 2130 2100 constant_expression '~' constant_expression // CFA, integer subrange 2131 { $$ = new CompositeExprNode( build_range( $1, $3 ) ); }2101 { $$ = new ExpressionNode( build_range( $1, $3 ) ); } 2132 2102 ; 2133 2103 … … 2168 2138 any_word: // GCC 2169 2139 identifier_or_type_name {} 2170 | storage_class _name{}2140 | storage_class {} 2171 2141 | basic_type_name {} 2172 2142 | type_qualifier {} … … 2868 2838 // ----end of grammar---- 2869 2839 2840 extern char *yytext; 2841 2870 2842 void yyerror( const char * ) { 2871 2843 std::cout << "Error ";
Note:
See TracChangeset
for help on using the changeset viewer.