Changeset 8135d4c for src/Parser/parser.yy
- Timestamp:
- Aug 22, 2017, 7:31:52 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 9aaac6e9
- Parents:
- fc56cdbf (diff), b3d413b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rfc56cdbf r8135d4c 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Aug 4 13:33:00201713 // Update Count : 2 47511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 20 09:21:54 2017 13 // Update Count : 2573 14 14 // 15 15 … … 98 98 StatementNode * sn; 99 99 ConstantExpr * constant; 100 IfCtl * ifctl; 100 101 ForCtl * fctl; 101 102 LabelNode * label; … … 130 131 %token ATTRIBUTE EXTENSION // GCC 131 132 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 132 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH 133 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA 133 134 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 134 135 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 175 176 %type<en> comma_expression comma_expression_opt 176 177 %type<en> argument_expression_list argument_expression default_initialize_opt 178 %type<ifctl> if_control_expression 177 179 %type<fctl> for_control_expression 178 180 %type<en> subrange … … 794 796 795 797 selection_statement: 796 IF '(' comma_expression ')' statement %prec THEN798 IF '(' push if_control_expression ')' statement %prec THEN 797 799 // explicitly deal with the shift/reduce conflict on if/else 798 { $$ = new StatementNode( build_if( $ 3, $5, nullptr ) ); }799 | IF '(' comma_expression ')' statement ELSE statement800 { $$ = new StatementNode( build_if( $ 3, $5, $7) ); }801 | SWITCH '(' comma_expression ')' case_clause // CFA800 { $$ = new StatementNode( build_if( $4, $6, nullptr ) ); } 801 | IF '(' push if_control_expression ')' statement ELSE statement 802 { $$ = new StatementNode( build_if( $4, $6, $8 ) ); } 803 | SWITCH '(' comma_expression ')' case_clause 802 804 { $$ = new StatementNode( build_switch( $3, $5 ) ); } 803 805 | SWITCH '(' comma_expression ')' '{' push declaration_list_opt switch_clause_list_opt '}' // CFA … … 819 821 } 820 822 ; 823 824 if_control_expression: 825 comma_expression pop 826 { $$ = new IfCtl( nullptr, $1 ); } 827 | c_declaration pop // no semi-colon 828 { $$ = new IfCtl( $1, nullptr ); } 829 | cfa_declaration pop // no semi-colon 830 { $$ = new IfCtl( $1, nullptr ); } 831 | declaration comma_expression // semi-colon separated 832 { $$ = new IfCtl( $1, $2 ); } 833 ; 821 834 822 835 // CASE and DEFAULT clauses are only allowed in the SWITCH statement, precluding Duff's device. In addition, a case … … 1091 1104 1092 1105 KR_declaration_list_opt: // used to declare parameter types in K&R style functions 1093 pop1106 // empty 1094 1107 { $$ = nullptr; } 1095 1108 | KR_declaration_list … … 1097 1110 1098 1111 KR_declaration_list: 1099 c_declaration 1100 | KR_declaration_list push c_declaration 1112 push c_declaration pop ';' 1113 { $$ = $2; } 1114 | KR_declaration_list push c_declaration pop ';' 1101 1115 { $$ = $1->appendList( $3 ); } 1102 1116 ; … … 1117 1131 ; 1118 1132 1119 declaration: // CFA, new & oldstyle declarations1120 c fa_declaration1121 | c _declaration1133 declaration: // old & new style declarations 1134 c_declaration pop ';' 1135 | cfa_declaration pop ';' // CFA 1122 1136 ; 1123 1137 … … 1134 1148 1135 1149 cfa_declaration: // CFA 1136 cfa_variable_declaration pop ';'1137 | cfa_typedef_declaration pop ';'1138 | cfa_function_declaration pop ';'1139 | type_declaring_list pop ';'1140 | trait_specifier pop ';'1150 cfa_variable_declaration 1151 | cfa_typedef_declaration 1152 | cfa_function_declaration 1153 | type_declaring_list 1154 | trait_specifier 1141 1155 ; 1142 1156 … … 1338 1352 1339 1353 c_declaration: 1340 declaration_specifier declaring_list pop ';'1354 declaration_specifier declaring_list 1341 1355 { 1342 1356 $$ = distAttr( $1, $2 ); 1343 1357 } 1344 | typedef_declaration pop ';'1345 | typedef_expression pop ';'// GCC, naming expression type1346 | sue_declaration_specifier pop ';'1358 | typedef_declaration 1359 | typedef_expression // GCC, naming expression type 1360 | sue_declaration_specifier 1347 1361 ; 1348 1362 … … 2215 2229 $$ = $1->addFunctionBody( $2 ); 2216 2230 } 2217 | KR_function_declarator pushKR_declaration_list_opt compound_statement2231 | KR_function_declarator KR_declaration_list_opt compound_statement 2218 2232 { 2219 2233 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2220 2234 typedefTable.leaveScope(); 2221 $$ = $1->addOldDeclList( $ 3 )->addFunctionBody( $4);2235 $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); 2222 2236 } 2223 2237 ; … … 2263 2277 2264 2278 // Old-style K&R function definition, OBSOLESCENT (see 4) 2265 | declaration_specifier KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2279 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2266 2280 { 2267 2281 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2268 2282 typedefTable.leaveScope(); 2269 $$ = $2->addOldDeclList( $ 4 )->addFunctionBody( $6)->addType( $1 );2270 } 2271 | type_qualifier_list KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2283 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addType( $1 ); 2284 } 2285 | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2272 2286 { 2273 2287 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2274 2288 typedefTable.leaveScope(); 2275 $$ = $2->addOldDeclList( $ 4 )->addFunctionBody( $6)->addQualifiers( $1 );2289 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 ); 2276 2290 } 2277 2291 2278 2292 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4) 2279 | declaration_qualifier_list KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2293 | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2280 2294 { 2281 2295 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2282 2296 typedefTable.leaveScope(); 2283 $$ = $2->addOldDeclList( $ 4 )->addFunctionBody( $6)->addQualifiers( $1 );2284 } 2285 | declaration_qualifier_list type_qualifier_list KR_function_declarator pushKR_declaration_list_opt with_clause_opt compound_statement2297 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5 )->addQualifiers( $1 ); 2298 } 2299 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2286 2300 { 2287 2301 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2288 2302 typedefTable.leaveScope(); 2289 $$ = $3->addOldDeclList( $ 5 )->addFunctionBody( $7)->addQualifiers( $2 )->addQualifiers( $1 );2303 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 ); 2290 2304 } 2291 2305 ;
Note: See TracChangeset
for help on using the changeset viewer.