Changeset 33218c6 for src/Parser/parser.yy
- Timestamp:
- Jul 26, 2017, 12:19:41 PM (8 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:
- b947fb2
- Parents:
- e0a653d (diff), ea91c42 (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
re0a653d r33218c6 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 : Tus Jul 11 13:39:00201713 // Update Count : 24 1611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 24 09:01:14 2017 13 // Update Count : 2463 14 14 // 15 15 … … 118 118 %token RESTRICT // C99 119 119 %token ATOMIC // C11 120 %token FORALL LVALUE MUTEX // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 120 %token FORALL LVALUE MUTEX VIRTUAL // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 122 %token BOOL COMPLEX IMAGINARY // C99 123 %token ZERO_T ONE_T // CFA 122 124 %token VALIST // GCC 123 %token BOOL COMPLEX IMAGINARY // C99124 125 %token TYPEOF LABEL // GCC 125 126 %token ENUM STRUCT UNION … … 129 130 %token ATTRIBUTE EXTENSION // GCC 130 131 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 131 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT // CFA132 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH // CFA 132 133 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 133 134 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 151 152 %token ELLIPSIS // ... 152 153 153 %token MULTassign DIVassign MODassign // *= /= %=/154 %token EXPassign MULTassign DIVassign MODassign // \= *= /= %= 154 155 %token PLUSassign MINUSassign // += -= 155 156 %token LSassign RSassign // <<= >>= … … 168 169 %type<op> ptrref_operator unary_operator assignment_operator 169 170 %type<en> primary_expression postfix_expression unary_expression 170 %type<en> cast_expression multiplicative_expression additive_expression shift_expression 171 %type<en> relational_expression equality_expression AND_expression exclusive_OR_expression 172 %type<en> inclusive_OR_expression logical_AND_expression logical_OR_expression conditional_expression 173 %type<en> constant_expression assignment_expression assignment_expression_opt 171 %type<en> cast_expression exponential_expression multiplicative_expression additive_expression 172 %type<en> shift_expression relational_expression equality_expression 173 %type<en> AND_expression exclusive_OR_expression inclusive_OR_expression 174 %type<en> logical_AND_expression logical_OR_expression 175 %type<en> conditional_expression constant_expression assignment_expression assignment_expression_opt 174 176 %type<en> comma_expression comma_expression_opt 175 %type<en> argument_expression_list argument_expression assignment_opt177 %type<en> argument_expression_list argument_expression default_initialize_opt 176 178 %type<fctl> for_control_expression 177 179 %type<en> subrange … … 184 186 // statements 185 187 %type<sn> labeled_statement compound_statement expression_statement selection_statement 186 %type<sn> iteration_statement jump_statement exception_statement asm_statement 188 %type<sn> iteration_statement jump_statement 189 %type<sn> with_statement exception_statement asm_statement 187 190 %type<sn> fall_through_opt fall_through 188 191 %type<sn> statement statement_list 189 192 %type<sn> block_item_list block_item 190 %type<sn> case_clause193 %type<sn> with_clause_opt 191 194 %type<en> case_value 192 %type<sn> case_ value_list case_label case_label_list195 %type<sn> case_clause case_value_list case_label case_label_list 193 196 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 194 197 %type<sn> /* handler_list */ handler_clause finally_clause … … 568 571 | '(' type_no_function ')' cast_expression 569 572 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 // VIRTUAL cannot be opt because of look ahead issues 574 | '(' VIRTUAL ')' cast_expression 575 { $$ = new ExpressionNode( build_cast( nullptr, $4 ) ); } 576 | '(' VIRTUAL type_no_function ')' cast_expression 577 { $$ = new ExpressionNode( build_cast( $3, $5 ) ); } 570 578 // | '(' type_no_function ')' tuple 571 579 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 572 580 ; 573 581 582 exponential_expression: 583 cast_expression 584 | exponential_expression '\\' cast_expression 585 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 586 ; 587 574 588 multiplicative_expression: 575 cast_expression576 | multiplicative_expression '*' cast_expression589 exponential_expression 590 | multiplicative_expression '*' exponential_expression 577 591 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 578 | multiplicative_expression '/' cast_expression592 | multiplicative_expression '/' exponential_expression 579 593 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 580 | multiplicative_expression '%' cast_expression594 | multiplicative_expression '%' exponential_expression 581 595 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 582 596 ; … … 677 691 '=' { $$ = OperKinds::Assign; } 678 692 | ATassign { $$ = OperKinds::AtAssn; } 693 | EXPassign { $$ = OperKinds::ExpAssn; } 679 694 | MULTassign { $$ = OperKinds::MulAssn; } 680 695 | DIVassign { $$ = OperKinds::DivAssn; } … … 729 744 | iteration_statement 730 745 | jump_statement 746 | with_statement 731 747 | exception_statement 732 748 | asm_statement … … 936 952 ; 937 953 954 with_statement: 955 WITH '(' tuple_expression_list ')' compound_statement 956 { $$ = (StatementNode *)0; } // FIX ME 957 ; 958 938 959 exception_statement: 939 960 TRY compound_statement handler_clause … … 965 986 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 966 987 967 | handler_key '(' push push exception_declaration pop ')' compound_statement pop 968 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $8 ) ); } 969 | handler_clause handler_key '(' push push exception_declaration pop ')' compound_statement pop 970 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $9 ) ) ); } 988 | handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 989 { $$ = new StatementNode( build_catch( $1, $5, nullptr, $9 ) ); } 990 | handler_clause handler_key '(' push push exception_declaration pop handler_predicate_opt ')' compound_statement pop 991 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $6, nullptr, $10 ) ) ); } 992 ; 993 994 handler_predicate_opt: 995 //empty 996 | ';' conditional_expression 971 997 ; 972 998 … … 1495 1521 | IMAGINARY // C99 1496 1522 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1497 | VALIST // GCC, __builtin_va_list1498 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1499 1523 | ZERO_T 1500 1524 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1501 1525 | ONE_T 1502 1526 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1527 | VALIST // GCC, __builtin_va_list 1528 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1503 1529 ; 1504 1530 … … 1660 1686 | aggregate_key attribute_list_opt typegen_name // CFA 1661 1687 { $$ = $3->addQualifiers( $2 ); } 1688 1689 // Temp, testing TreeStruct 1690 | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name 1691 { 1692 typedefTable.makeTypedef( *$4 ); // create typedef 1693 if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $ 1694 forall = false; // reset 1695 } 1696 '{' field_declaration_list '}' 1697 { 1698 $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct, 1699 $4, nullptr, nullptr, $7, true )->addQualifiers( $3 ); 1700 } 1701 | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name TYPEDEFname 1702 { 1703 typedefTable.makeTypedef( *$4 ); // create typedef 1704 if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $ 1705 forall = false; // reset 1706 } 1707 '{' field_declaration_list '}' 1708 { 1709 $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct, 1710 $4, $5, nullptr, $8, true )->addQualifiers( $3 ); 1711 } 1662 1712 ; 1663 1713 … … 1838 1888 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1839 1889 parameter_declaration 1840 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt1890 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt 1841 1891 { $$ = $1->addName( $2 ); } 1842 | cfa_abstract_tuple identifier_or_type_name assignment_opt1892 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1843 1893 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1844 1894 { $$ = $1->addName( $2 ); } 1845 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt1895 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt 1846 1896 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1847 1897 | cfa_function_specifier … … 1860 1910 parameter_declaration: 1861 1911 // No SUE declaration in parameter list. 1862 declaration_specifier_nobody identifier_parameter_declarator assignment_opt1912 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt 1863 1913 { 1864 1914 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1865 1915 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1866 1916 } 1867 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt1917 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt 1868 1918 { 1869 1919 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1873 1923 1874 1924 abstract_parameter_declaration: 1875 declaration_specifier_nobody assignment_opt1925 declaration_specifier_nobody default_initialize_opt 1876 1926 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1877 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt1927 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt 1878 1928 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1879 1929 ; … … 2212 2262 ; 2213 2263 2264 with_clause_opt: 2265 // empty 2266 { $$ = (StatementNode *)0; } // FIX ME 2267 | WITH '(' tuple_expression_list ')' 2268 { $$ = (StatementNode *)0; } // FIX ME 2269 ; 2270 2214 2271 function_definition: 2215 cfa_function_declaration compound_statement// CFA2272 cfa_function_declaration with_clause_opt compound_statement // CFA 2216 2273 { 2217 2274 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2218 2275 typedefTable.leaveScope(); 2219 $$ = $1->addFunctionBody( $ 2);2220 } 2221 | declaration_specifier function_declarator compound_statement2276 $$ = $1->addFunctionBody( $3 ); 2277 } 2278 | declaration_specifier function_declarator with_clause_opt compound_statement 2222 2279 { 2223 2280 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2224 2281 typedefTable.leaveScope(); 2225 $$ = $2->addFunctionBody( $ 3)->addType( $1 );2226 } 2227 | type_qualifier_list function_declarator compound_statement2282 $$ = $2->addFunctionBody( $4 )->addType( $1 ); 2283 } 2284 | type_qualifier_list function_declarator with_clause_opt compound_statement 2228 2285 { 2229 2286 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2230 2287 typedefTable.leaveScope(); 2231 $$ = $2->addFunctionBody( $ 3)->addQualifiers( $1 );2232 } 2233 | declaration_qualifier_list function_declarator compound_statement2288 $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 ); 2289 } 2290 | declaration_qualifier_list function_declarator with_clause_opt compound_statement 2234 2291 { 2235 2292 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2236 2293 typedefTable.leaveScope(); 2237 $$ = $2->addFunctionBody( $ 3)->addQualifiers( $1 );2238 } 2239 | declaration_qualifier_list type_qualifier_list function_declarator compound_statement2294 $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 ); 2295 } 2296 | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement 2240 2297 { 2241 2298 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2242 2299 typedefTable.leaveScope(); 2243 $$ = $3->addFunctionBody( $ 4)->addQualifiers( $2 )->addQualifiers( $1 );2300 $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 ); 2244 2301 } 2245 2302 2246 2303 // Old-style K&R function definition, OBSOLESCENT (see 4) 2247 | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement2304 | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2248 2305 { 2249 2306 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2250 2307 typedefTable.leaveScope(); 2251 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 5)->addType( $1 );2252 } 2253 | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement2308 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 ); 2309 } 2310 | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2254 2311 { 2255 2312 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2256 2313 typedefTable.leaveScope(); 2257 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 5)->addQualifiers( $1 );2314 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 ); 2258 2315 } 2259 2316 2260 2317 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4) 2261 | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement2318 | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2262 2319 { 2263 2320 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2264 2321 typedefTable.leaveScope(); 2265 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 5)->addQualifiers( $1 );2266 } 2267 | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement2322 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 ); 2323 } 2324 | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement 2268 2325 { 2269 2326 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2270 2327 typedefTable.leaveScope(); 2271 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $ 6)->addQualifiers( $2 )->addQualifiers( $1 );2328 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 ); 2272 2329 } 2273 2330 ; … … 3031 3088 ; 3032 3089 3033 assignment_opt:3090 default_initialize_opt: 3034 3091 // empty 3035 3092 { $$ = nullptr; }
Note:
See TracChangeset
for help on using the changeset viewer.