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