Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r757ffed r033ff37  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul 14 07:54:30 2019
    13 // Update Count     : 4355
     12// Last Modified On : Thu Jul 25 22:31:38 2019
     13// Update Count     : 4359
    1414//
    1515
     
    272272%token ZERO_T ONE_T                                                                             // CFA
    273273%token VALIST                                                                                   // GCC
     274%token AUTO_TYPE                                                                                // GCC
    274275%token TYPEOF BASETYPEOF LABEL                                                  // GCC
    275276%token ENUM STRUCT UNION
     
    288289%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    289290%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  no_attr_identifier
    315 %type<tok> identifier_or_type_name  no_attr_identifier_or_type_name  attr_name
     314%type<tok> identifier
     315%type<tok> identifier_or_type_name  attr_name
    316316%type<tok> quasi_keyword
    317317%type<constant> string_literal
     
    546546        ;
    547547
    548 no_attr_identifier:
     548identifier:
    549549        IDENTIFIER
    550550        | quasi_keyword
    551551        | '@'                                                                                           // CFA
    552552                { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; }
    553         ;
    554 
    555 identifier:
    556         no_attr_identifier
    557         | ATTR_IDENTIFIER                                                                       // CFA
    558553        ;
    559554
     
    594589        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    595590                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    596         | type_name '.' no_attr_identifier                                      // CFA, nested type
     591        | type_name '.' identifier                                                      // CFA, nested type
    597592                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    598593        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
     
    647642        | postfix_expression '(' argument_expression_list ')'
    648643                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    649         | postfix_expression '.' no_attr_identifier
     644        | postfix_expression '.' identifier
    650645                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    651646        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
     
    655650        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    656651                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    657         | postfix_expression ARROW no_attr_identifier
     652        | postfix_expression ARROW identifier
    658653                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    659654        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
     
    718713        | FLOATINGconstant fraction_constants_opt
    719714                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    720         | no_attr_identifier fraction_constants_opt
     715        | identifier fraction_constants_opt
    721716                {
    722717                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    776771        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    777772                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
    778         | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     773        | OFFSETOF '(' type_no_function ',' identifier ')'
    779774                { $$ = 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 ) ) ); }
    786775        ;
    787776
     
    10181007
    10191008labeled_statement:
    1020                 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER
     1009                // labels cannot be identifiers 0 or 1
    10211010        identifier_or_type_name ':' attribute_list_opt statement
    10221011                { $$ = $4->add_label( $1, $3 ); }
     
    13861375        | type_specifier_nobody variable_abstract_declarator
    13871376                { $$ = $2->addType( $1 ); }
    1388         | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
     1377        | cfa_abstract_declarator_tuple identifier                      // CFA
    13891378                { $$ = $1->addName( $2 ); }
    13901379        | cfa_abstract_declarator_tuple                                         // CFA
     
    14501439
    14511440label_list:
    1452         no_attr_identifier
     1441        identifier
    14531442                {
    14541443                        $$ = new LabelNode(); $$->labels.push_back( *$1 );
    14551444                        delete $1;                                                                      // allocated by lexer
    14561445                }
    1457         | label_list ',' no_attr_identifier
     1446        | label_list ',' identifier
    14581447                {
    14591448                        $$ = $1; $1->labels.push_back( *$3 );
     
    15001489
    15011490local_label_list:                                                                               // GCC, local label
    1502         no_attr_identifier_or_type_name
    1503         | local_label_list ',' no_attr_identifier_or_type_name
     1491        identifier_or_type_name
     1492        | local_label_list ',' identifier_or_type_name
    15041493        ;
    15051494
     
    16231612                        $$ = $2->addTypedef();
    16241613                }
    1625         | cfa_typedef_declaration pop ',' push no_attr_identifier
     1614        | cfa_typedef_declaration pop ',' push identifier
    16261615                {
    16271616                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
     
    16631652typedef_expression:
    16641653                // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    1665         TYPEDEF no_attr_identifier '=' assignment_expression
     1654        TYPEDEF identifier '=' assignment_expression
    16661655                {
    16671656                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    16681657                        SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
    16691658                }
    1670         | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression
     1659        | typedef_expression pop ',' push identifier '=' assignment_expression
    16711660                {
    16721661                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
     
    18711860        | VALIST                                                                                        // GCC, __builtin_va_list
    18721861                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Valist ); }
     1862        | AUTO_TYPE
     1863                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::AutoType ); }
    18731864        ;
    18741865
     
    19121903        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
    19131904                { $$ = 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 ); }
    19181905        | ZERO_T                                                                                        // CFA
    19191906                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     
    20242011          '{' field_declaration_list_opt '}' type_parameters_opt
    20252012                { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); }
    2026         | aggregate_key attribute_list_opt no_attr_identifier fred
     2013        | aggregate_key attribute_list_opt identifier fred
    20272014                {
    20282015                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     
    20502037
    20512038aggregate_type_nobody:                                                                  // struct, union - {...}
    2052         aggregate_key attribute_list_opt no_attr_identifier fred
     2039        aggregate_key attribute_list_opt identifier fred
    20532040                {
    20542041                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
     
    21512138cfa_field_declaring_list:                                                               // CFA, new style field declaration
    21522139        // bit-fields are handled by C declarations
    2153         cfa_abstract_declarator_tuple no_attr_identifier_or_type_name
     2140        cfa_abstract_declarator_tuple identifier_or_type_name
    21542141                { $$ = $1->addName( $2 ); }
    2155         | cfa_field_declaring_list ',' no_attr_identifier_or_type_name
     2142        | cfa_field_declaring_list ',' identifier_or_type_name
    21562143                { $$ = $1->appendList( $1->cloneType( $3 ) ); }
    21572144        ;
     
    21782165        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    21792166                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2180         | ENUM attribute_list_opt no_attr_identifier
     2167        | ENUM attribute_list_opt identifier
    21812168                { typedefTable.makeTypedef( *$3 ); }
    21822169          '{' enumerator_list comma_opt '}'
     
    21892176
    21902177enum_type_nobody:                                                                               // enum - {...}
    2191         ENUM attribute_list_opt no_attr_identifier
     2178        ENUM attribute_list_opt identifier
    21922179                {
    21932180                        typedefTable.makeTypedef( *$3 );
     
    22022189
    22032190enumerator_list:
    2204         no_attr_identifier_or_type_name enumerator_value_opt
     2191        identifier_or_type_name enumerator_value_opt
    22052192                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    2206         | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt
     2193        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    22072194                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    22082195        ;
     
    23122299
    23132300identifier_list:                                                                                // K&R-style parameter list => no types
    2314         no_attr_identifier
     2301        identifier
    23152302                { $$ = DeclarationNode::newName( $1 ); }
    2316         | identifier_list ',' no_attr_identifier
     2303        | identifier_list ',' identifier
    23172304                { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); }
    23182305        ;
     
    23202307identifier_or_type_name:
    23212308        identifier
    2322         | TYPEDEFname
    2323         | TYPEGENname
    2324         ;
    2325 
    2326 no_attr_identifier_or_type_name:
    2327         no_attr_identifier
    23282309        | TYPEDEFname
    23292310        | TYPEGENname
     
    23802361designation:
    23812362        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    2382         | no_attr_identifier ':'                                                        // GCC, field name
     2363        | identifier ':'                                                                        // GCC, field name
    23832364                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    23842365        ;
     
    23922373
    23932374designator:
    2394         '.' no_attr_identifier                                                          // C99, field name
     2375        '.' identifier                                                                          // C99, field name
    23952376                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    23962377        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    24372418
    24382419type_parameter:                                                                                 // CFA
    2439         type_class no_attr_identifier_or_type_name
     2420        type_class identifier_or_type_name
    24402421                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    24412422          type_initializer_opt assertion_list_opt
     
    24702451
    24712452assertion:                                                                                              // CFA
    2472         '|' no_attr_identifier_or_type_name '(' type_list ')'
     2453        '|' identifier_or_type_name '(' type_list ')'
    24732454                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    24742455        | '|' '{' push trait_declaration_list pop '}'
     
    25072488
    25082489type_declarator_name:                                                                   // CFA
    2509         no_attr_identifier_or_type_name
     2490        identifier_or_type_name
    25102491                {
    25112492                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    25122493                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    25132494                }
    2514         | no_attr_identifier_or_type_name '(' type_parameter_list ')'
     2495        | identifier_or_type_name '(' type_parameter_list ')'
    25152496                {
    25162497                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
     
    25202501
    25212502trait_specifier:                                                                                // CFA
    2522         TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'
     2503        TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    25232504                { $$ = 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 '}'
    25252506                { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
    25262507        ;
Note: See TracChangeset for help on using the changeset viewer.