Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rf1da02c r757ffed  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  4 21:48:23 2019
    13 // Update Count     : 4364
     12// Last Modified On : Sun Jul 14 07:54:30 2019
     13// Update Count     : 4355
    1414//
    1515
     
    268268%token VOID CHAR SHORT INT LONG FLOAT DOUBLE SIGNED UNSIGNED
    269269%token BOOL COMPLEX IMAGINARY                                                   // C99
    270 %token INT128 UINT128 uuFLOAT80 uuFLOAT128                              // GCC
     270%token INT128 uuFLOAT80 uuFLOAT128                                              // GCC
    271271%token uFLOAT16 uFLOAT32 uFLOAT32X uFLOAT64 uFLOAT64X uFLOAT128 // GCC
    272272%token ZERO_T ONE_T                                                                             // CFA
    273273%token VALIST                                                                                   // GCC
    274 %token AUTO_TYPE                                                                                // GCC
    275274%token TYPEOF BASETYPEOF LABEL                                                  // GCC
    276275%token ENUM STRUCT UNION
     
    289288%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    290289%token<tok> TIMEOUT                             WOR
     290%token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    291291%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
    292292%token<tok> DIRECTIVE
     
    312312%token ATassign                                                                                 // @=
    313313
    314 %type<tok> identifier
    315 %type<tok> identifier_or_type_name  attr_name
     314%type<tok> identifier  no_attr_identifier
     315%type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
    316316%type<tok> quasi_keyword
    317317%type<constant> string_literal
     
    546546        ;
    547547
    548 identifier:
     548no_attr_identifier:
    549549        IDENTIFIER
    550550        | quasi_keyword
    551551        | '@'                                                                                           // CFA
    552552                { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; }
     553        ;
     554
     555identifier:
     556        no_attr_identifier
     557        | ATTR_IDENTIFIER                                                                       // CFA
    553558        ;
    554559
     
    589594        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    590595                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    591         | type_name '.' identifier                                                      // CFA, nested type
     596        | type_name '.' no_attr_identifier                                      // CFA, nested type
    592597                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    593598        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
     
    642647        | postfix_expression '(' argument_expression_list ')'
    643648                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    644         | postfix_expression '.' identifier
     649        | postfix_expression '.' no_attr_identifier
    645650                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    646651        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
     
    650655        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    651656                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    652         | postfix_expression ARROW identifier
     657        | postfix_expression ARROW no_attr_identifier
    653658                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    654659        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
     
    713718        | FLOATINGconstant fraction_constants_opt
    714719                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    715         | identifier fraction_constants_opt
     720        | no_attr_identifier fraction_constants_opt
    716721                {
    717722                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    771776        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    772777                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
    773         | OFFSETOF '(' type_no_function ',' identifier ')'
     778        | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
    774779                { $$ = 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 ) ) ); }
    775786        ;
    776787
     
    10071018
    10081019labeled_statement:
    1009                 // labels cannot be identifiers 0 or 1
     1020                // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER
    10101021        identifier_or_type_name ':' attribute_list_opt statement
    10111022                { $$ = $4->add_label( $1, $3 ); }
     
    13751386        | type_specifier_nobody variable_abstract_declarator
    13761387                { $$ = $2->addType( $1 ); }
    1377         | cfa_abstract_declarator_tuple identifier                      // CFA
     1388        | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
    13781389                { $$ = $1->addName( $2 ); }
    13791390        | cfa_abstract_declarator_tuple                                         // CFA
     
    14391450
    14401451label_list:
    1441         identifier
     1452        no_attr_identifier
    14421453                {
    14431454                        $$ = new LabelNode(); $$->labels.push_back( *$1 );
    14441455                        delete $1;                                                                      // allocated by lexer
    14451456                }
    1446         | label_list ',' identifier
     1457        | label_list ',' no_attr_identifier
    14471458                {
    14481459                        $$ = $1; $1->labels.push_back( *$3 );
     
    14891500
    14901501local_label_list:                                                                               // GCC, local label
    1491         identifier_or_type_name
    1492         | local_label_list ',' identifier_or_type_name
     1502        no_attr_identifier_or_type_name
     1503        | local_label_list ',' no_attr_identifier_or_type_name
    14931504        ;
    14941505
     
    16121623                        $$ = $2->addTypedef();
    16131624                }
    1614         | cfa_typedef_declaration pop ',' push identifier
     1625        | cfa_typedef_declaration pop ',' push no_attr_identifier
    16151626                {
    16161627                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
     
    16521663typedef_expression:
    16531664                // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    1654         TYPEDEF identifier '=' assignment_expression
     1665        TYPEDEF no_attr_identifier '=' assignment_expression
    16551666                {
    16561667                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    16571668                        SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
    16581669                }
    1659         | typedef_expression pop ',' push identifier '=' assignment_expression
     1670        | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression
    16601671                {
    16611672                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
     
    18261837        | INT128
    18271838                { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 ); }
    1828         | UINT128
    1829                 { $$ = DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ); }
    18301839        | FLOAT
    18311840                { $$ = DeclarationNode::newBasicType( DeclarationNode::Float ); }
     
    18621871        | VALIST                                                                                        // GCC, __builtin_va_list
    18631872                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
    1864         | AUTO_TYPE
    1865                 { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }
    18661873        ;
    18671874
     
    19051912        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
    19061913                { $$ = 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 ); }
    19071918        | ZERO_T                                                                                        // CFA
    19081919                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     
    20132024          '{' field_declaration_list_opt '}' type_parameters_opt
    20142025                { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); }
    2015         | aggregate_key attribute_list_opt identifier fred
     2026        | aggregate_key attribute_list_opt no_attr_identifier fred
    20162027                {
    20172028                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     
    20392050
    20402051aggregate_type_nobody:                                                                  // struct, union - {...}
    2041         aggregate_key attribute_list_opt identifier fred
     2052        aggregate_key attribute_list_opt no_attr_identifier fred
    20422053                {
    20432054                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
     
    21402151cfa_field_declaring_list:                                                               // CFA, new style field declaration
    21412152        // bit-fields are handled by C declarations
    2142         cfa_abstract_declarator_tuple identifier_or_type_name
     2153        cfa_abstract_declarator_tuple no_attr_identifier_or_type_name
    21432154                { $$ = $1->addName( $2 ); }
    2144         | cfa_field_declaring_list ',' identifier_or_type_name
     2155        | cfa_field_declaring_list ',' no_attr_identifier_or_type_name
    21452156                { $$ = $1->appendList( $1->cloneType( $3 ) ); }
    21462157        ;
     
    21672178        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    21682179                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2169         | ENUM attribute_list_opt identifier
     2180        | ENUM attribute_list_opt no_attr_identifier
    21702181                { typedefTable.makeTypedef( *$3 ); }
    21712182          '{' enumerator_list comma_opt '}'
     
    21782189
    21792190enum_type_nobody:                                                                               // enum - {...}
    2180         ENUM attribute_list_opt identifier
     2191        ENUM attribute_list_opt no_attr_identifier
    21812192                {
    21822193                        typedefTable.makeTypedef( *$3 );
     
    21912202
    21922203enumerator_list:
    2193         identifier_or_type_name enumerator_value_opt
     2204        no_attr_identifier_or_type_name enumerator_value_opt
    21942205                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    2195         | enumerator_list ',' identifier_or_type_name enumerator_value_opt
     2206        | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt
    21962207                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    21972208        ;
     
    23012312
    23022313identifier_list:                                                                                // K&R-style parameter list => no types
    2303         identifier
     2314        no_attr_identifier
    23042315                { $$ = DeclarationNode::newName( $1 ); }
    2305         | identifier_list ',' identifier
     2316        | identifier_list ',' no_attr_identifier
    23062317                { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); }
    23072318        ;
     
    23092320identifier_or_type_name:
    23102321        identifier
     2322        | TYPEDEFname
     2323        | TYPEGENname
     2324        ;
     2325
     2326no_attr_identifier_or_type_name:
     2327        no_attr_identifier
    23112328        | TYPEDEFname
    23122329        | TYPEGENname
     
    23632380designation:
    23642381        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    2365         | identifier ':'                                                                        // GCC, field name
     2382        | no_attr_identifier ':'                                                        // GCC, field name
    23662383                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    23672384        ;
     
    23752392
    23762393designator:
    2377         '.' identifier                                                                          // C99, field name
     2394        '.' no_attr_identifier                                                          // C99, field name
    23782395                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    23792396        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    24202437
    24212438type_parameter:                                                                                 // CFA
    2422         type_class identifier_or_type_name
     2439        type_class no_attr_identifier_or_type_name
    24232440                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    24242441          type_initializer_opt assertion_list_opt
     
    24532470
    24542471assertion:                                                                                              // CFA
    2455         '|' identifier_or_type_name '(' type_list ')'
     2472        '|' no_attr_identifier_or_type_name '(' type_list ')'
    24562473                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    24572474        | '|' '{' push trait_declaration_list pop '}'
     
    24902507
    24912508type_declarator_name:                                                                   // CFA
    2492         identifier_or_type_name
     2509        no_attr_identifier_or_type_name
    24932510                {
    24942511                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    24952512                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    24962513                }
    2497         | identifier_or_type_name '(' type_parameter_list ')'
     2514        | no_attr_identifier_or_type_name '(' type_parameter_list ')'
    24982515                {
    24992516                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
     
    25032520
    25042521trait_specifier:                                                                                // CFA
    2505         TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
     2522        TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    25062523                { $$ = 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 '}'
    25082525                { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
    25092526        ;
Note: See TracChangeset for help on using the changeset viewer.