Changeset 1b772749 for src/Parser


Ignore:
Timestamp:
Sep 16, 2016, 10:48:28 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
2298f728
Parents:
ba7aa2d
Message:

more refactoring of parser code

Location:
src/Parser
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/Parser/DeclarationNode.cc

    rba7aa2d r1b772749  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Sep 15 23:36:02 2016
    13 // Update Count     : 515
     12// Last Modified On : Fri Sep 16 18:17:16 2016
     13// Update Count     : 527
    1414//
    1515
     
    447447        copyStorageClasses( q );
    448448
    449         if ( ! q->type ) { delete q; return this; }
     449        if ( ! q->type ) {
     450                delete q;
     451                return this;
     452        } // if
    450453
    451454        if ( ! type ) {
    452 //              type = new TypeData;
    453                 type = q->type;
     455                type = q->type;                                                                 // reuse this structure
     456                q->type = nullptr;
     457                delete q;
    454458                return this;
    455459        } // if
  • TabularUnified src/Parser/ExpressionNode.cc

    rba7aa2d r1b772749  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Aug 25 21:39:40 2016
    13 // Update Count     : 503
     12// Last Modified On : Fri Sep 16 16:27:44 2016
     13// Update Count     : 508
    1414//
    1515
     
    3131
    3232using namespace std;
    33 
    34 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.get_name() ), extension( other.extension ) {}
    3533
    3634//##############################################################################
  • TabularUnified src/Parser/ParseNode.h

    rba7aa2d r1b772749  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 08:00:05 2016
    13 // Update Count     : 603
     12// Last Modified On : Fri Sep 16 15:02:38 2016
     13// Update Count     : 613
    1414//
    1515
     
    4141  public:
    4242        ParseNode() {};
    43         ParseNode( const std::string * name ) : name( * name ) { assert( false ); delete name; }
    44         ParseNode( const std::string &name ) : name( name ) { assert( false ); }
    4543        virtual ~ParseNode() { delete next; };
    4644        virtual ParseNode * clone() const = 0;
     
    4846        ParseNode * get_next() const { return next; }
    4947        ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; }
     48
    5049        ParseNode * get_last() {
    5150                ParseNode * current;
     
    5857        }
    5958
    60         const std::string &get_name() const { return name; }
    61         void set_name( const std::string &newValue ) { name = newValue; }
    62 
    6359        virtual void print( std::ostream &os, int indent = 0 ) const {}
    6460        virtual void printList( std::ostream &os, int indent = 0 ) const {}
    65   private:
     61
    6662        static int indent_by;
    6763
     
    106102  public:
    107103        ExpressionNode( Expression * expr = nullptr ) : expr( expr ) {}
    108         ExpressionNode( Expression * expr, const std::string * name ) : ParseNode( name ), expr( expr ) {}
    109104        ExpressionNode( const ExpressionNode &other );
    110105        virtual ~ExpressionNode() {}
     
    286281
    287282        bool get_hasEllipsis() const;
    288         const std::string &get_name() const { return name; }
    289283        LinkageSpec::Spec get_linkage() const { return linkage; }
    290284        DeclarationNode * extractAggregate() const;
     
    295289        DeclarationNode * set_extension( bool exten ) { extension = exten; return this; }
    296290  public:
    297         // StorageClass buildStorageClass() const;
    298         // bool buildFuncSpecifier( StorageClass key ) const;
    299 
    300291        struct Variable_t {
    301292                DeclarationNode::TypeClass tyClass;
     
    315306
    316307        TypeData * type;
    317         std::string name;
    318308        StorageClass storageClass;
    319309        bool isInline, isNoreturn;
     
    331321
    332322Type * buildType( TypeData * type );
    333 //Type::Qualifiers buildQualifiers( const TypeData::Qualifiers & qualifiers );
    334323
    335324static inline Type * maybeMoveBuildType( const DeclarationNode * orig ) {
  • TabularUnified src/Parser/TypeData.cc

    rba7aa2d r1b772749  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Sep 15 23:05:01 2016
    13 // Update Count     : 384
     12// Last Modified On : Fri Sep 16 15:12:55 2016
     13// Update Count     : 388
    1414//
    1515
     
    763763} // buildTypeof
    764764
    765 AttrType * buildAttr( const TypeData * td ) {
    766         assert( false );
    767         return nullptr;
    768         // assert( td->kind == TypeData::Attr );
    769         // // assert( td->attr );
    770         // AttrType * ret;
    771         // if ( td->attr.expr ) {
    772         //      ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.expr->build() );
    773         // } else {
    774         //      assert( td->attr.type );
    775         //      ret = new AttrType( buildQualifiers( td ), td->attr.name, td->attr.type->buildType() );
    776         // } // if
    777         // return ret;
    778 } // buildAttr
    779 
    780765Declaration * buildDecl( const TypeData * td, std::string name, DeclarationNode::StorageClass sc, Expression * bitfieldWidth, bool isInline, bool isNoreturn, LinkageSpec::Spec linkage, Initializer * init ) {
    781766        if ( td->kind == TypeData::Function ) {
     
    795780                } // if
    796781                for ( DeclarationNode * cur = td->function.idList; cur != 0; cur = dynamic_cast< DeclarationNode* >( cur->get_next() ) ) {
    797                         if ( cur->get_name() != "" ) {
    798                                 decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->get_name() );
     782                        if ( cur->name != "" ) {
     783                                decl->get_oldIdents().insert( decl->get_oldIdents().end(), cur->name );
    799784                        } // if
    800785                } // for
  • TabularUnified src/Parser/TypeData.h

    rba7aa2d r1b772749  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 17:15:49 2016
    13 // Update Count     : 129
     12// Last Modified On : Fri Sep 16 15:17:31 2016
     13// Update Count     : 131
    1414//
    1515
     
    8888                DeclarationNode * tuple;
    8989                ExpressionNode * typeexpr;
    90                 // Attr_t attr;
    9190                // DeclarationNode::BuiltinType builtin;
    9291
     
    111110TupleType * buildTuple( const TypeData * );
    112111TypeofType * buildTypeof( const TypeData * );
    113 AttrType * buildAttr( const TypeData * );
    114112Declaration * buildDecl( const TypeData *, std::string, DeclarationNode::StorageClass, Expression *, bool isInline, bool isNoreturn, LinkageSpec::Spec, Initializer * init = 0 );
    115113FunctionType * buildFunction( const TypeData * );
  • TabularUnified src/Parser/parser.yy

    rba7aa2d r1b772749  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 12 17:29:45 2016
    13 // Update Count     : 1969
     12// Last Modified On : Fri Sep 16 18:12:21 2016
     13// Update Count     : 1978
    1414//
    1515
     
    359359                { $$ = $2; }
    360360        | '(' compound_statement ')'                                            // GCC, lambda expression
    361         { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
     361                { $$ = new ExpressionNode( build_valexpr( $2 ) ); }
    362362        ;
    363363
     
    896896                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
    897897        | handler_clause CATCH '(' push push exception_declaration pop ')' compound_statement pop
    898         { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
     898                { $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $6, $9 ) ) ); }
    899899        | CATCHRESUME '(' push push exception_declaration pop ')' compound_statement pop
    900900                { $$ = new StatementNode( build_catch( $5, $8 ) ); }
     
    968968                { $$ = new ExpressionNode( build_asmexpr( 0, $1, $3 ) ); }
    969969        | '[' constant_expression ']' string_literal '(' constant_expression ')'
    970         { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
     970                { $$ = new ExpressionNode( build_asmexpr( $2, $4, $6 ) ); }
    971971        ;
    972972
     
    14671467aggregate_name:
    14681468        aggregate_key '{' field_declaration_list '}'
    1469                 { $$ = DeclarationNode::newAggregate( $1, 0, 0, $3, true ); }
     1469                { $$ = DeclarationNode::newAggregate( $1, new std::string( "" ), nullptr, $3, true ); }
    14701470        | aggregate_key no_attr_identifier_or_type_name
    14711471                {
     
    14761476                { typedefTable.makeTypedef( *$2 ); }
    14771477                '{' field_declaration_list '}'
    1478                 { $$ = DeclarationNode::newAggregate( $1, $2, 0, $5, true ); }
     1478                { $$ = DeclarationNode::newAggregate( $1, $2, nullptr, $5, true ); }
    14791479        | aggregate_key '(' type_name_list ')' '{' field_declaration_list '}' // CFA
    1480                 { $$ = DeclarationNode::newAggregate( $1, 0, $3, $6, false ); }
     1480                { $$ = DeclarationNode::newAggregate( $1, new std::string( "" ), $3, $6, false ); }
    14811481        | aggregate_key typegen_name                                            // CFA, S/R conflict
    14821482                { $$ = $2; }
     
    15591559enum_name:
    15601560        enum_key '{' enumerator_list comma_opt '}'
    1561                 { $$ = DeclarationNode::newEnum( 0, $3 ); }
     1561                { $$ = DeclarationNode::newEnum( new std::string( "" ), $3 ); }
    15621562        | enum_key no_attr_identifier_or_type_name
    15631563                {
     
    25202520abstract_function:
    25212521        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2522                 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
     2522                { $$ = DeclarationNode::newFunction( new std::string( "" ), nullptr, $3, nullptr ); }
    25232523        | '(' abstract_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25242524                { $$ = $2->addParamList( $6 ); }
     
    25892589abstract_parameter_function:
    25902590        '(' push parameter_type_list_opt pop ')'                        // empty parameter list OBSOLESCENT (see 3)
    2591                 { $$ = DeclarationNode::newFunction( 0, 0, $3, 0 ); }
     2591                { $$ = DeclarationNode::newFunction( new std::string( "" ), nullptr, $3, nullptr ); }
    25922592        | '(' abstract_parameter_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    25932593                { $$ = $2->addParamList( $6 ); }
     
    28132813new_abstract_function:                                                                  // CFA
    28142814        '[' ']' '(' new_parameter_type_list_opt ')'
    2815                 { $$ = DeclarationNode::newFunction( 0, DeclarationNode::newTuple( 0 ), $4, 0 ); }
     2815        { $$ = DeclarationNode::newFunction( new std::string( "" ), DeclarationNode::newTuple( nullptr ), $4, nullptr ); }
    28162816        | new_abstract_tuple '(' push new_parameter_type_list_opt pop ')'
    2817                 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
     2817                { $$ = DeclarationNode::newFunction( new std::string( "" ), $1, $4, nullptr ); }
    28182818        | new_function_return '(' push new_parameter_type_list_opt pop ')'
    2819                 { $$ = DeclarationNode::newFunction( 0, $1, $4, 0 ); }
     2819                { $$ = DeclarationNode::newFunction( new std::string( "" ), $1, $4, nullptr ); }
    28202820        ;
    28212821
Note: See TracChangeset for help on using the changeset viewer.