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