Changeset f6e8c67 for src/Parser/ParseNode.h
- Timestamp:
- Mar 6, 2024, 6:06:43 AM (22 months ago)
- Branches:
- master
- Children:
- 647d633
- Parents:
- bbf2cb1 (diff), af60383 (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. - File:
-
- 1 edited
-
src/Parser/ParseNode.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ParseNode.h
rbbf2cb1 rf6e8c67 33 33 34 34 struct DeclarationNode; 35 classInitializerNode;36 classExpressionNode;35 struct InitializerNode; 36 struct ExpressionNode; 37 37 struct StatementNode; 38 38 … … 45 45 extern YYLTYPE yylloc; 46 46 47 class ParseNode { 48 public: 49 ParseNode() {}; 50 virtual ~ParseNode() { delete next; delete name; }; 47 struct ParseNode { 48 ParseNode() {} 49 virtual ~ParseNode() {} 51 50 virtual ParseNode * clone() const = 0; 52 51 53 ParseNode * get_next() const { return next; } 54 ParseNode * set_next( ParseNode * newlink ) { next = newlink; return this; } 52 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {} 55 53 56 ParseNode * get_last() { 57 ParseNode * current; 58 for ( current = this; current->get_next() != nullptr; current = current->get_next() ); 54 static int indent_by; 55 56 CodeLocation location = yylloc; 57 }; // ParseNode 58 59 /// Only ever use in the form `struct NAME final : public ParseList<NAME>`! 60 template<typename Next> 61 struct ParseList : public ParseNode { 62 ParseList() {} 63 virtual ~ParseList() { delete next; }; 64 virtual ParseList<Next> * clone() const = 0; 65 66 Next * get_last() { 67 Next * current = static_cast<Next *>( this ); 68 while ( current->next != nullptr ) current = current->next; 59 69 return current; 60 70 } 61 ParseNode * set_last( ParseNode* newlast ) {62 if ( newlast != nullptr ) get_last()-> set_next( newlast );63 return this;71 Next * set_last( Next * newlast ) { 72 if ( newlast != nullptr ) get_last()->next = newlast; 73 return static_cast<Next *>( this ); 64 74 } 65 75 66 virtual void print( __attribute__((unused)) std::ostream & os, __attribute__((unused)) int indent = 0 ) const {}67 76 virtual void printList( std::ostream & os, int indent = 0 ) const { 68 77 print( os, indent ); … … 70 79 } 71 80 72 static int indent_by; 73 74 ParseNode * next = nullptr; 75 const std::string * name = nullptr; 76 CodeLocation location = yylloc; 77 }; // ParseNode 81 Next * next = nullptr; 82 }; 78 83 79 84 // Must harmonize with OperName.
Note:
See TracChangeset
for help on using the changeset viewer.