Changeset 2dcd80a for src/Parser


Ignore:
Timestamp:
Dec 14, 2022, 12:23:42 PM (3 years ago)
Author:
caparson <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
441a6a7
Parents:
7d9598d8 (diff), d8bdf13 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r7d9598d8 r2dcd80a  
    254254} // DeclarationNode::newAggregate
    255255
    256 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base) {
     256DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base, EnumHiding hiding ) {
    257257        DeclarationNode * newnode = new DeclarationNode;
    258258        newnode->type = new TypeData( TypeData::Enum );
     
    262262        newnode->type->enumeration.anon = name == nullptr;
    263263        newnode->type->enumeration.typed = typed;
     264        newnode->type->enumeration.hiding = hiding;
    264265        if ( base && base->type)  {
    265266                newnode->type->base = base->type;
  • src/Parser/ParseNode.h

    r7d9598d8 r2dcd80a  
    239239        static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body );
    240240        static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body );
    241         static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base = nullptr );
     241        static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed, DeclarationNode * base = nullptr, EnumHiding hiding = EnumHiding::Visible );
    242242        static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant );
    243243        static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init );
  • src/Parser/TypeData.cc

    r7d9598d8 r2dcd80a  
    923923        buildList( td->enumeration.constants, ret->get_members() );
    924924        list< Declaration * >::iterator members = ret->get_members().begin();
     925        ret->hide = td->enumeration.hiding == EnumHiding::Hide ? EnumDecl::EnumHiding::Hide : EnumDecl::EnumHiding::Visible;
    925926        for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) {
    926927                if ( cur->enumInLine ) {
  • src/Parser/TypeData.h

    r7d9598d8 r2dcd80a  
    6060                bool anon;
    6161                bool typed;
     62                EnumHiding hiding;
    6263        };
    6364
  • src/Parser/parser.yy

    r7d9598d8 r2dcd80a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Nov  2 21:31:21 2022
    13 // Update Count     : 5810
     12// Last Modified On : Mon Nov 21 22:34:30 2022
     13// Update Count     : 5848
    1414//
    1515
     
    383383%type<ifctl> conditional_declaration
    384384%type<fctl> for_control_expression              for_control_expression_list
    385 %type<compop> updown updowneq downupdowneq
     385%type<compop> upupeq updown updowneq downupdowneq
    386386%type<en> subrange
    387387%type<decl> asm_name_opt
     
    489489%type<decl> type_parameter type_parameter_list type_initializer_opt
    490490
    491 %type<en> type_parameters_opt type_list
     491%type<en> type_parameters_opt type_list array_type_list
    492492
    493493%type<decl> type_qualifier type_qualifier_name forall type_qualifier_list_opt type_qualifier_list
     
    551551
    552552%%
    553 //************************* Namespace Management ********************************
     553// ************************ Namespace Management ********************************
    554554
    555555// The C grammar is not context free because it relies on the distinct terminal symbols "identifier" and "TYPEDEFname",
     
    588588        ;
    589589
    590 //************************* CONSTANTS ********************************
     590// ************************ CONSTANTS ********************************
    591591
    592592constant:
     
    634634        ;
    635635
    636 //************************* EXPRESSIONS ********************************
     636// ************************ EXPRESSIONS ********************************
    637637
    638638primary_expression:
     
    11011101        ;
    11021102
    1103 //*************************** STATEMENTS *******************************
     1103// ************************** STATEMENTS *******************************
    11041104
    11051105statement:
     
    17581758        ;
    17591759
    1760 //******************************* DECLARATIONS *********************************
     1760// ****************************** DECLARATIONS *********************************
    17611761
    17621762declaration_list_opt:                                                                   // used at beginning of switch statement
     
    25582558                { typedefTable.makeTypedef( *$3 ); }
    25592559          hide_opt '{' enumerator_list comma_opt '}'
    2560           { $$ = DeclarationNode::newEnum( $3, $7, true, false )->addQualifiers( $2 ); }
     2560                { $$ = DeclarationNode::newEnum( $3, $7, true, false, nullptr, $5 )->addQualifiers( $2 ); }
    25612561        | ENUM attribute_list_opt typedef_name                          // unqualified type name
    25622562          hide_opt '{' enumerator_list comma_opt '}'
    2563                 { $$ = DeclarationNode::newEnum( $3->name, $6, true, false )->addQualifiers( $2 ); }
     2563                { $$ = DeclarationNode::newEnum( $3->name, $6, true, false, nullptr, $4 )->addQualifiers( $2 ); }
    25642564        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt '{' enumerator_list comma_opt '}'
    25652565                {
     
    25802580          hide_opt '{' enumerator_list comma_opt '}'
    25812581                {
    2582                         $$ = DeclarationNode::newEnum( $6, $11, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
     2582                        $$ = DeclarationNode::newEnum( $6, $11, true, true, $3, $9 )->addQualifiers( $5 )->addQualifiers( $7 );
    25832583                }
    25842584        | ENUM '(' ')' attribute_list_opt identifier attribute_list_opt
    25852585          hide_opt '{' enumerator_list comma_opt '}'
    25862586                {
    2587                         $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 );
     2587                        $$ = DeclarationNode::newEnum( $5, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    25882588                }
    25892589        | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt
    25902590          hide_opt '{' enumerator_list comma_opt '}'
    25912591                {
    2592                         $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3 )->addQualifiers( $5 )->addQualifiers( $7 );
     2592                        $$ = DeclarationNode::newEnum( $6->name, $10, true, true, $3, $8 )->addQualifiers( $5 )->addQualifiers( $7 );
    25932593                }
    25942594        | ENUM '(' ')' attribute_list_opt typedef_name attribute_list_opt
    25952595          hide_opt '{' enumerator_list comma_opt '}'
    25962596                {
    2597                         $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr )->addQualifiers( $4 )->addQualifiers( $6 );
     2597                        $$ = DeclarationNode::newEnum( $5->name, $9, true, true, nullptr, $7 )->addQualifiers( $4 )->addQualifiers( $6 );
    25982598                }
    25992599        | enum_type_nobody
     
    29912991        ;
    29922992
    2993 //***************************** EXTERNAL DEFINITIONS *****************************
     2993// **************************** EXTERNAL DEFINITIONS *****************************
    29942994
    29952995translation_unit:
     
    36533653        | '[' ']' multi_array_dimension
    36543654                { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); }
    3655         | '[' push assignment_expression pop ',' comma_expression ']'
     3655                // Cannot use constant_expression because of tuples => semantic check
     3656        | '[' push assignment_expression pop ',' comma_expression ']' // CFA
    36563657                { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); }
    36573658                // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; }
     3659        | '[' push array_type_list pop ']'                                      // CFA
     3660                { SemanticError( yylloc, "Type array dimension is currently unimplemented." ); $$ = nullptr; }
    36583661        | multi_array_dimension
    36593662        ;
     3663
     3664array_type_list:
     3665        basic_type_name
     3666                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
     3667        | type_name
     3668                { $$ = new ExpressionNode( new TypeExpr( maybeMoveBuildType( $1 ) ) ); }
     3669        | assignment_expression upupeq assignment_expression
     3670        | array_type_list ',' basic_type_name
     3671                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
     3672        | array_type_list ',' type_name
     3673                { $$ = (ExpressionNode *)($1->set_last( new ExpressionNode( new TypeExpr( maybeMoveBuildType( $3 ) ) ) )); }
     3674        | array_type_list ',' assignment_expression upupeq assignment_expression
     3675        ;
     3676
     3677upupeq:
     3678        '~'
     3679                { $$ = OperKinds::LThan; }
     3680        | ErangeUpEq
     3681                { $$ = OperKinds::LEThan; }
     3682        ;
    36603683
    36613684multi_array_dimension:
     
    39904013//    declaration lists (not prototype-format parameter type and identifier declarators) is an obsolescent feature.
    39914014
    3992 //************************* MISCELLANEOUS ********************************
     4015// ************************ MISCELLANEOUS ********************************
    39934016
    39944017comma_opt:                                                                                              // redundant comma
Note: See TracChangeset for help on using the changeset viewer.