Changes in src/Parser/parser.yy [4e06c1e:8e9cbb2]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r4e06c1e r8e9cbb2 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Jul 12 17:26:32201613 // Update Count : 165 912 // Last Modified On : Thu Jun 30 21:15:54 2016 13 // Update Count : 1657 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 { 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 } 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. 722 718 | CHOOSE '(' comma_expression ')' case_clause // CFA 723 { $$ = new StatementNode( StatementNode:: Switch, $3, $5 ); }719 { $$ = new StatementNode( StatementNode::Choose, $3, $5 ); } 724 720 | CHOOSE '(' comma_expression ')' '{' push declaration_list_opt choose_clause_list_opt '}' // CFA 725 { 726 StatementNode *sw = new StatementNode( StatementNode::Switch, $3, $8 ); 727 $$ = $7 != 0 ? new CompoundStmtNode( (StatementNode *)((new StatementNode( $7 ))->set_link( sw )) ) : sw; 728 } 721 { $$ = new StatementNode( StatementNode::Choose, $3, $8 ); } 729 722 ; 730 723 … … 757 750 758 751 case_clause: // CFA 759 case_label_list statement { $$ = $1->append_last_case( new CompoundStmtNode( $2 )); }752 case_label_list statement { $$ = $1->append_last_case( $2 ); } 760 753 ; 761 754 … … 768 761 switch_clause_list: // CFA 769 762 case_label_list statement_list 770 { $$ = $1->append_last_case( new CompoundStmtNode( $2 )); }763 { $$ = $1->append_last_case( $2 ); } 771 764 | switch_clause_list case_label_list statement_list 772 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( $3 ) ) )); }765 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); } 773 766 ; 774 767 … … 783 776 { $$ = $1->append_last_case( $2 ); } 784 777 | case_label_list statement_list fall_through_opt 785 { $$ = $1->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$2, *$3 ) ) )); }778 { $$ = $1->append_last_case((StatementNode *)mkList((*$2,*$3 ))); } 786 779 | choose_clause_list case_label_list fall_through 787 780 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( $3 ))); } 788 781 | choose_clause_list case_label_list statement_list fall_through_opt 789 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case( new CompoundStmtNode( (StatementNode *)mkList( (*$3, *$4 ) ) ) ) )); }782 { $$ = (StatementNode *)( $1->set_link( $2->append_last_case((StatementNode *)mkList((*$3,*$4 ))))); } 790 783 ; 791 784 792 785 fall_through_opt: // CFA 793 786 // empty 794 { $$ = new StatementNode( StatementNode::Break ); } // insert implicit break787 { $$ = 0; } 795 788 | fall_through 796 789 ; 797 790 798 791 fall_through: // CFA 799 FALLTHRU 800 { $$ = 0; } 801 | FALLTHRU ';' 802 { $$ = 0; } 792 FALLTHRU { $$ = new StatementNode( StatementNode::Fallthru ); } 793 | FALLTHRU ';' { $$ = new StatementNode( StatementNode::Fallthru ); } 803 794 ; 804 795 … … 823 814 { $$ = new StatementNode( StatementNode::Goto, $2 ); } 824 815 | GOTO '*' comma_expression ';' // GCC, computed goto 825 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3 );816 // The syntax for the GCC computed goto violates normal expression precedence, e.g., goto *i+3; => goto *(i+3 ); 826 817 // whereas normal operator precedence yields goto (*i)+3; 827 818 { $$ = new StatementNode( StatementNode::Goto, $3 ); } … … 829 820 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 830 821 { $$ = new StatementNode( StatementNode::Continue ); } 831 | CONTINUE IDENTIFIER ';' // CFA, multi-level continue822 | CONTINUE IDENTIFIER ';' // CFA, multi-level continue 832 823 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 833 824 // the target of the transfer appears only at the start of an iteration statement. … … 836 827 // A semantic check is required to ensure this statement appears only in the body of an iteration statement. 837 828 { $$ = new StatementNode( StatementNode::Break ); } 838 | BREAK IDENTIFIER ';' // CFA, multi-level exit829 | BREAK IDENTIFIER ';' // CFA, multi-level exit 839 830 // A semantic check is required to ensure this statement appears only in the body of an iteration statement, and 840 831 // the target of the transfer appears only at the start of an iteration statement. … … 960 951 ; 961 952 962 asm_clobbers_list_opt: // GCC953 asm_clobbers_list_opt: // GCC 963 954 // empty 964 955 { $$ = 0; } // use default argument … … 1461 1452 { typedefTable.makeTypedef( *$2 ); } 1462 1453 '{' field_declaration_list '}' 1463 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5 ); }1454 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5); } 1464 1455 | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1465 1456 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6 ); } … … 1849 1840 { $$ = 0; } 1850 1841 | assertion_list_opt assertion 1851 { $$ = $1 != 0 ? $1->appendList( $2 ) : $2; }1842 { $$ = $1 == 0 ? $2 : $1->appendList( $2 ); } 1852 1843 ; 1853 1844
Note:
See TracChangeset
for help on using the changeset viewer.