Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    rde62360d r843054c2  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 24 14:09:51 2015
    13 // Update Count     : 81
     12// Last Modified On : Sat May 16 13:30:24 2015
     13// Update Count     : 3
    1414//
    1515
     
    2222
    2323#include "utility.h"
    24 #include "Parser/LinkageSpec.h"
    25 #include "SynTree/Type.h"
    26 //#include "SynTree/Declaration.h"
     24#include "SynTree/Declaration.h"
    2725#include "UniqueName.h"
    2826
     
    3836class ParseNode {
    3937  public:
    40         ParseNode();
    41         ParseNode( const std::string * );
    42         virtual ~ParseNode();
    43 
    44         ParseNode *get_link() const;
    45         ParseNode *get_last();
     38        ParseNode( void );
     39        ParseNode ( std::string );
     40        virtual ~ParseNode( void );
     41
     42        ParseNode *set_name ( std::string ) ;
     43        ParseNode *set_name ( std::string * ) ;
     44
     45        std::string get_name( void );
     46
     47        ParseNode *get_link( void ) const;
     48        ParseNode *get_last( void );
    4649        ParseNode *set_link( ParseNode * );
    4750        void set_next( ParseNode *newlink ) { next = newlink; }
     
    4952        virtual ParseNode *clone() const { return 0; };
    5053
    51         const std::string &get_name() const { return *name; }
     54        const std::string get_name( void ) const;
    5255        virtual void print( std::ostream &, int indent = 0 ) const;
    5356        virtual void printList( std::ostream &, int indent = 0 ) const;
     
    5558        ParseNode &operator,( ParseNode &);
    5659  protected:
    57         const std::string *name;
     60        std::string name;
    5861        ParseNode *next;
    5962        static int indent_by;
     
    6568  public:
    6669        ExpressionNode();
    67         ExpressionNode( const std::string * );
     70        ExpressionNode( std::string * );
    6871        ExpressionNode( const ExpressionNode &other );
    6972        virtual ~ExpressionNode() {} // cannot delete asArgName because it might be referenced elsewhere
     
    7477
    7578        ExpressionNode *get_argName() const { return argName; }
    76         ExpressionNode *set_asArgName( const std::string *aName );
     79        ExpressionNode *set_asArgName( std::string *aName );
    7780        ExpressionNode *set_asArgName( ExpressionNode *aDesignator );
    7881
     
    102105class ConstantNode : public ExpressionNode {
    103106  public:
    104         enum Type { Integer, Float, Character, String };
    105 
     107        enum Type {
     108                Integer, Float, Character, String /* , Range, EnumConstant  */
     109        };
     110
     111        ConstantNode( void );
     112        ConstantNode( std::string * );
    106113        ConstantNode( Type, std::string * );
     114        ConstantNode( const ConstantNode &other );
    107115
    108116        virtual ConstantNode *clone() const { return new ConstantNode( *this ); }
    109         Type get_type( void ) const { return type; }
     117
     118        Type get_type( void ) const ;
    110119        virtual void print( std::ostream &, int indent = 0) const;
    111120        virtual void printOneLine( std::ostream &, int indent = 0) const;
    112121
    113         const std::string &get_value() const { return value; }
    114         ConstantNode *appendstr( const std::string *newValue );
     122        std::string get_value() const { return value; }
     123        ConstantNode *append( std::string *newValue );
    115124
    116125        Expression *build() const;
    117126  private:
     127        void classify( std::string &);
    118128        Type type;
    119         BasicType::Kind btype;
    120         std::string &value;
     129        std::string value;
     130        bool sign;
     131        short base;
     132        int longs, size;
    121133};
    122134
     
    124136  public:
    125137        VarRefNode();
    126         VarRefNode( const std::string *, bool isLabel = false );
     138        VarRefNode( std::string *, bool isLabel = false );
    127139        VarRefNode( const VarRefNode &other );
    128140
     
    131143        virtual VarRefNode *clone() const { return new VarRefNode( *this ); }
    132144
    133         virtual void print( std::ostream &, int indent = 0 ) const;
    134         virtual void printOneLine( std::ostream &, int indent = 0 ) const;
     145        virtual void print( std::ostream &, int indent = 0) const;
     146        virtual void printOneLine( std::ostream &, int indent = 0) const;
    135147  private:
    136148        bool isLabel;
     
    171183        virtual OperatorNode *clone() const { return new OperatorNode( *this ); }
    172184
    173         Type get_type() const;
    174         const char *get_typename() const;
     185        Type get_type( void ) const;
     186        std::string get_typename( void ) const;
    175187
    176188        virtual void print( std::ostream &, int indent = 0) const;
     
    186198class CompositeExprNode : public ExpressionNode {
    187199  public:
    188         CompositeExprNode();
    189         CompositeExprNode( const std::string * );
     200        CompositeExprNode( void );
     201        CompositeExprNode( std::string * );
    190202        CompositeExprNode( ExpressionNode *f, ExpressionNode *args = 0 );
    191203        CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2 );
     
    266278  public:
    267279        enum Qualifier { Const, Restrict, Volatile, Lvalue, Atomic, Attribute };
    268         enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran, Noreturn, Threadlocal, NoStorageClass, };
     280        enum StorageClass { Extern, Static, Auto, Register, Inline, Fortran };
    269281        enum BasicType { Char, Int, Float, Double, Void, Bool, Complex, Imaginary };
    270         enum Modifier  { Signed, Unsigned, Short, Long };
    271         enum Aggregate { Struct, Union, Context };
     282        enum Modifier { Signed, Unsigned, Short, Long };
     283        enum TyCon { Struct, Union, Context };
    272284        enum TypeClass { Type, Dtype, Ftype };
    273285
    274         static const char *storageName[]; 
    275286        static const char *qualifierName[];
    276287        static const char *basicTypeName[];
    277288        static const char *modifierName[];
    278         static const char *aggregateName[];
     289        static const char *tyConName[];
    279290        static const char *typeClassName[];
    280291
     
    287298        static DeclarationNode *newForall( DeclarationNode *);
    288299        static DeclarationNode *newFromTypedef( std::string *);
    289         static DeclarationNode *newAggregate( Aggregate kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields );
     300        static DeclarationNode *newAggregate( TyCon kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields );
    290301        static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants );
    291302        static DeclarationNode *newEnumConstant( std::string *name, ExpressionNode *constant );
    292303        static DeclarationNode *newName( std::string *);
    293         static DeclarationNode *newFromTypeGen( std::string *, ExpressionNode *params );
     304        static DeclarationNode *newFromTypeGen( std::string*, ExpressionNode *params );
    294305        static DeclarationNode *newTypeParam( TypeClass, std::string *);
    295306        static DeclarationNode *newContext( std::string *name, DeclarationNode *params, DeclarationNode *asserts );
     
    302313        static DeclarationNode *newTuple( DeclarationNode *members );
    303314        static DeclarationNode *newTypeof( ExpressionNode *expr );
    304         static DeclarationNode *newAttr( std::string *, ExpressionNode *expr );
    305         static DeclarationNode *newAttr( std::string *, DeclarationNode *type );
     315        static DeclarationNode *newAttr( std::string*, ExpressionNode *expr );
     316        static DeclarationNode *newAttr( std::string*, DeclarationNode *type );
    306317
    307318        DeclarationNode *addQualifiers( DeclarationNode *);
     
    329340        DeclarationNode *cloneBaseType( DeclarationNode *newdecl );
    330341
    331         DeclarationNode *appendList( DeclarationNode * );
     342        DeclarationNode *appendList( DeclarationNode  *);
    332343
    333344        DeclarationNode *clone() const;
     
    339350
    340351        bool get_hasEllipsis() const;
    341         const std::string &get_name() const { return name; }
     352        std::string get_name() const { return name; }
    342353        LinkageSpec::Type get_linkage() const { return linkage; }
    343354        DeclarationNode *extractAggregate() const;
     
    346357        ~DeclarationNode();
    347358  private:
    348         StorageClass buildStorageClass() const;
    349         bool buildFuncSpecifier( StorageClass key ) const;
     359        Declaration::StorageClass buildStorageClass() const;
     360        bool buildInline() const;
    350361
    351362        TypeData *type;
     
    369380        };
    370381
    371         StatementNode();
    372         StatementNode( const std::string * );
     382        StatementNode( void );
     383        StatementNode( std::string );
    373384        StatementNode( Type, ExpressionNode *e = 0, StatementNode *s = 0 );
    374385        StatementNode( Type, std::string *target );
     
    376387
    377388
    378         ~StatementNode();
    379 
    380         static StatementNode *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
     389        ~StatementNode( void );
     390
     391        static StatementNode  *newCatchStmt( DeclarationNode *d = 0, StatementNode *s = 0, bool catchRestP = false );
    381392
    382393        void set_control( ExpressionNode * );
     
    385396        ExpressionNode *get_control() const ;
    386397        StatementNode *get_block() const;
    387         StatementNode::Type get_type() const;
    388 
    389         StatementNode *add_label( const std::string * );
     398        StatementNode::Type get_type( void ) const;
     399
     400        StatementNode *add_label( std::string * );
    390401        std::list<std::string> *get_labels() const;
    391402
     
    418429class CompoundStmtNode : public StatementNode {
    419430  public:
    420         CompoundStmtNode();
    421         CompoundStmtNode( const std::string * );
     431        CompoundStmtNode( void );
     432        CompoundStmtNode( std::string * );
    422433        CompoundStmtNode( StatementNode * );
    423434        ~CompoundStmtNode();
     
    488499
    489500// in DeclarationNode.cc
    490 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList );
     501void buildList( const DeclarationNode *firstNode, std::list< Declaration *> &outputList );
    491502void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList );
    492 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );
     503void buildTypeList( const DeclarationNode *firstNode, std::list< Type *> &outputList );
    493504
    494505// in ExpressionNode.cc
Note: See TracChangeset for help on using the changeset viewer.