Changes in src/Parser/ParseNode.h [de62360d:843054c2]
- File:
-
- 1 edited
-
src/Parser/ParseNode.h (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
rde62360d r843054c2 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 24 14:09:51201513 // Update Count : 8112 // Last Modified On : Sat May 16 13:30:24 2015 13 // Update Count : 3 14 14 // 15 15 … … 22 22 23 23 #include "utility.h" 24 #include "Parser/LinkageSpec.h" 25 #include "SynTree/Type.h" 26 //#include "SynTree/Declaration.h" 24 #include "SynTree/Declaration.h" 27 25 #include "UniqueName.h" 28 26 … … 38 36 class ParseNode { 39 37 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 ); 46 49 ParseNode *set_link( ParseNode * ); 47 50 void set_next( ParseNode *newlink ) { next = newlink; } … … 49 52 virtual ParseNode *clone() const { return 0; }; 50 53 51 const std::string &get_name() const { return *name; }54 const std::string get_name( void ) const; 52 55 virtual void print( std::ostream &, int indent = 0 ) const; 53 56 virtual void printList( std::ostream &, int indent = 0 ) const; … … 55 58 ParseNode &operator,( ParseNode &); 56 59 protected: 57 const std::string *name;60 std::string name; 58 61 ParseNode *next; 59 62 static int indent_by; … … 65 68 public: 66 69 ExpressionNode(); 67 ExpressionNode( conststd::string * );70 ExpressionNode( std::string * ); 68 71 ExpressionNode( const ExpressionNode &other ); 69 72 virtual ~ExpressionNode() {} // cannot delete asArgName because it might be referenced elsewhere … … 74 77 75 78 ExpressionNode *get_argName() const { return argName; } 76 ExpressionNode *set_asArgName( conststd::string *aName );79 ExpressionNode *set_asArgName( std::string *aName ); 77 80 ExpressionNode *set_asArgName( ExpressionNode *aDesignator ); 78 81 … … 102 105 class ConstantNode : public ExpressionNode { 103 106 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 * ); 106 113 ConstantNode( Type, std::string * ); 114 ConstantNode( const ConstantNode &other ); 107 115 108 116 virtual ConstantNode *clone() const { return new ConstantNode( *this ); } 109 Type get_type( void ) const { return type; } 117 118 Type get_type( void ) const ; 110 119 virtual void print( std::ostream &, int indent = 0) const; 111 120 virtual void printOneLine( std::ostream &, int indent = 0) const; 112 121 113 const std::string &get_value() const { return value; }114 ConstantNode *append str( conststd::string *newValue );122 std::string get_value() const { return value; } 123 ConstantNode *append( std::string *newValue ); 115 124 116 125 Expression *build() const; 117 126 private: 127 void classify( std::string &); 118 128 Type type; 119 BasicType::Kind btype; 120 std::string &value; 129 std::string value; 130 bool sign; 131 short base; 132 int longs, size; 121 133 }; 122 134 … … 124 136 public: 125 137 VarRefNode(); 126 VarRefNode( conststd::string *, bool isLabel = false );138 VarRefNode( std::string *, bool isLabel = false ); 127 139 VarRefNode( const VarRefNode &other ); 128 140 … … 131 143 virtual VarRefNode *clone() const { return new VarRefNode( *this ); } 132 144 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; 135 147 private: 136 148 bool isLabel; … … 171 183 virtual OperatorNode *clone() const { return new OperatorNode( *this ); } 172 184 173 Type get_type( ) const;174 const char *get_typename() const;185 Type get_type( void ) const; 186 std::string get_typename( void ) const; 175 187 176 188 virtual void print( std::ostream &, int indent = 0) const; … … 186 198 class CompositeExprNode : public ExpressionNode { 187 199 public: 188 CompositeExprNode( );189 CompositeExprNode( conststd::string * );200 CompositeExprNode( void ); 201 CompositeExprNode( std::string * ); 190 202 CompositeExprNode( ExpressionNode *f, ExpressionNode *args = 0 ); 191 203 CompositeExprNode( ExpressionNode *f, ExpressionNode *arg1, ExpressionNode *arg2 ); … … 266 278 public: 267 279 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 }; 269 281 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 }; 272 284 enum TypeClass { Type, Dtype, Ftype }; 273 285 274 static const char *storageName[];275 286 static const char *qualifierName[]; 276 287 static const char *basicTypeName[]; 277 288 static const char *modifierName[]; 278 static const char * aggregateName[];289 static const char *tyConName[]; 279 290 static const char *typeClassName[]; 280 291 … … 287 298 static DeclarationNode *newForall( DeclarationNode *); 288 299 static DeclarationNode *newFromTypedef( std::string *); 289 static DeclarationNode *newAggregate( Aggregatekind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields );300 static DeclarationNode *newAggregate( TyCon kind, std::string *name, DeclarationNode *formals, ExpressionNode *actuals, DeclarationNode *fields ); 290 301 static DeclarationNode *newEnum( std::string *name, DeclarationNode *constants ); 291 302 static DeclarationNode *newEnumConstant( std::string *name, ExpressionNode *constant ); 292 303 static DeclarationNode *newName( std::string *); 293 static DeclarationNode *newFromTypeGen( std::string *, ExpressionNode *params );304 static DeclarationNode *newFromTypeGen( std::string*, ExpressionNode *params ); 294 305 static DeclarationNode *newTypeParam( TypeClass, std::string *); 295 306 static DeclarationNode *newContext( std::string *name, DeclarationNode *params, DeclarationNode *asserts ); … … 302 313 static DeclarationNode *newTuple( DeclarationNode *members ); 303 314 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 ); 306 317 307 318 DeclarationNode *addQualifiers( DeclarationNode *); … … 329 340 DeclarationNode *cloneBaseType( DeclarationNode *newdecl ); 330 341 331 DeclarationNode *appendList( DeclarationNode *);342 DeclarationNode *appendList( DeclarationNode *); 332 343 333 344 DeclarationNode *clone() const; … … 339 350 340 351 bool get_hasEllipsis() const; 341 const std::string &get_name() const { return name; }352 std::string get_name() const { return name; } 342 353 LinkageSpec::Type get_linkage() const { return linkage; } 343 354 DeclarationNode *extractAggregate() const; … … 346 357 ~DeclarationNode(); 347 358 private: 348 StorageClass buildStorageClass() const;349 bool build FuncSpecifier( StorageClass key) const;359 Declaration::StorageClass buildStorageClass() const; 360 bool buildInline() const; 350 361 351 362 TypeData *type; … … 369 380 }; 370 381 371 StatementNode( );372 StatementNode( const std::string *);382 StatementNode( void ); 383 StatementNode( std::string ); 373 384 StatementNode( Type, ExpressionNode *e = 0, StatementNode *s = 0 ); 374 385 StatementNode( Type, std::string *target ); … … 376 387 377 388 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 ); 381 392 382 393 void set_control( ExpressionNode * ); … … 385 396 ExpressionNode *get_control() const ; 386 397 StatementNode *get_block() const; 387 StatementNode::Type get_type( ) const;388 389 StatementNode *add_label( conststd::string * );398 StatementNode::Type get_type( void ) const; 399 400 StatementNode *add_label( std::string * ); 390 401 std::list<std::string> *get_labels() const; 391 402 … … 418 429 class CompoundStmtNode : public StatementNode { 419 430 public: 420 CompoundStmtNode( );421 CompoundStmtNode( conststd::string * );431 CompoundStmtNode( void ); 432 CompoundStmtNode( std::string * ); 422 433 CompoundStmtNode( StatementNode * ); 423 434 ~CompoundStmtNode(); … … 488 499 489 500 // in DeclarationNode.cc 490 void buildList( const DeclarationNode *firstNode, std::list< Declaration * > &outputList );501 void buildList( const DeclarationNode *firstNode, std::list< Declaration *> &outputList ); 491 502 void buildList( const DeclarationNode *firstNode, std::list< DeclarationWithType *> &outputList ); 492 void buildTypeList( const DeclarationNode *firstNode, std::list< Type * > &outputList );503 void buildTypeList( const DeclarationNode *firstNode, std::list< Type *> &outputList ); 493 504 494 505 // in ExpressionNode.cc
Note:
See TracChangeset
for help on using the changeset viewer.