Changeset 30aab55


Ignore:
Timestamp:
Mar 16, 2024, 2:04:17 PM (8 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
30ee3155
Parents:
3ad5c50
Message:

reorganized enum_type rule in parser and add missing call to makeTypedef

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r3ad5c50 r30aab55  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 11 18:30:03 2024
    13 // Update Count     : 6589
     12// Last Modified On : Sat Mar 16 11:17:15 2024
     13// Update Count     : 6599
    1414//
    1515
     
    27422742
    27432743enum_type:
    2744         ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    2745                 { $$ = DeclarationNode::newEnum( nullptr, $4, true, false )->addQualifiers( $2 ); }
    2746         | ENUM attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule
     2744                // anonymous, no type name
     2745        ENUM attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2746                {
     2747                        if ( $3 == EnumHiding::Hide ) {
     2748                                SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr;
     2749                        } // if
     2750                        $$ = DeclarationNode::newEnum( nullptr, $5, true, false )->addQualifiers( $2 );
     2751                }
     2752                // pure enumeration
     2753        | ENUM '(' ')' attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2754                {
     2755                        if ( $5 == EnumHiding::Hide ) {
     2756                                SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr;
     2757                        } // if
     2758                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true )->addQualifiers( $4 );
     2759                }
     2760                // typed enumeration
     2761        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
     2762                {
     2763                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() ) {
     2764                                SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
     2765                        }
     2766                        $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 );
     2767                }
     2768        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // unqualified type name
    27472769                { SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
     2770
     2771                // type name
    27482772        | ENUM attribute_list_opt identifier
    27492773                { typedefTable.makeTypedef( *$3, "enum_type 1" ); }
     
    27522776        | ENUM attribute_list_opt typedef_name hide_opt '{' enumerator_list comma_opt '}' // unqualified type name
    27532777                { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); }
    2754         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2755                 {
    2756                         if ( $3->storageClasses.val != 0 || $3->type->qualifiers.any() ) {
    2757                                 SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
    2758                         }
    2759                         $$ = DeclarationNode::newEnum( nullptr, $7, true, true, $3 )->addQualifiers( $5 );
    2760                 }
    2761         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // unqualified type name
    2762                 { SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
    2763         | ENUM '(' ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    2764                 {
    2765                         $$ = DeclarationNode::newEnum( nullptr, $6, true, true )->addQualifiers( $4 );
    2766                 }
    2767         | ENUM '(' ')' attribute_list_opt '!' '{' enumerator_list comma_opt '}' // invalid syntax rule
    2768                 { SemanticError( yylloc, "syntax error, hiding ('!') the enumerator names of an anonymous enumeration means the names are inaccessible." ); $$ = nullptr; }
     2778                // pure enumeration
     2779        | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt
     2780                { typedefTable.makeTypedef( *$5, "enum_type 2" ); }
     2781          hide_opt '{' enumerator_list comma_opt '}'
     2782                {
     2783                        $$ = DeclarationNode::newEnum( $5, $10, true, true, nullptr, $8 )->addQualifiers( $4 )->addQualifiers( $6 );
     2784                }
     2785        | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
     2786                {
     2787                        $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
     2788                }
     2789                // typed enumeration
    27692790        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
    27702791                {
     
    27722793                                SemanticError( yylloc, "syntax error, storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." );
    27732794                        }
    2774                         typedefTable.makeTypedef( *$6, "enum_type 2" );
     2795                        typedefTable.makeTypedef( *$6, "enum_type 3" );
    27752796                }
    27762797          hide_opt '{' enumerator_list comma_opt '}'
     
    27782799                        $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 );
    27792800                }
    2780         | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2781                 {
    2782                         $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    2783                 }
    27842801        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    27852802                {
    27862803                        $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3, $8 )->addQualifiers( $5 )->addQualifiers( $7 );
    27872804                }
    2788         | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt hide_opt '{' enumerator_list comma_opt '}'
    2789                 {
    2790                         $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    2791                 }
     2805
     2806                // forward declaration
    27922807        | enum_type_nobody
    27932808        ;
Note: See TracChangeset for help on using the changeset viewer.