Changes in src/Parser/parser.yy [72457b6:0fc9756b]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r72457b6 r0fc9756b 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 24 09:01:14201713 // Update Count : 24 6311 // Last Modified By : Andrew Beach 12 // Last Modified On : Tus Jul 11 13:39:00 2017 13 // Update Count : 2416 14 14 // 15 15 … … 118 118 %token RESTRICT // C99 119 119 %token ATOMIC // C11 120 %token FORALL LVALUE MUTEX VIRTUAL // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 120 %token FORALL LVALUE MUTEX // CFA 121 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED ZERO_T ONE_T 122 %token VALIST // GCC 122 123 %token BOOL COMPLEX IMAGINARY // C99 123 %token ZERO_T ONE_T // CFA124 %token VALIST // GCC125 124 %token TYPEOF LABEL // GCC 126 125 %token ENUM STRUCT UNION … … 130 129 %token ATTRIBUTE EXTENSION // GCC 131 130 %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// CFA131 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT // CFA 133 132 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) 134 133 %token ALIGNAS ALIGNOF GENERIC STATICASSERT // C11 … … 152 151 %token ELLIPSIS // ... 153 152 154 %token EXPassign MULTassign DIVassign MODassign // \= *= /= %=153 %token MULTassign DIVassign MODassign // *= /= %=/ 155 154 %token PLUSassign MINUSassign // += -= 156 155 %token LSassign RSassign // <<= >>= … … 169 168 %type<op> ptrref_operator unary_operator assignment_operator 170 169 %type<en> primary_expression postfix_expression unary_expression 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 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 176 174 %type<en> comma_expression comma_expression_opt 177 %type<en> argument_expression_list argument_expression default_initialize_opt175 %type<en> argument_expression_list argument_expression assignment_opt 178 176 %type<fctl> for_control_expression 179 177 %type<en> subrange … … 186 184 // statements 187 185 %type<sn> labeled_statement compound_statement expression_statement selection_statement 188 %type<sn> iteration_statement jump_statement 189 %type<sn> with_statement exception_statement asm_statement 186 %type<sn> iteration_statement jump_statement exception_statement asm_statement 190 187 %type<sn> fall_through_opt fall_through 191 188 %type<sn> statement statement_list 192 189 %type<sn> block_item_list block_item 193 %type<sn> with_clause_opt190 %type<sn> case_clause 194 191 %type<en> case_value 195 %type<sn> case_ clause case_value_list case_label case_label_list192 %type<sn> case_value_list case_label case_label_list 196 193 %type<sn> switch_clause_list_opt switch_clause_list choose_clause_list_opt choose_clause_list 197 194 %type<sn> /* handler_list */ handler_clause finally_clause … … 571 568 | '(' type_no_function ')' cast_expression 572 569 { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 573 // VIRTUAL cannot be opt because of look ahead issues574 | '(' VIRTUAL ')' cast_expression575 { $$ = new ExpressionNode( build_cast( nullptr, $4 ) ); }576 | '(' VIRTUAL type_no_function ')' cast_expression577 { $$ = new ExpressionNode( build_cast( $3, $5 ) ); }578 570 // | '(' type_no_function ')' tuple 579 571 // { $$ = new ExpressionNode( build_cast( $2, $4 ) ); } 580 572 ; 581 573 582 exponential_expression:574 multiplicative_expression: 583 575 cast_expression 584 | exponential_expression '\\' cast_expression 585 { $$ = new ExpressionNode( build_binary_val( OperKinds::Exp, $1, $3 ) ); } 586 ; 587 588 multiplicative_expression: 589 exponential_expression 590 | multiplicative_expression '*' exponential_expression 576 | multiplicative_expression '*' cast_expression 591 577 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mul, $1, $3 ) ); } 592 | multiplicative_expression '/' exponential_expression578 | multiplicative_expression '/' cast_expression 593 579 { $$ = new ExpressionNode( build_binary_val( OperKinds::Div, $1, $3 ) ); } 594 | multiplicative_expression '%' exponential_expression580 | multiplicative_expression '%' cast_expression 595 581 { $$ = new ExpressionNode( build_binary_val( OperKinds::Mod, $1, $3 ) ); } 596 582 ; … … 691 677 '=' { $$ = OperKinds::Assign; } 692 678 | ATassign { $$ = OperKinds::AtAssn; } 693 | EXPassign { $$ = OperKinds::ExpAssn; }694 679 | MULTassign { $$ = OperKinds::MulAssn; } 695 680 | DIVassign { $$ = OperKinds::DivAssn; } … … 744 729 | iteration_statement 745 730 | jump_statement 746 | with_statement747 731 | exception_statement 748 732 | asm_statement … … 952 936 ; 953 937 954 with_statement:955 WITH '(' tuple_expression_list ')' compound_statement956 { $$ = (StatementNode *)0; } // FIX ME957 ;958 959 938 exception_statement: 960 939 TRY compound_statement handler_clause … … 986 965 { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, nullptr, new ExpressionNode( build_constantInteger( *$6 ) ), $9 ) ) ); } 987 966 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 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 ) ) ); } 997 971 ; 998 972 … … 1521 1495 | IMAGINARY // C99 1522 1496 { $$ = DeclarationNode::newComplexType( DeclarationNode::Imaginary ); } 1497 | VALIST // GCC, __builtin_va_list 1498 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1523 1499 | ZERO_T 1524 1500 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } 1525 1501 | ONE_T 1526 1502 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::One ); } 1527 | VALIST // GCC, __builtin_va_list1528 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }1529 1503 ; 1530 1504 … … 1686 1660 | aggregate_key attribute_list_opt typegen_name // CFA 1687 1661 { $$ = $3->addQualifiers( $2 ); } 1688 1689 // Temp, testing TreeStruct1690 | STRUCT TRY attribute_list_opt no_attr_identifier_or_type_name1691 {1692 typedefTable.makeTypedef( *$4 ); // create typedef1693 if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $1694 forall = false; // reset1695 }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 TYPEDEFname1702 {1703 typedefTable.makeTypedef( *$4 ); // create typedef1704 if ( forall ) typedefTable.changeKind( *$4, TypedefTable::TG ); // $1705 forall = false; // reset1706 }1707 '{' field_declaration_list '}'1708 {1709 $$ = DeclarationNode::newTreeStruct( DeclarationNode::Struct,1710 $4, $5, nullptr, $8, true )->addQualifiers( $3 );1711 }1712 1662 ; 1713 1663 … … 1888 1838 cfa_parameter_declaration: // CFA, new & old style parameter declaration 1889 1839 parameter_declaration 1890 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name default_initialize_opt1840 | cfa_identifier_parameter_declarator_no_tuple identifier_or_type_name assignment_opt 1891 1841 { $$ = $1->addName( $2 ); } 1892 | cfa_abstract_tuple identifier_or_type_name default_initialize_opt1842 | cfa_abstract_tuple identifier_or_type_name assignment_opt 1893 1843 // To obtain LR(1), these rules must be duplicated here (see cfa_abstract_declarator). 1894 1844 { $$ = $1->addName( $2 ); } 1895 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name default_initialize_opt1845 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name assignment_opt 1896 1846 { $$ = $2->addName( $3 )->addQualifiers( $1 ); } 1897 1847 | cfa_function_specifier … … 1910 1860 parameter_declaration: 1911 1861 // No SUE declaration in parameter list. 1912 declaration_specifier_nobody identifier_parameter_declarator default_initialize_opt1862 declaration_specifier_nobody identifier_parameter_declarator assignment_opt 1913 1863 { 1914 1864 typedefTable.addToEnclosingScope( TypedefTable::ID ); 1915 1865 $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); 1916 1866 } 1917 | declaration_specifier_nobody type_parameter_redeclarator default_initialize_opt1867 | declaration_specifier_nobody type_parameter_redeclarator assignment_opt 1918 1868 { 1919 1869 typedefTable.addToEnclosingScope( TypedefTable::ID ); … … 1923 1873 1924 1874 abstract_parameter_declaration: 1925 declaration_specifier_nobody default_initialize_opt1875 declaration_specifier_nobody assignment_opt 1926 1876 { $$ = $1->addInitializer( $2 ? new InitializerNode( $2 ) : nullptr ); } 1927 | declaration_specifier_nobody abstract_parameter_declarator default_initialize_opt1877 | declaration_specifier_nobody abstract_parameter_declarator assignment_opt 1928 1878 { $$ = $2->addType( $1 )->addInitializer( $3 ? new InitializerNode( $3 ) : nullptr ); } 1929 1879 ; … … 2262 2212 ; 2263 2213 2264 with_clause_opt:2265 // empty2266 { $$ = (StatementNode *)0; } // FIX ME2267 | WITH '(' tuple_expression_list ')'2268 { $$ = (StatementNode *)0; } // FIX ME2269 ;2270 2271 2214 function_definition: 2272 cfa_function_declaration with_clause_opt compound_statement// CFA2215 cfa_function_declaration compound_statement // CFA 2273 2216 { 2274 2217 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2275 2218 typedefTable.leaveScope(); 2276 $$ = $1->addFunctionBody( $ 3);2277 } 2278 | declaration_specifier function_declarator with_clause_optcompound_statement2219 $$ = $1->addFunctionBody( $2 ); 2220 } 2221 | declaration_specifier function_declarator compound_statement 2279 2222 { 2280 2223 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2281 2224 typedefTable.leaveScope(); 2282 $$ = $2->addFunctionBody( $ 4)->addType( $1 );2283 } 2284 | type_qualifier_list function_declarator with_clause_optcompound_statement2225 $$ = $2->addFunctionBody( $3 )->addType( $1 ); 2226 } 2227 | type_qualifier_list function_declarator compound_statement 2285 2228 { 2286 2229 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2287 2230 typedefTable.leaveScope(); 2288 $$ = $2->addFunctionBody( $ 4)->addQualifiers( $1 );2289 } 2290 | declaration_qualifier_list function_declarator with_clause_optcompound_statement2231 $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 ); 2232 } 2233 | declaration_qualifier_list function_declarator compound_statement 2291 2234 { 2292 2235 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2293 2236 typedefTable.leaveScope(); 2294 $$ = $2->addFunctionBody( $ 4)->addQualifiers( $1 );2295 } 2296 | declaration_qualifier_list type_qualifier_list function_declarator with_clause_optcompound_statement2237 $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 ); 2238 } 2239 | declaration_qualifier_list type_qualifier_list function_declarator compound_statement 2297 2240 { 2298 2241 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2299 2242 typedefTable.leaveScope(); 2300 $$ = $3->addFunctionBody( $ 5)->addQualifiers( $2 )->addQualifiers( $1 );2243 $$ = $3->addFunctionBody( $4 )->addQualifiers( $2 )->addQualifiers( $1 ); 2301 2244 } 2302 2245 2303 2246 // Old-style K&R function definition, OBSOLESCENT (see 4) 2304 | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_optcompound_statement2247 | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement 2305 2248 { 2306 2249 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2307 2250 typedefTable.leaveScope(); 2308 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 6)->addType( $1 );2309 } 2310 | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_optcompound_statement2251 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addType( $1 ); 2252 } 2253 | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement 2311 2254 { 2312 2255 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2313 2256 typedefTable.leaveScope(); 2314 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $ 6)->addQualifiers( $1 );2257 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 ); 2315 2258 } 2316 2259 2317 2260 // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4) 2318 | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_optcompound_statement2261 | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement 2319 2262 { 2320 2263 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2321 2264 typedefTable.leaveScope(); 2322 $$ = $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_optcompound_statement2265 $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 ); 2266 } 2267 | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement 2325 2268 { 2326 2269 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2327 2270 typedefTable.leaveScope(); 2328 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $ 7)->addQualifiers( $2 )->addQualifiers( $1 );2271 $$ = $3->addOldDeclList( $5 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 ); 2329 2272 } 2330 2273 ; … … 3088 3031 ; 3089 3032 3090 default_initialize_opt:3033 assignment_opt: 3091 3034 // empty 3092 3035 { $$ = nullptr; }
Note:
See TracChangeset
for help on using the changeset viewer.