Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    rd824715 r374cb117  
    380380
    381381%type<decl> enumerator_list enum_type enum_type_nobody
    382 %type<en> enumerator_value_opt
     382%type<in> enumerator_value_opt
    383383
    384384%type<decl> external_definition external_definition_list external_definition_list_opt
     
    23032303        ;
    23042304
    2305 enum_type:                                                                                              // enum
     2305enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed );                                                                                         // enum
    23062306        ENUM attribute_list_opt '{' enumerator_list comma_opt '}'
    23072307                { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); }
     
    23152315        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    23162316                {
    2317                         if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    2318                         SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
    2319                 }
    2320         | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt
     2317                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 )
     2318                        { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     2319
     2320                        $$ = DeclarationNode::newEnum( nullptr, $7, true ) ->addQualifiers( $5 )  -> addEnumBase( $3 );
     2321                }
     2322        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier
    23212323                {
    23222324                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
     
    23252327          '{' enumerator_list comma_opt '}'
    23262328                {
    2327                         SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
     2329                        $$ = DeclarationNode::newEnum( $6, $10, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
    23282330                }
    23292331        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}'
     
    23312333                        if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); }
    23322334                        typedefTable.makeTypedef( *$6->name );
    2333                         SemanticError( yylloc, "Typed enumeration is currently unimplemented." ); $$ = nullptr;
     2335                        $$ = DeclarationNode::newEnum( $6->name, $9, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 );
    23342336                }
    23352337        | enum_type_nobody
     
    23452347enumerator_list:
    23462348        identifier_or_type_name enumerator_value_opt
    2347                 { $$ = DeclarationNode::newEnumConstant( $1, $2 ); }
     2349                { $$ = DeclarationNode::newEnumValueGeneric( $1, $2 ); }
    23482350        | INLINE type_name
    2349                 { $$ = DeclarationNode::newEnumConstant( new string("inline"), nullptr ); }
     2351                { $$ = DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ); }
    23502352        | enumerator_list ',' identifier_or_type_name enumerator_value_opt
    2351                 { $$ = $1->appendList( DeclarationNode::newEnumConstant( $3, $4 ) ); }
     2353                { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( $3, $4 ) ); }
    23522354        | enumerator_list ',' INLINE type_name enumerator_value_opt
    2353                 { $$ = $1->appendList( DeclarationNode::newEnumConstant( new string("inline"), nullptr ) ); }
     2355                { $$ = $1->appendList( DeclarationNode::newEnumValueGeneric( new string("inline"), nullptr ) ); }
    23542356        ;
    23552357
     
    23602362        //      { $$ = $2; }
    23612363        | simple_assignment_operator initializer
    2362                 { $$ = $2->get_expression(); }                                  // FIX ME: enum only deals with constant_expression
     2364                { $$ = $1 == OperKinds::Assign ? $2 : $2->set_maybeConstructed( false ); }
    23632365        ;
    23642366
Note: See TracChangeset for help on using the changeset viewer.