Changeset 054514d for src/Parser/parser.yy
- Timestamp:
- May 29, 2018, 3:26:31 PM (6 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, with_gc
- Children:
- 3530f39a
- Parents:
- 96812c0 (diff), da60c631 (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
r96812c0 r054514d 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 … … 326 326 %type<decl> cfa_identifier_parameter_declarator_tuple cfa_identifier_parameter_ptr 327 327 328 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ type_list_opt328 %type<decl> cfa_parameter_declaration cfa_parameter_list cfa_parameter_ellipsis_list_opt 329 329 330 330 %type<decl> cfa_typedef_declaration cfa_variable_declaration cfa_variable_specifier … … 852 852 // '[' ']' 853 853 // { $$ = new ExpressionNode( build_tuple() ); } 854 // '[' push assignment_expression pop ']'854 // | '[' push assignment_expression pop ']' 855 855 // { $$ = 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) ) ); }856 '[' push ',' tuple_expression_list pop ']' 857 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)(new ExpressionNode( nullptr ) )->set_last( $4 ) ) ); } 858 | '[' push assignment_expression ',' tuple_expression_list pop ']' 859 { $$ = new ExpressionNode( build_tuple( (ExpressionNode *)$3->set_last( $5 ) ) ); } 860 860 ; 861 861 … … 883 883 labeled_statement 884 884 | compound_statement 885 | expression_statement { $$ = $1; }885 | expression_statement 886 886 | selection_statement 887 887 | iteration_statement … … 1200 1200 type_specifier_nobody 1201 1201 | type_specifier_nobody declarator 1202 { 1203 $$ = $2->addType( $1 ); 1204 } 1202 { $$ = $2->addType( $1 ); } 1205 1203 | type_specifier_nobody variable_abstract_declarator 1206 1204 { $$ = $2->addType( $1 ); } 1207 1205 | cfa_abstract_declarator_tuple no_attr_identifier // CFA 1208 { 1209 $$ = $1->addName( $2 ); 1210 } 1206 { $$ = $1->addName( $2 ); } 1211 1207 | cfa_abstract_declarator_tuple // CFA 1212 1208 ; … … 1286 1282 1287 1283 declaration_list_opt: // used at beginning of switch statement 1288 pop 1284 pop // empty 1289 1285 { $$ = nullptr; } 1290 1286 | declaration_list … … 1321 1317 1322 1318 local_label_list: // GCC, local label 1323 no_attr_identifier_or_type_name {}1324 | local_label_list ',' no_attr_identifier_or_type_name {}1319 no_attr_identifier_or_type_name 1320 | local_label_list ',' no_attr_identifier_or_type_name 1325 1321 ; 1326 1322 … … 1385 1381 | declaration_qualifier_list type_qualifier_list cfa_function_specifier 1386 1382 { $$ = $3->addQualifiers( $1 )->addQualifiers( $2 ); } 1387 | cfa_function_declaration ',' identifier_or_type_name '(' cfa_parameter_type_list_opt')'1383 | cfa_function_declaration ',' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' 1388 1384 { 1389 1385 // Append the return type at the start (left-hand-side) to each identifier in the list. 1390 1386 DeclarationNode * ret = new DeclarationNode; 1391 1387 ret->type = maybeClone( $1->type->base ); 1392 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $ 5, nullptr ) );1388 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $6, nullptr ) ); 1393 1389 } 1394 1390 ; 1395 1391 1396 1392 cfa_function_specifier: // CFA 1397 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ type_list_opt pop ')' // S/R conflict1393 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict 1398 1394 // { 1399 1395 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true ); 1400 1396 // } 1401 // '[' ']' identifier '(' push cfa_parameter_ type_list_opt pop ')'1397 // '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')' 1402 1398 // { 1403 1399 // typedefTable.setNextIdentifier( *$5 ); 1404 1400 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true ); 1405 1401 // } 1406 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ type_list_opt pop ')'1402 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')' 1407 1403 // { 1408 1404 // typedefTable.setNextIdentifier( *$5 ); … … 1412 1408 // identifier_or_type_name must be broken apart because of the sequence: 1413 1409 // 1414 // '[' ']' identifier_or_type_name '(' cfa_parameter_ type_list_opt ')'1410 // '[' ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')' 1415 1411 // '[' ']' type_specifier 1416 1412 // 1417 1413 // type_specifier can resolve to just TYPEDEFname (e.g., typedef int T; int f( T );). Therefore this must be 1418 1414 // 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')'1415 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' 1420 1416 // 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 ); }1417 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); } 1418 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' 1419 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 ); } 1424 1420 ; 1425 1421 1426 1422 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 ) ); } 1423 '[' push cfa_parameter_list pop ']' 1424 { $$ = DeclarationNode::newTuple( $3 ); } 1425 | '[' push cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ']' 1426 // To obtain LR(1 ), the last cfa_abstract_parameter_list is added into this flattened rule to lookahead to the ']'. 1427 { $$ = DeclarationNode::newTuple( $3->appendList( $7 ) ); } 1433 1428 ; 1434 1429 … … 1604 1599 1605 1600 forall: 1606 FORALL '(' 1607 { 1608 typedefTable.enterScope(); 1609 } 1610 type_parameter_list ')' // CFA 1611 { 1612 typedefTable.leaveScope(); 1613 $$ = DeclarationNode::newForall( $4 ); 1614 } 1601 FORALL '(' push type_parameter_list pop ')' // CFA 1602 { $$ = DeclarationNode::newForall( $4 ); } 1615 1603 ; 1616 1604 … … 1980 1968 ; 1981 1969 1982 cfa_parameter_ type_list_opt: // CFA, abstract + real1970 cfa_parameter_ellipsis_list_opt: // CFA, abstract + real 1983 1971 // empty 1984 1972 { $$ = DeclarationNode::newBasicType( DeclarationNode::Void ); } … … 1987 1975 | cfa_abstract_parameter_list 1988 1976 | cfa_parameter_list 1989 | cfa_parameter_list ','cfa_abstract_parameter_list1990 { $$ = $1->appendList( $ 3); }1991 | cfa_abstract_parameter_list ','ELLIPSIS1977 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list 1978 { $$ = $1->appendList( $5 ); } 1979 | cfa_abstract_parameter_list pop ',' push ELLIPSIS 1992 1980 { $$ = $1->addVarArgs(); } 1993 | cfa_parameter_list ','ELLIPSIS1981 | cfa_parameter_list pop ',' push ELLIPSIS 1994 1982 { $$ = $1->addVarArgs(); } 1995 1983 ; … … 1999 1987 // factored out from cfa_parameter_list, flattening the rules to get lookahead to the ']'. 2000 1988 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); }1989 | cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration 1990 { $$ = $1->appendList( $5 ); } 1991 | cfa_parameter_list pop ',' push cfa_parameter_declaration 1992 { $$ = $1->appendList( $5 ); } 1993 | cfa_parameter_list pop ',' push cfa_abstract_parameter_list pop ',' push cfa_parameter_declaration 1994 { $$ = $1->appendList( $5 )->appendList( $9 ); } 2007 1995 ; 2008 1996 2009 1997 cfa_abstract_parameter_list: // CFA, new & old style abstract 2010 1998 cfa_abstract_parameter_declaration 2011 | cfa_abstract_parameter_list ','cfa_abstract_parameter_declaration2012 { $$ = $1->appendList( $ 3); }1999 | cfa_abstract_parameter_list pop ',' push cfa_abstract_parameter_declaration 2000 { $$ = $1->appendList( $5 ); } 2013 2001 ; 2014 2002 … … 2159 2147 '.' no_attr_identifier // C99, field name 2160 2148 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2161 | '[' assignment_expression ']'// C99, single array element2149 | '[' push assignment_expression pop ']' // C99, single array element 2162 2150 // 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 2151 { $$ = $3; } 2152 | '[' push subrange pop ']' // CFA, multiple array elements 2153 { $$ = $3; } 2154 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2155 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild< Expression >( $3 ), maybeMoveBuild< Expression >( $5 ) ) ); } 2156 | '.' '[' push field_list pop ']' // CFA, tuple field selector 2157 { $$ = $4; } 2170 2158 ; 2171 2159 … … 2238 2226 '|' no_attr_identifier_or_type_name '(' type_list ')' 2239 2227 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2240 | '|' '{' push trait_declaration_list '}'2228 | '|' '{' push trait_declaration_list pop '}' 2241 2229 { $$ = $4; } 2242 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list '}' '(' type_list ')'2230 | '|' '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' '(' type_list ')' 2243 2231 { SemanticError( yylloc, "Generic data-type assertion is currently unimplemented." ); $$ = nullptr; } 2244 2232 ; … … 2286 2274 TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' '}' 2287 2275 { $$ = 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 '}' 2276 | TRAIT no_attr_identifier_or_type_name '(' push type_parameter_list pop ')' '{' push trait_declaration_list pop '}' 2291 2277 { $$ = DeclarationNode::newTrait( $2, $5, $10 ); } 2292 2278 ; … … 2294 2280 trait_declaration_list: // CFA 2295 2281 trait_declaration 2296 | trait_declaration_list p ush trait_declaration2297 { $$ = $1->appendList( $ 3); }2282 | trait_declaration_list pop push trait_declaration 2283 { $$ = $1->appendList( $4 ); } 2298 2284 ; 2299 2285 2300 2286 trait_declaration: // CFA 2301 cfa_trait_declaring_list pop';'2302 | trait_declaring_list pop';'2287 cfa_trait_declaring_list ';' 2288 | trait_declaring_list ';' 2303 2289 ; 2304 2290 2305 2291 cfa_trait_declaring_list: // CFA 2306 2292 cfa_variable_specifier 2307 { $$ = $1; }2308 2293 | cfa_function_specifier 2309 { $$ = $1; }2310 2294 | cfa_trait_declaring_list pop ',' push identifier_or_type_name 2311 2295 { $$ = $1->appendList( $1->cloneType( $5 ) ); } … … 2366 2350 } 2367 2351 | type_qualifier_list 2368 { 2369 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2370 } 2352 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2371 2353 push '{' external_definition_list '}' // CFA, namespace 2372 2354 { … … 2381 2363 } 2382 2364 | declaration_qualifier_list 2383 { 2384 if ( $1->type->forall ) xxx = forall = true; // remember generic type 2385 } 2365 { if ( $1->type->forall ) xxx = forall = true; } // remember generic type 2386 2366 push '{' external_definition_list '}' // CFA, namespace 2387 2367 { … … 2423 2403 // declaration must still have a type_specifier. OBSOLESCENT (see 1) 2424 2404 | function_declarator compound_statement 2425 { 2426 typedefTable.leaveScope(); 2427 $$ = $1->addFunctionBody( $2 ); 2428 } 2405 { $$ = $1->addFunctionBody( $2 ); } 2429 2406 | KR_function_declarator KR_declaration_list_opt compound_statement 2430 { 2431 typedefTable.leaveScope(); 2432 $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); 2433 } 2407 { $$ = $1->addOldDeclList( $2 )->addFunctionBody( $3 ); } 2434 2408 ; 2435 2409 … … 2444 2418 cfa_function_declaration with_clause_opt compound_statement // CFA 2445 2419 { 2446 typedefTable.leaveScope();2447 2420 // Add the function body to the last identifier in the function definition list, i.e., foo3: 2448 2421 // [const double] foo1(), foo2( int ), foo3( double ) { return 3.0; } … … 2453 2426 { 2454 2427 rebindForall( $1, $2 ); 2455 typedefTable.leaveScope();2456 2428 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2457 2429 } … … 2459 2431 { 2460 2432 rebindForall( $1, $2 ); 2461 typedefTable.leaveScope();2462 2433 $$ = $2->addFunctionBody( $4, $3 )->addType( $1 ); 2463 2434 } 2464 2435 // handles default int return type, OBSOLESCENT (see 1) 2465 2436 | type_qualifier_list function_declarator with_clause_opt compound_statement 2466 { 2467 typedefTable.leaveScope(); 2468 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2469 } 2437 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2470 2438 // handles default int return type, OBSOLESCENT (see 1) 2471 2439 | declaration_qualifier_list function_declarator with_clause_opt compound_statement 2472 { 2473 typedefTable.leaveScope(); 2474 $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); 2475 } 2440 { $$ = $2->addFunctionBody( $4, $3 )->addQualifiers( $1 ); } 2476 2441 // handles default int return type, OBSOLESCENT (see 1) 2477 2442 | 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 } 2443 { $$ = $3->addFunctionBody( $5, $4 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2482 2444 2483 2445 // Old-style K&R function definition, OBSOLESCENT (see 4) … … 2485 2447 { 2486 2448 rebindForall( $1, $2 ); 2487 typedefTable.leaveScope();2488 2449 $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addType( $1 ); 2489 2450 } 2490 2451 // handles default int return type, OBSOLESCENT (see 1) 2491 2452 | 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 } 2453 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2496 2454 // handles default int return type, OBSOLESCENT (see 1) 2497 2455 | 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 } 2456 { $$ = $2->addOldDeclList( $3 )->addFunctionBody( $5, $4 )->addQualifiers( $1 ); } 2502 2457 // handles default int return type, OBSOLESCENT (see 1) 2503 2458 | 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 } 2459 { $$ = $3->addOldDeclList( $4 )->addFunctionBody( $6, $5 )->addQualifiers( $2 )->addQualifiers( $1 ); } 2508 2460 ; 2509 2461 … … 2702 2654 paren_identifier '(' identifier_list ')' // function_declarator handles empty parameter 2703 2655 { $$ = $1->addIdList( $3 ); } 2704 | '(' KR_function_ptr ')' '(' p arameter_type_list_opt')'2705 { $$ = $2->addParamList( $ 5); }2656 | '(' KR_function_ptr ')' '(' push parameter_type_list_opt pop ')' 2657 { $$ = $2->addParamList( $6 ); } 2706 2658 | '(' KR_function_no_ptr ')' // redundant parenthesis 2707 2659 { $$ = $2; } … … 2821 2773 2822 2774 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); }2775 paren_identifier '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2776 { $$ = $1->addParamList( $4 ); } 2777 | '(' identifier_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2778 { $$ = $2->addParamList( $6 ); } 2827 2779 | '(' identifier_parameter_function ')' // redundant parenthesis 2828 2780 { $$ = $2; } … … 2874 2826 2875 2827 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); }2828 typedef '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2829 { $$ = $1->addParamList( $4 ); } 2830 | '(' type_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2831 { $$ = $2->addParamList( $6 ); } 2880 2832 ; 2881 2833 … … 2924 2876 2925 2877 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); }2878 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2879 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); } 2880 | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2881 { $$ = $2->addParamList( $6 ); } 2930 2882 | '(' abstract_function ')' // redundant parenthesis 2931 2883 { $$ = $2; } … … 2942 2894 2943 2895 multi_array_dimension: 2944 '[' assignment_expression']'2945 { $$ = DeclarationNode::newArray( $ 2, 0, false ); }2946 | '[' '*' ']'// C992896 '[' push assignment_expression pop ']' 2897 { $$ = DeclarationNode::newArray( $3, 0, false ); } 2898 | '[' push '*' pop ']' // C99 2947 2899 { $$ = DeclarationNode::newVarArray( 0 ); } 2948 | multi_array_dimension '[' assignment_expression']'2949 { $$ = $1->addArray( DeclarationNode::newArray( $ 3, 0, false ) ); }2950 | multi_array_dimension '[' '*' ']'// C992900 | multi_array_dimension '[' push assignment_expression pop ']' 2901 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); } 2902 | multi_array_dimension '[' push '*' pop ']' // C99 2951 2903 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } 2952 2904 ; … … 3015 2967 3016 2968 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); }2969 '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2970 { $$ = DeclarationNode::newFunction( nullptr, nullptr, $3, nullptr ); } 2971 | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 2972 { $$ = $2->addParamList( $6 ); } 3021 2973 | '(' abstract_parameter_function ')' // redundant parenthesis 3022 2974 { $$ = $2; } … … 3039 2991 '[' ']' 3040 2992 { $$ = 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 ); }2993 // multi_array_dimension handles the '[' '*' ']' case 2994 | '[' push type_qualifier_list '*' pop ']' // remaining C99 2995 { $$ = DeclarationNode::newVarArray( $3 ); } 2996 | '[' push type_qualifier_list pop ']' 2997 { $$ = DeclarationNode::newArray( 0, $3, false ); } 2998 // multi_array_dimension handles the '[' assignment_expression ']' case 2999 | '[' push type_qualifier_list assignment_expression pop ']' 3000 { $$ = DeclarationNode::newArray( $4, $3, false ); } 3001 | '[' push STATIC type_qualifier_list_opt assignment_expression pop ']' 3002 { $$ = DeclarationNode::newArray( $5, $4, true ); } 3003 | '[' push type_qualifier_list STATIC assignment_expression pop ']' 3004 { $$ = DeclarationNode::newArray( $5, $3, true ); } 3053 3005 ; 3054 3006 … … 3094 3046 3095 3047 variable_abstract_function: 3096 '(' variable_abstract_ptr ')' '(' p arameter_type_list_opt')' // empty parameter list OBSOLESCENT (see 3)3097 { $$ = $2->addParamList( $ 5); }3048 '(' variable_abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3) 3049 { $$ = $2->addParamList( $6 ); } 3098 3050 | '(' variable_abstract_function ')' // redundant parenthesis 3099 3051 { $$ = $2; } … … 3158 3110 3159 3111 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']'3112 '[' push type_qualifier_list '*' pop ']' // remaining C99 3113 { $$ = DeclarationNode::newVarArray( $3 ); } 3114 | '[' push type_qualifier_list assignment_expression pop ']' 3115 { $$ = DeclarationNode::newArray( $4, $3, false ); } 3116 | '[' push declaration_qualifier_list assignment_expression pop ']' 3165 3117 // declaration_qualifier_list must be used because of shift/reduce conflict with 3166 3118 // assignment_expression, so a semantic check is necessary to preclude them as a type_qualifier cannot 3167 3119 // 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 ); }3120 { $$ = DeclarationNode::newArray( $4, $3, true ); } 3121 | '[' push declaration_qualifier_list type_qualifier_list assignment_expression pop ']' 3122 { $$ = DeclarationNode::newArray( $5, $4->addQualifiers( $3 ), true ); } 3171 3123 ; 3172 3124 … … 3180 3132 // 3181 3133 // cfa_abstract_tuple identifier_or_type_name 3182 // '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ type_list_opt ')'3134 // '[' cfa_parameter_list ']' identifier_or_type_name '(' cfa_parameter_ellipsis_list_opt ')' 3183 3135 // 3184 3136 // since a function return type can be syntactically identical to a tuple type: … … 3237 3189 3238 3190 cfa_abstract_tuple: // CFA 3239 '[' cfa_abstract_parameter_list ']' 3240 { $$ = DeclarationNode::newTuple( $2 ); } 3191 '[' push cfa_abstract_parameter_list pop ']' 3192 { $$ = DeclarationNode::newTuple( $3 ); } 3193 | '[' push type_specifier_nobody ELLIPSIS ']' 3194 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 3195 | '[' push type_specifier_nobody ELLIPSIS constant_expression ']' 3196 { SemanticError( yylloc, "Tuple array currently unimplemented." ); $$ = nullptr; } 3241 3197 ; 3242 3198 3243 3199 cfa_abstract_function: // CFA 3244 // '[' ']' '(' cfa_parameter_ type_list_opt ')'3200 // '[' ']' '(' cfa_parameter_ellipsis_list_opt ')' 3245 3201 // { $$ = 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 ); }3202 cfa_abstract_tuple '(' push cfa_parameter_ellipsis_list_opt pop ')' 3203 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 3204 | cfa_function_return '(' push cfa_parameter_ellipsis_list_opt pop ')' 3205 { $$ = DeclarationNode::newFunction( nullptr, $1, $4, nullptr ); } 3250 3206 ; 3251 3207
Note: See TracChangeset
for help on using the changeset viewer.