Changes in src/Parser/parser.yy [f1da02c:757ffed]
- File:
-
- 1 edited
-
src/Parser/parser.yy (modified) (33 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rf1da02c r757ffed 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Aug 4 21:48:23201913 // Update Count : 43 6412 // Last Modified On : Sun Jul 14 07:54:30 2019 13 // Update Count : 4355 14 14 // 15 15 … … 268 268 %token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED 269 269 %token BOOL COMPLEX IMAGINARY // C99 270 %token INT128 UINT128 uuFLOAT80 uuFLOAT128// GCC270 %token INT128 uuFLOAT80 uuFLOAT128 // GCC 271 271 %token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC 272 272 %token ZERO_T ONE_T // CFA 273 273 %token VALIST // GCC 274 %token AUTO_TYPE // GCC275 274 %token TYPEOF BASETYPEOF LABEL // GCC 276 275 %token ENUM STRUCT UNION … … 289 288 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 290 289 %token<tok> TIMEOUT WOR 290 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname 291 291 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 292 292 %token<tok> DIRECTIVE … … 312 312 %token ATassign // @= 313 313 314 %type<tok> identifier 315 %type<tok> identifier_or_type_name attr_name314 %type<tok> identifier no_attr_identifier 315 %type<tok> identifier_or_type_name no_attr_identifier_or_type_name attr_name 316 316 %type<tok> quasi_keyword 317 317 %type<constant> string_literal … … 546 546 ; 547 547 548 identifier:548 no_attr_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_identifier 557 | ATTR_IDENTIFIER // CFA 553 558 ; 554 559 … … 589 594 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 590 595 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 591 | type_name '.' identifier// CFA, nested type596 | type_name '.' no_attr_identifier // CFA, nested type 592 597 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 593 598 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector … … 642 647 | postfix_expression '(' argument_expression_list ')' 643 648 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 644 | postfix_expression '.' identifier649 | postfix_expression '.' no_attr_identifier 645 650 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 646 651 | postfix_expression '.' INTEGERconstant // CFA, tuple index … … 650 655 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 651 656 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 652 | postfix_expression ARROW identifier657 | postfix_expression ARROW no_attr_identifier 653 658 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 654 659 | postfix_expression ARROW INTEGERconstant // CFA, tuple index … … 713 718 | FLOATINGconstant fraction_constants_opt 714 719 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 715 | identifier fraction_constants_opt720 | no_attr_identifier fraction_constants_opt 716 721 { 717 722 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 771 776 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 772 777 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } 773 | OFFSETOF '(' type_no_function ',' identifier ')'778 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')' 774 779 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 780 | ATTR_IDENTIFIER 781 { $$ = 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 ) ) ); } 775 786 ; 776 787 … … 1007 1018 1008 1019 labeled_statement: 1009 // labels cannot be identifiers 0 or 1 1020 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER 1010 1021 identifier_or_type_name ':' attribute_list_opt statement 1011 1022 { $$ = $4->add_label( $1, $3 ); } … … 1375 1386 | type_specifier_nobody variable_abstract_declarator 1376 1387 { $$ = $2->addType( $1 ); } 1377 | cfa_abstract_declarator_tuple identifier// CFA1388 | cfa_abstract_declarator_tuple no_attr_identifier // CFA 1378 1389 { $$ = $1->addName( $2 ); } 1379 1390 | cfa_abstract_declarator_tuple // CFA … … 1439 1450 1440 1451 label_list: 1441 identifier1452 no_attr_identifier 1442 1453 { 1443 1454 $$ = new LabelNode(); $$->labels.push_back( *$1 ); 1444 1455 delete $1; // allocated by lexer 1445 1456 } 1446 | label_list ',' identifier1457 | label_list ',' no_attr_identifier 1447 1458 { 1448 1459 $$ = $1; $1->labels.push_back( *$3 ); … … 1489 1500 1490 1501 local_label_list: // GCC, local label 1491 identifier_or_type_name1492 | local_label_list ',' identifier_or_type_name1502 no_attr_identifier_or_type_name 1503 | local_label_list ',' no_attr_identifier_or_type_name 1493 1504 ; 1494 1505 … … 1612 1623 $$ = $2->addTypedef(); 1613 1624 } 1614 | cfa_typedef_declaration pop ',' push identifier1625 | cfa_typedef_declaration pop ',' push no_attr_identifier 1615 1626 { 1616 1627 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); … … 1652 1663 typedef_expression: 1653 1664 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression 1654 TYPEDEF identifier '=' assignment_expression1665 TYPEDEF no_attr_identifier '=' assignment_expression 1655 1666 { 1656 1667 // $$ = DeclarationNode::newName( 0 ); // unimplemented 1657 1668 SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr; 1658 1669 } 1659 | typedef_expression pop ',' push identifier '=' assignment_expression1670 | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression 1660 1671 { 1661 1672 // $$ = DeclarationNode::newName( 0 ); // unimplemented … … 1826 1837 | INT128 1827 1838 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); } 1828 | UINT1281829 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ); }1830 1839 | FLOAT 1831 1840 { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); } … … 1862 1871 | VALIST // GCC, __builtin_va_list 1863 1872 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); } 1864 | AUTO_TYPE1865 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }1866 1873 ; 1867 1874 … … 1905 1912 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1906 1913 { $$ = 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 ); } 1907 1918 | ZERO_T // CFA 1908 1919 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2013 2024 '{' field_declaration_list_opt '}' type_parameters_opt 2014 2025 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); } 2015 | aggregate_key attribute_list_opt identifier fred2026 | aggregate_key attribute_list_opt no_attr_identifier fred 2016 2027 { 2017 2028 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef … … 2039 2050 2040 2051 aggregate_type_nobody: // struct, union - {...} 2041 aggregate_key attribute_list_opt identifier fred2052 aggregate_key attribute_list_opt no_attr_identifier fred 2042 2053 { 2043 2054 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); … … 2140 2151 cfa_field_declaring_list: // CFA, new style field declaration 2141 2152 // bit-fields are handled by C declarations 2142 cfa_abstract_declarator_tuple identifier_or_type_name2153 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name 2143 2154 { $$ = $1->addName( $2 ); } 2144 | cfa_field_declaring_list ',' identifier_or_type_name2155 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name 2145 2156 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 2146 2157 ; … … 2167 2178 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2168 2179 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2169 | ENUM attribute_list_opt identifier2180 | ENUM attribute_list_opt no_attr_identifier 2170 2181 { typedefTable.makeTypedef( *$3 ); } 2171 2182 '{' enumerator_list comma_opt '}' … … 2178 2189 2179 2190 enum_type_nobody: // enum - {...} 2180 ENUM attribute_list_opt identifier2191 ENUM attribute_list_opt no_attr_identifier 2181 2192 { 2182 2193 typedefTable.makeTypedef( *$3 ); … … 2191 2202 2192 2203 enumerator_list: 2193 identifier_or_type_name enumerator_value_opt2204 no_attr_identifier_or_type_name enumerator_value_opt 2194 2205 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2195 | enumerator_list ',' identifier_or_type_name enumerator_value_opt2206 | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt 2196 2207 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2197 2208 ; … … 2301 2312 2302 2313 identifier_list: // K&R-style parameter list => no types 2303 identifier2314 no_attr_identifier 2304 2315 { $$ = DeclarationNode::newName( $1 ); } 2305 | identifier_list ',' identifier2316 | identifier_list ',' no_attr_identifier 2306 2317 { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); } 2307 2318 ; … … 2309 2320 identifier_or_type_name: 2310 2321 identifier 2322 | TYPEDEFname 2323 | TYPEGENname 2324 ; 2325 2326 no_attr_identifier_or_type_name: 2327 no_attr_identifier 2311 2328 | TYPEDEFname 2312 2329 | TYPEGENname … … 2363 2380 designation: 2364 2381 designator_list ':' // C99, CFA uses ":" instead of "=" 2365 | identifier ':'// GCC, field name2382 | no_attr_identifier ':' // GCC, field name 2366 2383 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2367 2384 ; … … 2375 2392 2376 2393 designator: 2377 '.' identifier// C99, field name2394 '.' no_attr_identifier // C99, field name 2378 2395 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2379 2396 | '[' push assignment_expression pop ']' // C99, single array element … … 2420 2437 2421 2438 type_parameter: // CFA 2422 type_class identifier_or_type_name2439 type_class no_attr_identifier_or_type_name 2423 2440 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2424 2441 type_initializer_opt assertion_list_opt … … 2453 2470 2454 2471 assertion: // CFA 2455 '|' identifier_or_type_name '(' type_list ')'2472 '|' no_attr_identifier_or_type_name '(' type_list ')' 2456 2473 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2457 2474 | '|' '{' push trait_declaration_list pop '}' … … 2490 2507 2491 2508 type_declarator_name: // CFA 2492 identifier_or_type_name2509 no_attr_identifier_or_type_name 2493 2510 { 2494 2511 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2495 2512 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2496 2513 } 2497 | identifier_or_type_name '(' type_parameter_list ')'2514 | no_attr_identifier_or_type_name '(' type_parameter_list ')' 2498 2515 { 2499 2516 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); … … 2503 2520 2504 2521 trait_specifier: // CFA 2505 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'2522 TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2506 2523 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2507 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}'2524 | TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2508 2525 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2509 2526 ;
Note:
See TracChangeset
for help on using the changeset viewer.