Changeset c1e66d9 for src/Parser


Ignore:
Timestamp:
Sep 21, 2023, 10:15:37 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
deda7e6
Parents:
01510fe
Message:

Fix designator value in enumerated array and implemented enumerated array with inlined enume declaration

Location:
src/Parser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r01510fe rc1e66d9  
    394394        return newnode->addQualifiers( qualifiers );
    395395} // DeclarationNode::newArray
     396
     397DeclarationNode * DeclarationNode::newInlineEnumeratedArray( DeclarationNode * enumDecl, DeclarationNode * qualifiers ) {
     398        DeclarationNode * newnode = new DeclarationNode;
     399        newnode->type = new TypeData( TypeData::Array );
     400        newnode->type->array.isStatic = false;
     401        newnode->type->array.isVarLen = false;
     402
     403        if ( enumDecl ) {
     404                newnode->type->declType = enumDecl->type;
     405                enumDecl->type = nullptr;
     406                delete enumDecl;
     407        } // if
     408       
     409        return newnode->addQualifiers( qualifiers );
     410}
    396411
    397412DeclarationNode * DeclarationNode::newVarArray( DeclarationNode * qualifiers ) {
  • src/Parser/DeclarationNode.h

    r01510fe rc1e66d9  
    6666        static DeclarationNode * newPointer( DeclarationNode * qualifiers, OperKinds kind );
    6767        static DeclarationNode * newArray( ExpressionNode * size, DeclarationNode * qualifiers, bool isStatic );
     68        static DeclarationNode * newInlineEnumeratedArray( DeclarationNode * enumDecl, DeclarationNode * qualifiers );
    6869        static DeclarationNode * newVarArray( DeclarationNode * qualifiers );
    6970        static DeclarationNode * newBitfield( ExpressionNode * size );
  • src/Parser/TypeData.cc

    r01510fe rc1e66d9  
    10211021                );
    10221022        } // if
     1023        if ( td->declType) {
     1024                at->declaredType = buildEnum( td->declType, std::vector<ast::ptr<ast::Attribute>>(), ast::Linkage::Cforall );
     1025        }
    10231026        return at;
    10241027} // buildArray
  • src/Parser/TypeData.h

    r01510fe rc1e66d9  
    8585        Kind kind;
    8686        TypeData * base;
     87        TypeData * declType;
    8788        DeclarationNode::BasicType basictype = DeclarationNode::NoBasicType;
    8889        DeclarationNode::ComplexType complextype = DeclarationNode::NoComplexType;
  • src/Parser/parser.yy

    r01510fe rc1e66d9  
    38553855        | '[' push array_type_list pop ']'                                      // CFA
    38563856                { $$ = DeclarationNode::newArray( $3, nullptr, false ); }
     3857        | '[' push INLINE enum_type_nobody pop']'
     3858                {       
     3859                        $$ = DeclarationNode::newInlineEnumeratedArray( $4, nullptr );
     3860                }
    38573861        | multi_array_dimension
    38583862        ;
Note: See TracChangeset for help on using the changeset viewer.