Ignore:
Timestamp:
Jul 26, 2019, 6:39:42 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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
Message:

remove attribute expression '@'name mechanism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rf673c13c r033ff37  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul 25 15:49:52 2019
    13 // Update Count     : 4356
     12// Last Modified On : Thu Jul 25 22:31:38 2019
     13// Update Count     : 4359
    1414//
    1515
     
    289289%token<tok> IDENTIFIER                  QUOTED_IDENTIFIER               TYPEDEFname                             TYPEGENname
    290290%token<tok> TIMEOUT                             WOR
    291 %token<tok> ATTR_IDENTIFIER             ATTR_TYPEDEFname                ATTR_TYPEGENname
    292291%token<tok> INTEGERconstant             CHARACTERconstant               STRINGliteral
    293292%token<tok> DIRECTIVE
     
    313312%token ATassign                                                                                 // @=
    314313
    315 %type<tok> identifier  no_attr_identifier
    316 %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
    317316%type<tok> quasi_keyword
    318317%type<constant> string_literal
     
    547546        ;
    548547
    549 no_attr_identifier:
     548identifier:
    550549        IDENTIFIER
    551550        | quasi_keyword
    552551        | '@'                                                                                           // CFA
    553552                { Token tok = { new string( DeclarationNode::anonymous.newName() ), yylval.tok.loc }; $$ = tok; }
    554         ;
    555 
    556 identifier:
    557         no_attr_identifier
    558         | ATTR_IDENTIFIER                                                                       // CFA
    559553        ;
    560554
     
    595589        | '(' comma_expression ')' '`' IDENTIFIER                       // CFA, postfix call
    596590                { $$ = new ExpressionNode( build_func( new ExpressionNode( build_postfix_name( $5 ) ), $2 ) ); }
    597         | type_name '.' no_attr_identifier                                      // CFA, nested type
     591        | type_name '.' identifier                                                      // CFA, nested type
    598592                { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }
    599593        | type_name '.' '[' field_name_list ']'                         // CFA, nested type / tuple field selector
     
    648642        | postfix_expression '(' argument_expression_list ')'
    649643                { $$ = new ExpressionNode( build_func( $1, $3 ) ); }
    650         | postfix_expression '.' no_attr_identifier
     644        | postfix_expression '.' identifier
    651645                { $$ = new ExpressionNode( build_fieldSel( $1, build_varref( $3 ) ) ); }
    652646        | postfix_expression '.' INTEGERconstant                        // CFA, tuple index
     
    656650        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    657651                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    658         | postfix_expression ARROW no_attr_identifier
     652        | postfix_expression ARROW identifier
    659653                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
    660654        | postfix_expression ARROW INTEGERconstant                      // CFA, tuple index
     
    719713        | FLOATINGconstant fraction_constants_opt
    720714                { $$ = new ExpressionNode( build_field_name_fraction_constants( build_field_name_FLOATINGconstant( *$1 ), $2 ) ); }
    721         | no_attr_identifier fraction_constants_opt
     715        | identifier fraction_constants_opt
    722716                {
    723717                        $$ = new ExpressionNode( build_field_name_fraction_constants( build_varref( $1 ), $2 ) );
     
    777771        | ALIGNOF '(' type_no_function ')'                                      // GCC, type alignment
    778772                { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); }
    779         | OFFSETOF '(' type_no_function ',' no_attr_identifier ')'
     773        | OFFSETOF '(' type_no_function ',' identifier ')'
    780774                { $$ = new ExpressionNode( build_offsetOf( $3, build_varref( $5 ) ) ); }
    781         | ATTR_IDENTIFIER
    782                 { $$ = 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 ) ) ); }
    787775        ;
    788776
     
    10191007
    10201008labeled_statement:
    1021                 // labels cannot be identifiers 0 or 1 or ATTR_IDENTIFIER
     1009                // labels cannot be identifiers 0 or 1
    10221010        identifier_or_type_name ':' attribute_list_opt statement
    10231011                { $$ = $4->add_label( $1, $3 ); }
     
    13871375        | type_specifier_nobody variable_abstract_declarator
    13881376                { $$ = $2->addType( $1 ); }
    1389         | cfa_abstract_declarator_tuple no_attr_identifier      // CFA
     1377        | cfa_abstract_declarator_tuple identifier                      // CFA
    13901378                { $$ = $1->addName( $2 ); }
    13911379        | cfa_abstract_declarator_tuple                                         // CFA
     
    14511439
    14521440label_list:
    1453         no_attr_identifier
     1441        identifier
    14541442                {
    14551443                        $$ = new LabelNode(); $$->labels.push_back( *$1 );
    14561444                        delete $1;                                                                      // allocated by lexer
    14571445                }
    1458         | label_list ',' no_attr_identifier
     1446        | label_list ',' identifier
    14591447                {
    14601448                        $$ = $1; $1->labels.push_back( *$3 );
     
    15011489
    15021490local_label_list:                                                                               // GCC, local label
    1503         no_attr_identifier_or_type_name
    1504         | local_label_list ',' no_attr_identifier_or_type_name
     1491        identifier_or_type_name
     1492        | local_label_list ',' identifier_or_type_name
    15051493        ;
    15061494
     
    16241612                        $$ = $2->addTypedef();
    16251613                }
    1626         | cfa_typedef_declaration pop ',' push no_attr_identifier
     1614        | cfa_typedef_declaration pop ',' push identifier
    16271615                {
    16281616                        typedefTable.addToEnclosingScope( *$5, TYPEDEFname, "3" );
     
    16641652typedef_expression:
    16651653                // GCC, naming expression type: typedef name = exp; gives a name to the type of an expression
    1666         TYPEDEF no_attr_identifier '=' assignment_expression
     1654        TYPEDEF identifier '=' assignment_expression
    16671655                {
    16681656                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
    16691657                        SemanticError( yylloc, "Typedef expression is currently unimplemented." ); $$ = nullptr;
    16701658                }
    1671         | typedef_expression pop ',' push no_attr_identifier '=' assignment_expression
     1659        | typedef_expression pop ',' push identifier '=' assignment_expression
    16721660                {
    16731661                        // $$ = DeclarationNode::newName( 0 );                  // unimplemented
     
    19151903        | BASETYPEOF '(' comma_expression ')'                           // CFA: basetypeof( a+b ) y;
    19161904                { $$ = 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 ); }
    19211905        | ZERO_T                                                                                        // CFA
    19221906                { $$ = DeclarationNode::newBuiltinType( DeclarationNode::Zero ); }
     
    20272011          '{' field_declaration_list_opt '}' type_parameters_opt
    20282012                { $$ = DeclarationNode::newAggregate( $1, nullptr, $7, $5, true )->addQualifiers( $2 ); }
    2029         | aggregate_key attribute_list_opt no_attr_identifier fred
     2013        | aggregate_key attribute_list_opt identifier fred
    20302014                {
    20312015                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname ); // create typedef
     
    20532037
    20542038aggregate_type_nobody:                                                                  // struct, union - {...}
    2055         aggregate_key attribute_list_opt no_attr_identifier fred
     2039        aggregate_key attribute_list_opt identifier fred
    20562040                {
    20572041                        typedefTable.makeTypedef( *$3, forall || typedefTable.getEnclForall() ? TYPEGENname : TYPEDEFname );
     
    21542138cfa_field_declaring_list:                                                               // CFA, new style field declaration
    21552139        // bit-fields are handled by C declarations
    2156         cfa_abstract_declarator_tuple no_attr_identifier_or_type_name
     2140        cfa_abstract_declarator_tuple identifier_or_type_name
    21572141                { $$ = $1->addName( $2 ); }
    2158         | cfa_field_declaring_list ',' no_attr_identifier_or_type_name
     2142        | cfa_field_declaring_list ',' identifier_or_type_name
    21592143                { $$ = $1->appendList( $1->cloneType( $3 ) ); }
    21602144        ;
     
    21812165        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    21822166                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
    2183         | ENUM attribute_list_opt no_attr_identifier
     2167        | ENUM attribute_list_opt identifier
    21842168                { typedefTable.makeTypedef( *$3 ); }
    21852169          '{' enumerator_list comma_opt '}'
     
    21922176
    21932177enum_type_nobody:                                                                               // enum - {...}
    2194         ENUM attribute_list_opt no_attr_identifier
     2178        ENUM attribute_list_opt identifier
    21952179                {
    21962180                        typedefTable.makeTypedef( *$3 );
     
    22052189
    22062190enumerator_list:
    2207         no_attr_identifier_or_type_name enumerator_value_opt
     2191        identifier_or_type_name enumerator_value_opt
    22082192                { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
    2209         | enumerator_list ',' no_attr_identifier_or_type_name enumerator_value_opt
     2193        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    22102194                { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
    22112195        ;
     
    23152299
    23162300identifier_list:                                                                                // K&R-style parameter list => no types
    2317         no_attr_identifier
     2301        identifier
    23182302                { $$ = DeclarationNode::newName( $1 ); }
    2319         | identifier_list ',' no_attr_identifier
     2303        | identifier_list ',' identifier
    23202304                { $$ = $1->appendList( DeclarationNode::newName( $3 ) ); }
    23212305        ;
     
    23232307identifier_or_type_name:
    23242308        identifier
    2325         | TYPEDEFname
    2326         | TYPEGENname
    2327         ;
    2328 
    2329 no_attr_identifier_or_type_name:
    2330         no_attr_identifier
    23312309        | TYPEDEFname
    23322310        | TYPEGENname
     
    23832361designation:
    23842362        designator_list ':'                                                                     // C99, CFA uses ":" instead of "="
    2385         | no_attr_identifier ':'                                                        // GCC, field name
     2363        | identifier ':'                                                                        // GCC, field name
    23862364                { $$ = new ExpressionNode( build_varref( $1 ) ); }
    23872365        ;
     
    23952373
    23962374designator:
    2397         '.' no_attr_identifier                                                          // C99, field name
     2375        '.' identifier                                                                          // C99, field name
    23982376                { $$ = new ExpressionNode( build_varref( $2 ) ); }
    23992377        | '[' push assignment_expression pop ']'                        // C99, single array element
     
    24402418
    24412419type_parameter:                                                                                 // CFA
    2442         type_class no_attr_identifier_or_type_name
     2420        type_class identifier_or_type_name
    24432421                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    24442422          type_initializer_opt assertion_list_opt
     
    24732451
    24742452assertion:                                                                                              // CFA
    2475         '|' no_attr_identifier_or_type_name '(' type_list ')'
     2453        '|' identifier_or_type_name '(' type_list ')'
    24762454                { $$ = DeclarationNode::newTraitUse( $2, $4 ); }
    24772455        | '|' '{' push trait_declaration_list pop '}'
     
    25102488
    25112489type_declarator_name:                                                                   // CFA
    2512         no_attr_identifier_or_type_name
     2490        identifier_or_type_name
    25132491                {
    25142492                        typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" );
    25152493                        $$ = DeclarationNode::newTypeDecl( $1, 0 );
    25162494                }
    2517         | no_attr_identifier_or_type_name '(' type_parameter_list ')'
     2495        | identifier_or_type_name '(' type_parameter_list ')'
    25182496                {
    25192497                        typedefTable.addToEnclosingScope( *$1, TYPEGENname, "11" );
     
    25232501
    25242502trait_specifier:                                                                                // CFA
    2525         TRAIT no_attr_identifier_or_type_name '(' type_parameter_list ')' '{' '}'
     2503        TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}'
    25262504                { $$ = 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 '}'
    25282506                { $$ = DeclarationNode::newTrait( $2, $4, $8 ); }
    25292507        ;
Note: See TracChangeset for help on using the changeset viewer.