Changeset 033ff37 for src/Parser/parser.yy
- Timestamp:
- Jul 26, 2019, 6:39:42 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- be53b87
- Parents:
- f673c13c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/parser.yy
rf673c13c r033ff37 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 25 15:49:52201913 // Update Count : 435 612 // Last Modified On : Thu Jul 25 22:31:38 2019 13 // Update Count : 4359 14 14 // 15 15 … … 289 289 %token<tok> IDENTIFIER QUOTED_IDENTIFIER TYPEDEFname TYPEGENname 290 290 %token<tok> TIMEOUT WOR 291 %token<tok> ATTR_IDENTIFIER ATTR_TYPEDEFname ATTR_TYPEGENname292 291 %token<tok> INTEGERconstant CHARACTERconstant STRINGliteral 293 292 %token<tok> DIRECTIVE … … 313 312 %token ATassign // @= 314 313 315 %type<tok> identifier no_attr_identifier316 %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 317 316 %type<tok> quasi_keyword 318 317 %type<constant> string_literal … … 547 546 ; 548 547 549 no_attr_identifier:548 identifier: 550 549 IDENTIFIER 551 550 | quasi_keyword 552 551 | '@' // CFA 553 552 { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; } 554 ;555 556 identifier:557 no_attr_identifier558 | ATTR_IDENTIFIER // CFA559 553 ; 560 554 … … 595 589 | '(' comma_expression ')' '`' IDENTIFIER // CFA, postfix call 596 590 { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); } 597 | type_name '.' no_attr_identifier// CFA, nested type591 | type_name '.' identifier // CFA, nested type 598 592 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; } 599 593 | type_name '.' '[' field_name_list ']' // CFA, nested type / tuple field selector … … 648 642 | postfix_expression '(' argument_expression_list ')' 649 643 { $$ = new ExpressionNode( build_func( $1, $3 ) ); } 650 | postfix_expression '.' no_attr_identifier644 | postfix_expression '.' identifier 651 645 { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); } 652 646 | postfix_expression '.' INTEGERconstant // CFA, tuple index … … 656 650 | postfix_expression '.' '[' field_name_list ']' // CFA, tuple field selector 657 651 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 658 | postfix_expression ARROW no_attr_identifier652 | postfix_expression ARROW identifier 659 653 { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); } 660 654 | postfix_expression ARROW INTEGERconstant // CFA, tuple index … … 719 713 | FLOATINGconstant fraction_constants_opt 720 714 { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); } 721 | no_attr_identifier fraction_constants_opt715 | identifier fraction_constants_opt 722 716 { 723 717 $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) ); … … 777 771 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 778 772 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } 779 | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'773 | OFFSETOF '(' type_no_function ',' identifier ')' 780 774 { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); } 781 | ATTR_IDENTIFIER782 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ) ) ); }783 | ATTR_IDENTIFIER '(' argument_expression ')'784 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuild< Expression >( $3 ) ) ); }785 | ATTR_IDENTIFIER '(' type ')'786 { $$ = new ExpressionNode( new AttrExpr( build_varref( $1 ), maybeMoveBuildType( $3 ) ) ); }787 775 ; 788 776 … … 1019 1007 1020 1008 labeled_statement: 1021 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER1009 // labels cannot be identifiers 0 or 1 1022 1010 identifier_or_type_name ':' attribute_list_opt statement 1023 1011 { $$ = $4->add_label( $1, $3 ); } … … 1387 1375 | type_specifier_nobody variable_abstract_declarator 1388 1376 { $$ = $2->addType( $1 ); } 1389 | cfa_abstract_declarator_tuple no_attr_identifier// CFA1377 | cfa_abstract_declarator_tuple identifier // CFA 1390 1378 { $$ = $1->addName( $2 ); } 1391 1379 | cfa_abstract_declarator_tuple // CFA … … 1451 1439 1452 1440 label_list: 1453 no_attr_identifier1441 identifier 1454 1442 { 1455 1443 $$ = new LabelNode(); $$->labels.push_back( *$1 ); 1456 1444 delete $1; // allocated by lexer 1457 1445 } 1458 | label_list ',' no_attr_identifier1446 | label_list ',' identifier 1459 1447 { 1460 1448 $$ = $1; $1->labels.push_back( *$3 ); … … 1501 1489 1502 1490 local_label_list: // GCC, local label 1503 no_attr_identifier_or_type_name1504 | local_label_list ',' no_attr_identifier_or_type_name1491 identifier_or_type_name 1492 | local_label_list ',' identifier_or_type_name 1505 1493 ; 1506 1494 … … 1624 1612 $$ = $2->addTypedef(); 1625 1613 } 1626 | cfa_typedef_declaration pop ',' push no_attr_identifier1614 | cfa_typedef_declaration pop ',' push identifier 1627 1615 { 1628 1616 typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" ); … … 1664 1652 typedef_expression: 1665 1653 // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression 1666 TYPEDEF no_attr_identifier '=' assignment_expression1654 TYPEDEF identifier '=' assignment_expression 1667 1655 { 1668 1656 // $$ = DeclarationNode::newName( 0 ); // unimplemented 1669 1657 SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr; 1670 1658 } 1671 | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression1659 | typedef_expression pop ',' push identifier '=' assignment_expression 1672 1660 { 1673 1661 // $$ = DeclarationNode::newName( 0 ); // unimplemented … … 1915 1903 | BASETYPEOF '(' comma_expression ')' // CFA: basetypeof( a+b ) y; 1916 1904 { $$ = DeclarationNode::newTypeof( $3, true ); } 1917 | ATTR_TYPEGENname '(' type ')' // CFA: e.g., @type( x ) y;1918 { $$ = DeclarationNode::newAttr( $1, $3 ); }1919 | ATTR_TYPEGENname '(' comma_expression ')' // CFA: e.g., @type( a+b ) y;1920 { $$ = DeclarationNode::newAttr( $1, $3 ); }1921 1905 | ZERO_T // CFA 1922 1906 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); } … … 2027 2011 '{' field_declaration_list_opt '}' type_parameters_opt 2028 2012 { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); } 2029 | aggregate_key attribute_list_opt no_attr_identifier fred2013 | aggregate_key attribute_list_opt identifier fred 2030 2014 { 2031 2015 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef … … 2053 2037 2054 2038 aggregate_type_nobody: // struct, union - {...} 2055 aggregate_key attribute_list_opt no_attr_identifier fred2039 aggregate_key attribute_list_opt identifier fred 2056 2040 { 2057 2041 typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); … … 2154 2138 cfa_field_declaring_list: // CFA, new style field declaration 2155 2139 // bit-fields are handled by C declarations 2156 cfa_abstract_declarator_tuple no_attr_identifier_or_type_name2140 cfa_abstract_declarator_tuple identifier_or_type_name 2157 2141 { $$ = $1->addName( $2 ); } 2158 | cfa_field_declaring_list ',' no_attr_identifier_or_type_name2142 | cfa_field_declaring_list ',' identifier_or_type_name 2159 2143 { $$ = $1->appendList( $1->cloneType( $3 ) ); } 2160 2144 ; … … 2181 2165 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2182 2166 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 2183 | ENUM attribute_list_opt no_attr_identifier2167 | ENUM attribute_list_opt identifier 2184 2168 { typedefTable.makeTypedef( *$3 ); } 2185 2169 '{' enumerator_list comma_opt '}' … … 2192 2176 2193 2177 enum_type_nobody: // enum - {...} 2194 ENUM attribute_list_opt no_attr_identifier2178 ENUM attribute_list_opt identifier 2195 2179 { 2196 2180 typedefTable.makeTypedef( *$3 ); … … 2205 2189 2206 2190 enumerator_list: 2207 no_attr_identifier_or_type_name enumerator_value_opt2191 identifier_or_type_name enumerator_value_opt 2208 2192 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); } 2209 | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt2193 | enumerator_list ',' identifier_or_type_name enumerator_value_opt 2210 2194 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); } 2211 2195 ; … … 2315 2299 2316 2300 identifier_list: // K&R-style parameter list => no types 2317 no_attr_identifier2301 identifier 2318 2302 { $$ = DeclarationNode::newName( $1 ); } 2319 | identifier_list ',' no_attr_identifier2303 | identifier_list ',' identifier 2320 2304 { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); } 2321 2305 ; … … 2323 2307 identifier_or_type_name: 2324 2308 identifier 2325 | TYPEDEFname2326 | TYPEGENname2327 ;2328 2329 no_attr_identifier_or_type_name:2330 no_attr_identifier2331 2309 | TYPEDEFname 2332 2310 | TYPEGENname … … 2383 2361 designation: 2384 2362 designator_list ':' // C99, CFA uses ":" instead of "=" 2385 | no_attr_identifier ':'// GCC, field name2363 | identifier ':' // GCC, field name 2386 2364 { $$ = new ExpressionNode( build_varref( $1 ) ); } 2387 2365 ; … … 2395 2373 2396 2374 designator: 2397 '.' no_attr_identifier// C99, field name2375 '.' identifier // C99, field name 2398 2376 { $$ = new ExpressionNode( build_varref( $2 ) ); } 2399 2377 | '[' push assignment_expression pop ']' // C99, single array element … … 2440 2418 2441 2419 type_parameter: // CFA 2442 type_class no_attr_identifier_or_type_name2420 type_class identifier_or_type_name 2443 2421 { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); } 2444 2422 type_initializer_opt assertion_list_opt … … 2473 2451 2474 2452 assertion: // CFA 2475 '|' no_attr_identifier_or_type_name '(' type_list ')'2453 '|' identifier_or_type_name '(' type_list ')' 2476 2454 { $$ = DeclarationNode::newTraitUse( $2, $4 ); } 2477 2455 | '|' '{' push trait_declaration_list pop '}' … … 2510 2488 2511 2489 type_declarator_name: // CFA 2512 no_attr_identifier_or_type_name2490 identifier_or_type_name 2513 2491 { 2514 2492 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2515 2493 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2516 2494 } 2517 | no_attr_identifier_or_type_name '(' type_parameter_list ')'2495 | identifier_or_type_name '(' type_parameter_list ')' 2518 2496 { 2519 2497 typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" ); … … 2523 2501 2524 2502 trait_specifier: // CFA 2525 TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'2503 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2526 2504 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2527 | 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 '}' 2528 2506 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2529 2507 ;
Note: See TracChangeset
for help on using the changeset viewer.