Changes in src/Parser/parser.yy [13e8427:3ed994e]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r13e8427 r3ed994e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon May 28 17:01:36201813 // Update Count : 33 8312 // Last Modified On : Tue May 22 08:41:57 2018 13 // Update Count : 3353 14 14 // 15 15 … … 175 175 bool flag; 176 176 CatchStmt::Kind catch_kind; 177 GenericExpr * genexpr; 177 178 } 178 179 … … 259 260 %type<flag> asm_volatile_opt 260 261 %type<en> handler_predicate_opt 262 %type<genexpr> generic_association generic_assoc_list 261 263 262 264 // statements … … 324 326 %type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr 325 327 326 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ ellipsis_list_opt328 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_type_list_opt 327 329 328 330 %type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier … … 501 503 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 502 504 | GENERIC '(' assignment_expression ',' generic_assoc_list ')' // C11 503 { SemanticError( yylloc, "_Generic is currently unimplemented." ); $$ = nullptr; } 505 { 506 // add the missing control expression to the GenericExpr and return it 507 $5->control = maybeMoveBuild<Expression>( $3 ); 508 $$ = new ExpressionNode( $5 ); 509 } 504 510 ; 505 511 506 512 generic_assoc_list: // C11 507 |generic_association513 generic_association 508 514 | generic_assoc_list ',' generic_association 515 { 516 // steal the association node from the singleton and delete the wrapper 517 $1->associations.splice($1->associations.end(), $3->associations); 518 delete $3; 519 $$ = $1; 520 } 509 521 ; 510 522 511 523 generic_association: // C11 512 524 type_no_function ':' assignment_expression 525 { 526 // create a GenericExpr wrapper with one association pair 527 $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild<Expression>($3) } } ); 528 } 513 529 | DEFAULT ':' assignment_expression 530 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild<Expression>($3) } } ); } 514 531 ; 515 532 … … 835 852 // '[' ']' 836 853 // { $$ = new ExpressionNode( build_tuple() ); } 837 // |'[' push assignment_expression pop ']'854 // '[' push assignment_expression pop ']' 838 855 // { $$ = new ExpressionNode( build_tuple( $3 ) ); } 839 '[' push ',' tuple_expression_list pop']'840 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $ 4) ) ); }841 | '[' push assignment_expression ',' tuple_expression_list pop']'842 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$ 3->set_last( $5) ) ); }856 '[' ',' tuple_expression_list ']' 857 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $3 ) ) ); } 858 | '[' assignment_expression ',' tuple_expression_list ']' 859 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$2->set_last( $4 ) ) ); } 843 860 ; 844 861 … … 866 883 labeled_statement 867 884 | compound_statement 868 | expression_statement 885 | expression_statement { $$ = $1; } 869 886 | selection_statement 870 887 | iteration_statement … … 1183 1200 type_specifier_nobody 1184 1201 | type_specifier_nobody declarator 1185 { $$ = $2->addType( $1 ); } 1202 { 1203 $$ = $2->addType( $1 ); 1204 } 1186 1205 | type_specifier_nobody variable_abstract_declarator 1187 1206 { $$ = $2->addType( $1 ); } 1188 1207 | cfa_abstract_declarator_tuple no_attr_identifier // CFA 1189 { $$ = $1->addName( $2 ); } 1208 { 1209 $$ = $1->addName( $2 ); 1210 } 1190 1211 | cfa_abstract_declarator_tuple // CFA 1191 1212 ; … … 1265 1286 1266 1287 declaration_list_opt: // used at beginning of switch statement 1267 pop // empty1288 pop 1268 1289 { $$ = nullptr; } 1269 1290 | declaration_list … … 1300 1321 1301 1322 local_label_list: // GCC, local label 1302 no_attr_identifier_or_type_name 1303 | local_label_list ',' no_attr_identifier_or_type_name 1323 no_attr_identifier_or_type_name {} 1324 | local_label_list ',' no_attr_identifier_or_type_name {} 1304 1325 ; 1305 1326 … … 1364 1385 | declaration_qualifier_list type_qualifier_list cfa_function_specifier 1365 1386 { $$ = $3->addQualifiers( $1 )->addQualifiers( $2 ); } 1366 | cfa_function_declaration ',' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop')'1387 | cfa_function_declaration ',' identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1367 1388 { 1368 1389 // Append the return type at the start (left-hand-side) to each identifier in the list. 1369 1390 DeclarationNode * ret = new DeclarationNode; 1370 1391 ret->type = maybeClone( $1->type->base ); 1371 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $ 6, nullptr ) );1392 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $5, nullptr ) ); 1372 1393 } 1373 1394 ; 1374 1395 1375 1396 cfa_function_specifier: // CFA 1376 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ ellipsis_list_opt pop ')' // S/R conflict1397 // '[' ']' identifier_or_type_name '(' push cfa_parameter_type_list_opt pop ')' // S/R conflict 1377 1398 // { 1378 1399 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true ); 1379 1400 // } 1380 // '[' ']' identifier '(' push cfa_parameter_ ellipsis_list_opt pop ')'1401 // '[' ']' identifier '(' push cfa_parameter_type_list_opt pop ')' 1381 1402 // { 1382 1403 // typedefTable.setNextIdentifier( *$5 ); 1383 1404 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true ); 1384 1405 // } 1385 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ ellipsis_list_opt pop ')'1406 // | '[' ']' TYPEDEFname '(' push cfa_parameter_type_list_opt pop ')' 1386 1407 // { 1387 1408 // typedefTable.setNextIdentifier( *$5 ); … … 1391 1412 // identifier_or_type_name must be broken apart because of the sequence: 1392 1413 // 1393 // '[' ']' identifier_or_type_name '(' cfa_parameter_ ellipsis_list_opt ')'1414 // '[' ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1394 1415 // '[' ']' type_specifier 1395 1416 // 1396 1417 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1397 1418 // flattened to allow lookahead to the '(' without having to reduce identifier_or_type_name. 1398 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop')'1419 cfa_abstract_tuple identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1399 1420 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1400 { $$ = DeclarationNode::newFunction( $2, $1, $ 5, 0 ); }1401 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop')'1402 { $$ = DeclarationNode::newFunction( $2, $1, $ 5, 0 ); }1421 { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); } 1422 | cfa_function_return identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 1423 { $$ = DeclarationNode::newFunction( $2, $1, $4, 0 ); } 1403 1424 ; 1404 1425 1405 1426 cfa_function_return: // CFA 1406 '[' push cfa_parameter_list pop ']' 1407 { $$ = DeclarationNode::newTuple( $3 ); } 1408 | '[' push cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ']' 1409 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'. 1410 { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); } 1427 '[' cfa_parameter_list ']' 1428 { $$ = DeclarationNode::newTuple( $2 ); } 1429 | '[' cfa_parameter_list ',' cfa_abstract_parameter_list ']' 1430 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the 1431 // ']'. 1432 { $$ = DeclarationNode::newTuple( $2->appendList( $4 ) ); } 1411 1433 ; 1412 1434 … … 1582 1604 1583 1605 forall: 1584 FORALL '(' push type_parameter_list pop ')' // CFA 1585 { $$ = DeclarationNode::newForall( $4 ); } 1606 FORALL '(' 1607 { 1608 typedefTable.enterScope(); 1609 } 1610 type_parameter_list ')' // CFA 1611 { 1612 typedefTable.leaveScope(); 1613 $$ = DeclarationNode::newForall( $4 ); 1614 } 1586 1615 ; 1587 1616 … … 1951 1980 ; 1952 1981 1953 cfa_parameter_ ellipsis_list_opt: // CFA, abstract + real1982 cfa_parameter_type_list_opt: // CFA, abstract + real 1954 1983 // empty 1955 1984 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } … … 1958 1987 | cfa_abstract_parameter_list 1959 1988 | cfa_parameter_list 1960 | cfa_parameter_list pop ',' pushcfa_abstract_parameter_list1961 { $$ = $1->appendList( $ 5); }1962 | cfa_abstract_parameter_list pop ',' pushELLIPSIS1989 | cfa_parameter_list ',' cfa_abstract_parameter_list 1990 { $$ = $1->appendList( $3 ); } 1991 | cfa_abstract_parameter_list ',' ELLIPSIS 1963 1992 { $$ = $1->addVarArgs(); } 1964 | cfa_parameter_list pop ',' pushELLIPSIS1993 | cfa_parameter_list ',' ELLIPSIS 1965 1994 { $$ = $1->addVarArgs(); } 1966 1995 ; … … 1970 1999 // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'. 1971 2000 cfa_parameter_declaration 1972 | cfa_abstract_parameter_list pop ',' pushcfa_parameter_declaration1973 { $$ = $1->appendList( $ 5); }1974 | cfa_parameter_list pop ',' pushcfa_parameter_declaration1975 { $$ = $1->appendList( $ 5); }1976 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ',' pushcfa_parameter_declaration1977 { $$ = $1->appendList( $ 5 )->appendList( $9); }2001 | cfa_abstract_parameter_list ',' cfa_parameter_declaration 2002 { $$ = $1->appendList( $3 ); } 2003 | cfa_parameter_list ',' cfa_parameter_declaration 2004 { $$ = $1->appendList( $3 ); } 2005 | cfa_parameter_list ',' cfa_abstract_parameter_list ',' cfa_parameter_declaration 2006 { $$ = $1->appendList( $3 )->appendList( $5 ); } 1978 2007 ; 1979 2008 1980 2009 cfa_abstract_parameter_list: // CFA, new & old style abstract 1981 2010 cfa_abstract_parameter_declaration 1982 | cfa_abstract_parameter_list pop ',' pushcfa_abstract_parameter_declaration1983 { $$ = $1->appendList( $ 5); }2011 | cfa_abstract_parameter_list ',' cfa_abstract_parameter_declaration 2012 { $$ = $1->appendList( $3 ); } 1984 2013 ; 1985 2014 … … 2084 2113 { $$ = $2; } 2085 2114 | '=' VOID 2086 { $$ = n ullptr; }2115 { $$ = new InitializerNode( true ); } 2087 2116 | ATassign initializer 2088 2117 { $$ = $2->set_maybeConstructed( false ); } … … 2130 2159 '.' no_attr_identifier // C99, field name 2131 2160 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2132 | '[' push assignment_expression pop ']'// C99, single array element2161 | '[' assignment_expression ']' // C99, single array element 2133 2162 // assignment_expression used instead of constant_expression because of shift/reduce conflicts with tuple. 2163 { $$ = $2; } 2164 | '[' subrange ']' // CFA, multiple array elements 2165 { $$ = $2; } 2166 | '[' constant_expression ELLIPSIS constant_expression ']' // GCC, multiple array elements 2167 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $2 ), maybeMoveBuild< Expression >( $4 ) ) ); } 2168 | '.' '[' field_list ']' // CFA, tuple field selector 2134 2169 { $$ = $3; } 2135 | '[' push subrange pop ']' // CFA, multiple array elements2136 { $$ = $3; }2137 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements2138 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); }2139 | '.' '[' push field_list pop ']' // CFA, tuple field selector2140 { $$ = $4; }2141 2170 ; 2142 2171 … … 2209 2238 '|' no_attr_identifier_or_type_name '(' type_list ')' 2210 2239 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2211 | '|' '{' push trait_declaration_list pop'}'2240 | '|' '{' push trait_declaration_list '}' 2212 2241 { $$ = $4; } 2213 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop'}' '(' type_list ')'2242 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')' 2214 2243 { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; } 2215 2244 ; … … 2257 2286 TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}' 2258 2287 { $$ = DeclarationNode::newTrait( $2, $5, 0 ); } 2259 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' 2288 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' 2289 { typedefTable.enterScope(); } 2290 trait_declaration_list '}' 2260 2291 { $$ = DeclarationNode::newTrait( $2, $5, $10 ); } 2261 2292 ; … … 2263 2294 trait_declaration_list: // CFA 2264 2295 trait_declaration 2265 | trait_declaration_list p op push trait_declaration2266 { $$ = $1->appendList( $ 4); }2296 | trait_declaration_list push trait_declaration 2297 { $$ = $1->appendList( $3 ); } 2267 2298 ; 2268 2299 2269 2300 trait_declaration: // CFA 2270 cfa_trait_declaring_list ';'2271 | trait_declaring_list ';'2301 cfa_trait_declaring_list pop ';' 2302 | trait_declaring_list pop ';' 2272 2303 ; 2273 2304 2274 2305 cfa_trait_declaring_list: // CFA 2275 2306 cfa_variable_specifier 2307 { $$ = $1; } 2276 2308 | cfa_function_specifier 2309 { $$ = $1; } 2277 2310 | cfa_trait_declaring_list pop ',' push identifier_or_type_name 2278 2311 { $$ = $1->appendList( $1->cloneType( $5 ) ); } … … 2333 2366 } 2334 2367 | type_qualifier_list 2335 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2368 { 2369 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2370 } 2336 2371 push '{' external_definition_list '}' // CFA, namespace 2337 2372 { … … 2346 2381 } 2347 2382 | declaration_qualifier_list 2348 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2383 { 2384 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2385 } 2349 2386 push '{' external_definition_list '}' // CFA, namespace 2350 2387 { … … 2386 2423 // declaration must still have a type_specifier. OBSOLESCENT (see 1) 2387 2424 | function_declarator compound_statement 2388 { $$ = $1->addFunctionBody( $2 ); } 2425 { 2426 typedefTable.leaveScope(); 2427 $$ = $1->addFunctionBody( $2 ); 2428 } 2389 2429 | KR_function_declarator KR_declaration_list_opt compound_statement 2390 { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); } 2430 { 2431 typedefTable.leaveScope(); 2432 $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); 2433 } 2391 2434 ; 2392 2435 … … 2401 2444 cfa_function_declaration with_clause_opt compound_statement // CFA 2402 2445 { 2446 typedefTable.leaveScope(); 2403 2447 // Add the function body to the last identifier in the function definition list, i.e., foo3: 2404 2448 // [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; } … … 2409 2453 { 2410 2454 rebindForall( $1, $2 ); 2455 typedefTable.leaveScope(); 2411 2456 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2412 2457 } … … 2414 2459 { 2415 2460 rebindForall( $1, $2 ); 2461 typedefTable.leaveScope(); 2416 2462 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2417 2463 } 2418 2464 // handles default int return type, OBSOLESCENT (see 1) 2419 2465 | type_qualifier_list function_declarator with_clause_opt compound_statement 2420 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2466 { 2467 typedefTable.leaveScope(); 2468 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2469 } 2421 2470 // handles default int return type, OBSOLESCENT (see 1) 2422 2471 | declaration_qualifier_list function_declarator with_clause_opt compound_statement 2423 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2472 { 2473 typedefTable.leaveScope(); 2474 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2475 } 2424 2476 // handles default int return type, OBSOLESCENT (see 1) 2425 2477 | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement 2426 { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2478 { 2479 typedefTable.leaveScope(); 2480 $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); 2481 } 2427 2482 2428 2483 // Old-style K&R function definition, OBSOLESCENT (see 4) … … 2430 2485 { 2431 2486 rebindForall( $1, $2 ); 2487 typedefTable.leaveScope(); 2432 2488 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 ); 2433 2489 } 2434 2490 // handles default int return type, OBSOLESCENT (see 1) 2435 2491 | type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2436 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2492 { 2493 typedefTable.leaveScope(); 2494 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2495 } 2437 2496 // handles default int return type, OBSOLESCENT (see 1) 2438 2497 | declaration_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2439 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2498 { 2499 typedefTable.leaveScope(); 2500 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); 2501 } 2440 2502 // handles default int return type, OBSOLESCENT (see 1) 2441 2503 | declaration_qualifier_list type_qualifier_list KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2442 { $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2504 { 2505 typedefTable.leaveScope(); 2506 $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); 2507 } 2443 2508 ; 2444 2509 … … 2637 2702 paren_identifier '(' identifier_list ')' // function_declarator handles empty parameter 2638 2703 { $$ = $1->addIdList( $3 ); } 2639 | '(' KR_function_ptr ')' '(' p ush parameter_type_list_opt pop')'2640 { $$ = $2->addParamList( $ 6); }2704 | '(' KR_function_ptr ')' '(' parameter_type_list_opt ')' 2705 { $$ = $2->addParamList( $5 ); } 2641 2706 | '(' KR_function_no_ptr ')' // redundant parenthesis 2642 2707 { $$ = $2; } … … 2756 2821 2757 2822 identifier_parameter_function: 2758 paren_identifier '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2759 { $$ = $1->addParamList( $ 4); }2760 | '(' identifier_parameter_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2761 { $$ = $2->addParamList( $ 6); }2823 paren_identifier '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2824 { $$ = $1->addParamList( $3 ); } 2825 | '(' identifier_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2826 { $$ = $2->addParamList( $5 ); } 2762 2827 | '(' identifier_parameter_function ')' // redundant parenthesis 2763 2828 { $$ = $2; } … … 2809 2874 2810 2875 type_parameter_function: 2811 typedef '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2812 { $$ = $1->addParamList( $ 4); }2813 | '(' type_parameter_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2814 { $$ = $2->addParamList( $ 6); }2876 typedef '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2877 { $$ = $1->addParamList( $3 ); } 2878 | '(' type_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2879 { $$ = $2->addParamList( $5 ); } 2815 2880 ; 2816 2881 … … 2859 2924 2860 2925 abstract_function: 2861 '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2862 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 3, nullptr ); }2863 | '(' abstract_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2864 { $$ = $2->addParamList( $ 6); }2926 '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2927 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); } 2928 | '(' abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 2929 { $$ = $2->addParamList( $5 ); } 2865 2930 | '(' abstract_function ')' // redundant parenthesis 2866 2931 { $$ = $2; } … … 2877 2942 2878 2943 multi_array_dimension: 2879 '[' push assignment_expression pop']'2880 { $$ = DeclarationNode::newArray( $ 3, 0, false ); }2881 | '[' push '*' pop ']'// C992944 '[' assignment_expression ']' 2945 { $$ = DeclarationNode::newArray( $2, 0, false ); } 2946 | '[' '*' ']' // C99 2882 2947 { $$ = DeclarationNode::newVarArray( 0 ); } 2883 | multi_array_dimension '[' push assignment_expression pop']'2884 { $$ = $1->addArray( DeclarationNode::newArray( $ 4, 0, false ) ); }2885 | multi_array_dimension '[' push '*' pop ']'// C992948 | multi_array_dimension '[' assignment_expression ']' 2949 { $$ = $1->addArray( DeclarationNode::newArray( $3, 0, false ) ); } 2950 | multi_array_dimension '[' '*' ']' // C99 2886 2951 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } 2887 2952 ; … … 2950 3015 2951 3016 abstract_parameter_function: 2952 '(' p ush parameter_type_list_opt pop ')'// empty parameter list OBSOLESCENT (see 3)2953 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $ 3, nullptr ); }2954 | '(' abstract_parameter_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)2955 { $$ = $2->addParamList( $ 6); }3017 '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 3018 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $2, nullptr ); } 3019 | '(' abstract_parameter_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 3020 { $$ = $2->addParamList( $5 ); } 2956 3021 | '(' abstract_parameter_function ')' // redundant parenthesis 2957 3022 { $$ = $2; } … … 2974 3039 '[' ']' 2975 3040 { $$ = DeclarationNode::newArray( 0, 0, false ); } 2976 2977 | '[' push type_qualifier_list '*' pop ']'// remaining C992978 { $$ = DeclarationNode::newVarArray( $ 3); }2979 | '[' push type_qualifier_list pop']'2980 { $$ = DeclarationNode::newArray( 0, $ 3, false ); }2981 2982 | '[' push type_qualifier_list assignment_expression pop']'2983 { $$ = DeclarationNode::newArray( $ 4, $3, false ); }2984 | '[' push STATIC type_qualifier_list_opt assignment_expression pop']'2985 { $$ = DeclarationNode::newArray( $ 5, $4, true ); }2986 | '[' push type_qualifier_list STATIC assignment_expression pop']'2987 { $$ = DeclarationNode::newArray( $ 5, $3, true ); }3041 // multi_array_dimension handles the '[' '*' ']' case 3042 | '[' type_qualifier_list '*' ']' // remaining C99 3043 { $$ = DeclarationNode::newVarArray( $2 ); } 3044 | '[' type_qualifier_list ']' 3045 { $$ = DeclarationNode::newArray( 0, $2, false ); } 3046 // multi_array_dimension handles the '[' assignment_expression ']' case 3047 | '[' type_qualifier_list assignment_expression ']' 3048 { $$ = DeclarationNode::newArray( $3, $2, false ); } 3049 | '[' STATIC type_qualifier_list_opt assignment_expression ']' 3050 { $$ = DeclarationNode::newArray( $4, $3, true ); } 3051 | '[' type_qualifier_list STATIC assignment_expression ']' 3052 { $$ = DeclarationNode::newArray( $4, $2, true ); } 2988 3053 ; 2989 3054 … … 3029 3094 3030 3095 variable_abstract_function: 3031 '(' variable_abstract_ptr ')' '(' p ush parameter_type_list_opt pop')' // empty parameter list OBSOLESCENT (see 3)3032 { $$ = $2->addParamList( $ 6); }3096 '(' variable_abstract_ptr ')' '(' parameter_type_list_opt ')' // empty parameter list OBSOLESCENT (see 3) 3097 { $$ = $2->addParamList( $5 ); } 3033 3098 | '(' variable_abstract_function ')' // redundant parenthesis 3034 3099 { $$ = $2; } … … 3093 3158 3094 3159 cfa_array_parameter_1st_dimension: 3095 '[' push type_qualifier_list '*' pop ']'// remaining C993096 { $$ = DeclarationNode::newVarArray( $ 3); }3097 | '[' push type_qualifier_list assignment_expression pop']'3098 { $$ = DeclarationNode::newArray( $ 4, $3, false ); }3099 | '[' push declaration_qualifier_list assignment_expression pop']'3160 '[' type_qualifier_list '*' ']' // remaining C99 3161 { $$ = DeclarationNode::newVarArray( $2 ); } 3162 | '[' type_qualifier_list assignment_expression ']' 3163 { $$ = DeclarationNode::newArray( $3, $2, false ); } 3164 | '[' declaration_qualifier_list assignment_expression ']' 3100 3165 // declaration_qualifier_list must be used because of shift/reduce conflict with 3101 3166 // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot 3102 3167 // appear in this context. 3103 { $$ = DeclarationNode::newArray( $ 4, $3, true ); }3104 | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop']'3105 { $$ = DeclarationNode::newArray( $ 5, $4->addQualifiers( $3 ), true ); }3168 { $$ = DeclarationNode::newArray( $3, $2, true ); } 3169 | '[' declaration_qualifier_list type_qualifier_list assignment_expression ']' 3170 { $$ = DeclarationNode::newArray( $4, $3->addQualifiers( $3 ), true ); } 3106 3171 ; 3107 3172 … … 3115 3180 // 3116 3181 // cfa_abstract_tuple identifier_or_type_name 3117 // '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ ellipsis_list_opt ')'3182 // '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_type_list_opt ')' 3118 3183 // 3119 3184 // since a function return type can be syntactically identical to a tuple type: … … 3172 3237 3173 3238 cfa_abstract_tuple: // CFA 3174 '[' push cfa_abstract_parameter_list pop ']' 3175 { $$ = DeclarationNode::newTuple( $3 ); } 3176 | '[' push type_specifier_nobody ELLIPSIS ']' 3177 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 3178 | '[' push type_specifier_nobody ELLIPSIS constant_expression ']' 3179 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 3239 '[' cfa_abstract_parameter_list ']' 3240 { $$ = DeclarationNode::newTuple( $2 ); } 3180 3241 ; 3181 3242 3182 3243 cfa_abstract_function: // CFA 3183 // '[' ']' '(' cfa_parameter_ ellipsis_list_opt ')'3244 // '[' ']' '(' cfa_parameter_type_list_opt ')' 3184 3245 // { $$ = DeclarationNode::newFunction( nullptr, DeclarationNode::newTuple( nullptr ), $4, nullptr ); } 3185 cfa_abstract_tuple '(' push cfa_parameter_ellipsis_list_opt pop')'3186 { $$ = DeclarationNode::newFunction( nullptr, $1, $ 4, nullptr ); }3187 | cfa_function_return '(' push cfa_parameter_ellipsis_list_opt pop')'3188 { $$ = DeclarationNode::newFunction( nullptr, $1, $ 4, nullptr ); }3246 cfa_abstract_tuple '(' cfa_parameter_type_list_opt ')' 3247 { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); } 3248 | cfa_function_return '(' cfa_parameter_type_list_opt ')' 3249 { $$ = DeclarationNode::newFunction( nullptr, $1, $3, nullptr ); } 3189 3250 ; 3190 3251
Note: See TracChangeset
for help on using the changeset viewer.