Changes in src/Parser/parser.yy [757ffed:033ff37]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (32 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
r757ffed r033ff37 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jul 14 07:54:30201913 // Update Count : 435 512 // Last Modified On : Thu Jul 25 22:31:38 2019 13 // Update Count : 4359 14 14 // 15 15 … … 272 272 %token ZERO_T ONE_T // CFA 273 273 %token VALIST // GCC 274 %token AUTO_TYPE // GCC 274 275 %token TYPEOF BASETYPEOF LABEL // GCC 275 276 %token ENUM STRUCT UNION … … 288 289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 289 290 %token<tok> TIMEOUT WOR 290 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname291 291 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 292 292 %token<tok> DIRECTIVE … … 312 312 %token ATassign // @= 313 313 314 %type<tok> identifier no_attr_identifier315 %type<tok> identifier_or_type_name no_attr_identifier_or_type_nameattr_name314 %type<tok> identifier 315 %type<tok> identifier_or_type_name attr_name 316 316 %type<tok> quasi_keyword 317 317 %type<constant> string_literal … … 546 546 ; 547 547 548 no_attr_identifier:548 identifier: 549 549 IDENTIFIER 550 550 | quasi_keyword 551 551 | '@' // CFA 552 552 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } 553 ;554 555 identifier:556 no_attr_identifier557 | ATTR_IDENTIFIER // CFA558 553 ; 559 554 … … 594 589 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 595 590 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 596 | type_name '.' no_attr_identifier// CFA, nested type591 | type_name '.' identifier // CFA, nested type 597 592 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 598 593 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector … … 647 642 | postfix_expression '(' argument_expression_list ')' 648 643 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 649 | postfix_expression '.' no_attr_identifier644 | postfix_expression '.' identifier 650 645 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 651 646 | postfix_expression '.' INTEGERconstant // CFA, tuple index … … 655 650 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 656 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 657 | postfix_expression ARROW no_attr_identifier652 | postfix_expression ARROW identifier 658 653 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 659 654 | postfix_expression ARROW INTEGERconstant // CFA, tuple index … … 718 713 | FLOATINGconstant fraction_constants_opt 719 714 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 720 | no_attr_identifier fraction_constants_opt715 | identifier fraction_constants_opt 721 716 { 722 717 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 776 771 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 777 772 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } 778 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'773 | OFFSETOF '(' type_no_function ',' identifier ')' 779 774 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 780 | ATTR_IDENTIFIER781 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ) ) ); }782 | ATTR_IDENTIFIER '(' argument_expression ')'783 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }784 | ATTR_IDENTIFIER '(' type ')'785 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuildType( $3 ) ) ); }786 775 ; 787 776 … … 1018 1007 1019 1008 labeled_statement: 1020 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER1009 // labels cannot be identifiers 0 or 1 1021 1010 identifier_or_type_name ':' attribute_list_opt statement 1022 1011 { $$ = $4->add_label( $1, $3 ); } … … 1386 1375 | type_specifier_nobody variable_abstract_declarator 1387 1376 { $$ = $2->addType( $1 ); } 1388 | cfa_abstract_declarator_tuple no_attr_identifier// CFA1377 | cfa_abstract_declarator_tuple identifier // CFA 1389 1378 { $$ = $1->addName( $2 ); } 1390 1379 | cfa_abstract_declarator_tuple // CFA … … 1450 1439 1451 1440 label_list: 1452 no_attr_identifier1441 identifier 1453 1442 { 1454 1443 $$ = new LabelNode(); $$->labels.push_back( *$1 ); 1455 1444 delete $1; // allocated by lexer 1456 1445 } 1457 | label_list ',' no_attr_identifier1446 | label_list ',' identifier 1458 1447 { 1459 1448 $$ = $1; $1->labels.push_back( *$3 ); … … 1500 1489 1501 1490 local_label_list: // GCC, local label 1502 no_attr_identifier_or_type_name1503 | local_label_list ',' no_attr_identifier_or_type_name1491 identifier_or_type_name 1492 | local_label_list ',' identifier_or_type_name 1504 1493 ; 1505 1494 … … 1623 1612 $$ = $2->addTypedef(); 1624 1613 } 1625 | cfa_typedef_declaration pop ',' push no_attr_identifier1614 | cfa_typedef_declaration pop ',' push identifier 1626 1615 { 1627 1616 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); … … 1663 1652 typedef_expression: 1664 1653 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression 1665 TYPEDEF no_attr_identifier '=' assignment_expression1654 TYPEDEF identifier '=' assignment_expression 1666 1655 { 1667 1656 // $$ = DeclarationNode::newName( 0 ); // unimplemented 1668 1657 SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr; 1669 1658 } 1670 | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression1659 | typedef_expression pop ',' push identifier '=' assignment_expression 1671 1660 { 1672 1661 // $$ = DeclarationNode::newName( 0 ); // unimplemented … … 1871 1860 | VALIST // GCC, __builtin_va_list 1872 1861 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1862 | AUTO_TYPE 1863 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); } 1873 1864 ; 1874 1865 … … 1912 1903 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1913 1904 { $$ = DeclarationNode::newTypeof( $3, true ); } 1914 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type( x ) y;1915 { $$ = DeclarationNode::newAttr( $1, $3 ); }1916 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b ) y;1917 { $$ = DeclarationNode::newAttr( $1, $3 ); }1918 1905 | ZERO_T // CFA 1919 1906 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2024 2011 '{' field_declaration_list_opt '}' type_parameters_opt 2025 2012 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); } 2026 | aggregate_key attribute_list_opt no_attr_identifier fred2013 | aggregate_key attribute_list_opt identifier fred 2027 2014 { 2028 2015 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef … … 2050 2037 2051 2038 aggregate_type_nobody: // struct, union - {...} 2052 aggregate_key attribute_list_opt no_attr_identifier fred2039 aggregate_key attribute_list_opt identifier fred 2053 2040 { 2054 2041 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); … … 2151 2138 cfa_field_declaring_list: // CFA, new style field declaration 2152 2139 // bit-fields are handled by C declarations 2153 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name2140 cfa_abstract_declarator_tuple identifier_or_type_name 2154 2141 { $$ = $1->addName( $2 ); } 2155 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name2142 | cfa_field_declaring_list ',' identifier_or_type_name 2156 2143 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 2157 2144 ; … … 2178 2165 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2179 2166 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2180 | ENUM attribute_list_opt no_attr_identifier2167 | ENUM attribute_list_opt identifier 2181 2168 { typedefTable.makeTypedef( *$3 ); } 2182 2169 '{' enumerator_list comma_opt '}' … … 2189 2176 2190 2177 enum_type_nobody: // enum - {...} 2191 ENUM attribute_list_opt no_attr_identifier2178 ENUM attribute_list_opt identifier 2192 2179 { 2193 2180 typedefTable.makeTypedef( *$3 ); … … 2202 2189 2203 2190 enumerator_list: 2204 no_attr_identifier_or_type_name enumerator_value_opt2191 identifier_or_type_name enumerator_value_opt 2205 2192 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2206 | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt2193 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2207 2194 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2208 2195 ; … … 2312 2299 2313 2300 identifier_list: // K&R-style parameter list => no types 2314 no_attr_identifier2301 identifier 2315 2302 { $$ = DeclarationNode::newName( $1 ); } 2316 | identifier_list ',' no_attr_identifier2303 | identifier_list ',' identifier 2317 2304 { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); } 2318 2305 ; … … 2320 2307 identifier_or_type_name: 2321 2308 identifier 2322 | TYPEDEFname2323 | TYPEGENname2324 ;2325 2326 no_attr_identifier_or_type_name:2327 no_attr_identifier2328 2309 | TYPEDEFname 2329 2310 | TYPEGENname … … 2380 2361 designation: 2381 2362 designator_list ':' // C99, CFA uses ":" instead of "=" 2382 | no_attr_identifier ':'// GCC, field name2363 | identifier ':' // GCC, field name 2383 2364 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2384 2365 ; … … 2392 2373 2393 2374 designator: 2394 '.' no_attr_identifier// C99, field name2375 '.' identifier // C99, field name 2395 2376 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2396 2377 | '[' push assignment_expression pop ']' // C99, single array element … … 2437 2418 2438 2419 type_parameter: // CFA 2439 type_class no_attr_identifier_or_type_name2420 type_class identifier_or_type_name 2440 2421 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2441 2422 type_initializer_opt assertion_list_opt … … 2470 2451 2471 2452 assertion: // CFA 2472 '|' no_attr_identifier_or_type_name '(' type_list ')'2453 '|' identifier_or_type_name '(' type_list ')' 2473 2454 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2474 2455 | '|' '{' push trait_declaration_list pop '}' … … 2507 2488 2508 2489 type_declarator_name: // CFA 2509 no_attr_identifier_or_type_name2490 identifier_or_type_name 2510 2491 { 2511 2492 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2512 2493 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2513 2494 } 2514 | no_attr_identifier_or_type_name '(' type_parameter_list ')'2495 | identifier_or_type_name '(' type_parameter_list ')' 2515 2496 { 2516 2497 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); … … 2520 2501 2521 2502 trait_specifier: // CFA 2522 TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'2503 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2523 2504 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2524 | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'2505 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2525 2506 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2526 2507 ;
Note:
See TracChangeset
for help on using the changeset viewer.