Changeset 9fa61f5


Ignore:
Timestamp:
Mar 14, 2023, 11:19:51 AM (16 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
a96ce07
Parents:
15596d7
Message:

remove unnecessary code, add action to not duplicate aggregate (work in progress)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r15596d7 r9fa61f5  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 25 13:23:16 2023
    13 // Update Count     : 5989
     12// Last Modified On : Tue Mar 14 09:37:58 2023
     13// Update Count     : 5990
    1414//
    1515
     
    20552055        basic_type_specifier
    20562056        | sue_type_specifier
    2057                 {
    2058                         // printf( "sue_type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2059                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    2060                         //   printf( "\tattr %s\n", attr->name.c_str() );
    2061                         // } // for
    2062                 }
    20632057        | type_type_specifier
    20642058        ;
     
    24002394          '{' field_declaration_list_opt '}' type_parameters_opt
    24012395                {
    2402                         // printf( "aggregate_type1 %s\n", $3.str->c_str() );
    2403                         // if ( $2 )
    2404                         //      for ( Attribute * attr: reverseIterate( $2->attributes ) ) {
    2405                         //              printf( "copySpecifiers12 %s\n", attr->name.c_str() );
    2406                         //      } // for
    24072396                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
    2408                         // printf( "aggregate_type2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );
    2409                         // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {
    2410                         //      printf( "aggregate_type3 %s\n", attr->name.c_str() );
    2411                         // } // for
    24122397                }
    24132398        | aggregate_key attribute_list_opt TYPEDEFname          // unqualified type name
     
    24182403          '{' field_declaration_list_opt '}' type_parameters_opt
    24192404                {
    2420                         // printf( "AGG3\n" );
    24212405                        DeclarationNode::newFromTypedef( $3 );
    24222406                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     
    24292413          '{' field_declaration_list_opt '}' type_parameters_opt
    24302414                {
    2431                         // printf( "AGG4\n" );
    24322415                        DeclarationNode::newFromTypeGen( $3, nullptr );
    24332416                        $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 );
     
    24562439                        // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and
    24572440                        // delete newFromTypeGen.
    2458                         $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 );
    2459                         $3->type->symbolic.name = nullptr;
    2460                         $3->type->symbolic.actuals = nullptr;
    2461                         delete $3;
     2441                        if ( $3->type->kind == TypeData::SymbolicInst && ! $3->type->symbolic.isTypedef ) {
     2442                                $$ = $3->addQualifiers( $2 );
     2443                        } else {
     2444                                $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 );
     2445                                $3->type->symbolic.name = nullptr;                      // copied to $$
     2446                                $3->type->symbolic.actuals = nullptr;
     2447                                delete $3;
     2448                        }
    24622449                }
    24632450        ;
     
    27962783type_no_function:                                                                               // sizeof, alignof, cast (constructor)
    27972784        cfa_abstract_declarator_tuple                                           // CFA
    2798         | type_specifier
     2785        | type_specifier                                                                        // cannot be type_specifier_nobody, e.g., (struct S {}){} is a thing
    27992786        | type_specifier abstract_declarator
    28002787                { $$ = $2->addType( $1 ); }
Note: See TracChangeset for help on using the changeset viewer.