Changes in src/Parser/parser.yy [4cc585b:936e9f4]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r4cc585b r936e9f4 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 20 09:21:54 201713 // Update Count : 2 57312 // Last Modified On : Wed Aug 16 18:09:14 2017 13 // Update Count : 2485 14 14 // 15 15 … … 131 131 %token ATTRIBUTE EXTENSION // GCC 132 132 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 133 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA133 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA 134 134 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 135 135 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 796 796 797 797 selection_statement: 798 IF '(' pushif_control_expression ')' statement %prec THEN798 IF '(' if_control_expression ')' statement %prec THEN 799 799 // explicitly deal with the shift/reduce conflict on if/else 800 { $$ = new StatementNode( build_if( $ 4, $6, nullptr ) ); }801 | IF '(' pushif_control_expression ')' statement ELSE statement802 { $$ = new StatementNode( build_if( $ 4, $6, $8) ); }803 | SWITCH '(' comma_expression ')' case_clause 800 { $$ = new StatementNode( build_if( $3, $5, nullptr ) ); } 801 | IF '(' if_control_expression ')' statement ELSE statement 802 { $$ = new StatementNode( build_if( $3, $5, $7 ) ); } 803 | SWITCH '(' comma_expression ')' case_clause // CFA 804 804 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 805 805 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA … … 823 823 824 824 if_control_expression: 825 comma_expression pop825 comma_expression 826 826 { $$ = new IfCtl( nullptr, $1 ); } 827 | c_declaration pop // no semi-colon827 | c_declaration // no semi-coln 828 828 { $$ = new IfCtl( $1, nullptr ); } 829 | cfa_declaration pop// no semi-colon829 | cfa_declaration // no semi-colon 830 830 { $$ = new IfCtl( $1, nullptr ); } 831 | declaration comma_expression // semi-colon separated831 | declaration comma_expression 832 832 { $$ = new IfCtl( $1, $2 ); } 833 833 ; … … 1104 1104 1105 1105 KR_declaration_list_opt: // used to declare parameter types in K&R style functions 1106 // empty1106 pop 1107 1107 { $$ = nullptr; } 1108 1108 | KR_declaration_list … … 1110 1110 1111 1111 KR_declaration_list: 1112 push c_declaration pop ';' 1113 { $$ = $2; } 1114 | KR_declaration_list push c_declaration pop ';' 1112 c_declaration ';' 1113 | KR_declaration_list push c_declaration ';' 1115 1114 { $$ = $1->appendList( $3 ); } 1116 1115 ; … … 1132 1131 1133 1132 declaration: // old & new style declarations 1134 c_declaration pop';'1135 | cfa_declaration pop ';'// CFA1133 c_declaration ';' 1134 | cfa_declaration ';' // CFA 1136 1135 ; 1137 1136 … … 1148 1147 1149 1148 cfa_declaration: // CFA 1150 cfa_variable_declaration 1151 | cfa_typedef_declaration 1152 | cfa_function_declaration 1153 | type_declaring_list 1154 | trait_specifier 1149 cfa_variable_declaration pop 1150 | cfa_typedef_declaration pop 1151 | cfa_function_declaration pop 1152 | type_declaring_list pop 1153 | trait_specifier pop 1155 1154 ; 1156 1155 … … 1352 1351 1353 1352 c_declaration: 1354 declaration_specifier declaring_list 1353 declaration_specifier declaring_list pop 1355 1354 { 1356 1355 $$ = distAttr( $1, $2 ); 1357 1356 } 1358 | typedef_declaration 1359 | typedef_expression // GCC, naming expression type1360 | sue_declaration_specifier 1357 | typedef_declaration pop 1358 | typedef_expression pop // GCC, naming expression type 1359 | sue_declaration_specifier pop 1361 1360 ; 1362 1361 … … 2231 2230 $$ = $1->addFunctionBody( $2 ); 2232 2231 } 2233 | KR_function_declarator KR_declaration_list_opt compound_statement2232 | KR_function_declarator push KR_declaration_list_opt compound_statement 2234 2233 { 2235 2234 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2236 2235 typedefTable.leaveScope(); 2237 $$ = $1->addOldDeclList( $ 2 )->addFunctionBody( $3);2236 $$ = $1->addOldDeclList( $3 )->addFunctionBody( $4 ); 2238 2237 } 2239 2238 ; … … 2279 2278 2280 2279 // Old-style K&R function definition, OBSOLESCENT (see 4) 2281 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement2280 | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2282 2281 { 2283 2282 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2284 2283 typedefTable.leaveScope(); 2285 $$ = $2->addOldDeclList( $ 3 )->addFunctionBody( $5)->addType( $1 );2286 } 2287 | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement2284 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 ); 2285 } 2286 | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2288 2287 { 2289 2288 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2290 2289 typedefTable.leaveScope(); 2291 $$ = $2->addOldDeclList( $ 3 )->addFunctionBody( $5)->addQualifiers( $1 );2290 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 ); 2292 2291 } 2293 2292 2294 2293 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4) 2295 | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement2294 | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2296 2295 { 2297 2296 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2298 2297 typedefTable.leaveScope(); 2299 $$ = $2->addOldDeclList( $ 3 )->addFunctionBody( $5)->addQualifiers( $1 );2300 } 2301 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement2298 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 ); 2299 } 2300 | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2302 2301 { 2303 2302 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2304 2303 typedefTable.leaveScope(); 2305 $$ = $3->addOldDeclList( $ 4 )->addFunctionBody( $6)->addQualifiers( $2 )->addQualifiers( $1 );2304 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 ); 2306 2305 } 2307 2306 ;
Note:
See TracChangeset
for help on using the changeset viewer.