Changeset 4e06c1e for src/Parser/parser.yy
- Timestamp:
- Jul 12, 2016, 6:34:10 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:
- e4d3ceb
- Parents:
- 6e4b913
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r6e4b913 r4e06c1e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Jun 30 21:15:54201613 // Update Count : 165 712 // Last Modified On : Tue Jul 12 17:26:32 2016 13 // Update Count : 1659 14 14 // 15 15 … … 712 712 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); } 713 713 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA 714 { $$ = new StatementNode( StatementNode::Switch, $3, $8 ); /* xxx */ } 715 // The semantics of the declaration list is changed to include any associated initialization, which is performed 716 // *before* the transfer to the appropriate case clause. Statements after the initial declaration list can 717 // never be executed, and therefore, are removed from the grammar even though C allows it. 714 { 715 StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 ); 716 // The semantics of the declaration list is changed to include associated initialization, which is performed 717 // *before* the transfer to the appropriate case clause by hoisting the declarations into a compound 718 // statement around the switch. Statements after the initial declaration list can never be executed, and 719 // therefore, are removed from the grammar even though C allows it. Change also applies to choose statement. 720 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 721 } 718 722 | CHOOSE '(' comma_expression ')' case_clause // CFA 719 { $$ = new StatementNode( StatementNode:: Choose, $3, $5 ); }723 { $$ = new StatementNode( StatementNode::Switch, $3, $5 ); } 720 724 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA 721 { $$ = new StatementNode( StatementNode::Choose, $3, $8 ); } 725 { 726 StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 ); 727 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 728 } 722 729 ; 723 730 … … 750 757 751 758 case_clause: // CFA 752 case_label_list statement { $$ = $1->append_last_case( $2); }759 case_label_list statement { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); } 753 760 ; 754 761 … … 761 768 switch_clause_list: // CFA 762 769 case_label_list statement_list 763 { $$ = $1->append_last_case( $2); }770 { $$ = $1->append_last_case( new CompoundStmtNode( $2 ) ); } 764 771 | switch_clause_list case_label_list statement_list 765 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); }772 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( $3 ) ) ) ); } 766 773 ; 767 774 … … 776 783 { $$ = $1->append_last_case( $2 ); } 777 784 | case_label_list statement_list fall_through_opt 778 { $$ = $1->append_last_case( (StatementNode *)mkList((*$2,*$3 ))); }785 { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) ) ); } 779 786 | choose_clause_list case_label_list fall_through 780 787 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); } 781 788 | choose_clause_list case_label_list statement_list fall_through_opt 782 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( (StatementNode *)mkList((*$3,*$4 ))))); }789 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) ) ); } 783 790 ; 784 791 785 792 fall_through_opt: // CFA 786 793 // empty 794 { $$ = new StatementNode( StatementNode::Break ); } // insert implicit break 795 | fall_through 796 ; 797 798 fall_through: // CFA 799 FALLTHRU 787 800 { $$ = 0; } 788 | fall_through 789 ; 790 791 fall_through: // CFA 792 FALLTHRU { $$ = new StatementNode( StatementNode::Fallthru ); } 793 | FALLTHRU ';' { $$ = new StatementNode( StatementNode::Fallthru ); } 801 | FALLTHRU ';' 802 { $$ = 0; } 794 803 ; 795 804 … … 814 823 { $$ = new StatementNode( StatementNode::Goto, $2 ); } 815 824 | GOTO '*' comma_expression ';' // GCC, computed goto 816 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3 825 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3); 817 826 // whereas normal operator precedence yields goto (*i)+3; 818 827 { $$ = new StatementNode( StatementNode::Goto, $3 ); } … … 820 829 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 821 830 { $$ = new StatementNode( StatementNode::Continue ); } 822 | CONTINUE IDENTIFIER ';' // CFA, multi-level continue831 | CONTINUE IDENTIFIER ';' // CFA, multi-level continue 823 832 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 824 833 // the target of the transfer appears only at the start of an iteration statement. … … 827 836 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 828 837 { $$ = new StatementNode( StatementNode::Break ); } 829 | BREAK IDENTIFIER ';' // CFA, multi-level exit838 | BREAK IDENTIFIER ';' // CFA, multi-level exit 830 839 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 831 840 // the target of the transfer appears only at the start of an iteration statement. … … 951 960 ; 952 961 953 asm_clobbers_list_opt: 962 asm_clobbers_list_opt: // GCC 954 963 // empty 955 964 { $$ = 0; } // use default argument … … 1452 1461 { typedefTable.makeTypedef( *$2 ); } 1453 1462 '{' field_declaration_list '}' 1454 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5 ); }1463 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5 ); } 1455 1464 | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1456 1465 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); } … … 1840 1849 { $$ = 0; } 1841 1850 | assertion_list_opt assertion 1842 { $$ = $1 == 0 ? $2 : $1->appendList( $2 ); }1851 { $$ = $1 != 0 ? $1->appendList( $2 ) : $2; } 1843 1852 ; 1844 1853
Note: See TracChangeset
for help on using the changeset viewer.