1- #ifndef INC_BaseAST_hpp__
2- #define INC_BaseAST_hpp__
1+ #ifndef INC_BaseAST_hpp_
2+ #define INC_BaseAST_hpp_
33
44/* ANTLR Translator Generator
55 * Project led by Terence Parr at http://www.jGuru.com
@@ -23,100 +23,100 @@ class ANTLR_API BaseAST : public AST {
2323 BaseAST ();
2424 BaseAST (const BaseAST& other);
2525
26- virtual ~BaseAST ();
26+ ~BaseAST () override ;
2727
2828 // / Return the class name
29- virtual const char * typeName ( void ) const ;
29+ const char * typeName () const override ;
3030
3131 // / Clone this AST node.
32- virtual RefAST clone ( void ) const ;
32+ RefAST clone () const override ;
3333
3434 // / Is node t equal to this in terms of token type and text?
35- virtual bool equals (RefAST t) const ;
35+ bool equals (RefAST t) const override ;
3636
3737 /* * Is t an exact structural and equals() match of this tree. The
3838 * 'this' reference is considered the start of a sibling list.
3939 */
40- virtual bool equalsList (RefAST t) const ;
40+ bool equalsList (RefAST t) const override ;
4141
4242 /* * Is 't' a subtree of this list? The siblings of the root are NOT ignored.
4343 */
44- virtual bool equalsListPartial (RefAST t) const ;
44+ bool equalsListPartial (RefAST t) const override ;
4545
4646 /* * Is tree rooted at 'this' equal to 't'? The siblings of 'this' are
4747 * ignored.
4848 */
49- virtual bool equalsTree (RefAST t) const ;
49+ bool equalsTree (RefAST t) const override ;
5050
5151 /* * Is 't' a subtree of the tree rooted at 'this'? The siblings of
5252 * 'this' are ignored.
5353 */
54- virtual bool equalsTreePartial (RefAST t) const ;
54+ bool equalsTreePartial (RefAST t) const override ;
5555
5656 /* * Walk the tree looking for all exact subtree matches. Return
5757 * an ASTEnumerator that lets the caller walk the list
5858 * of subtree roots found herein.
5959 */
60- virtual ANTLR_USE_NAMESPACE (std)vector<RefAST> findAll(RefAST t);
60+ ANTLR_USE_NAMESPACE (std)vector<RefAST> findAll (RefAST t) override ;
6161
6262 /* * Walk the tree looking for all subtrees. Return
6363 * an ASTEnumerator that lets the caller walk the list
6464 * of subtree roots found herein.
6565 */
66- virtual ANTLR_USE_NAMESPACE (std)vector<RefAST> findAllPartial(RefAST t);
66+ ANTLR_USE_NAMESPACE (std)vector<RefAST> findAllPartial (RefAST t) override ;
6767
6868 // / Add a node to the end of the child list for this node
69- virtual void addChild (RefAST c);
69+ void addChild (RefAST c) override ;
7070 /* * Get the number of child nodes of this node (shallow e.g. not of the
7171 * whole tree it spans).
7272 */
73- virtual size_t getNumberOfChildren () const ;
73+ size_t getNumberOfChildren () const override ;
7474
7575 // / Get the first child of this node; null if no children
76- virtual RefAST getFirstChild () const
76+ RefAST getFirstChild () const override
7777 {
78- return RefAST ( down) ;
78+ return { down} ;
7979 }
8080 // / Get the next sibling in line after this one
81- virtual RefAST getNextSibling () const
81+ RefAST getNextSibling () const override
8282 {
83- return RefAST ( right) ;
83+ return { right} ;
8484 }
8585
8686 // / Get the token text for this node
87- virtual ANTLR_USE_NAMESPACE (std)string getText() const
87+ ANTLR_USE_NAMESPACE (std)string getText () const override
8888 {
8989 return " " ;
9090 }
9191 // / Get the token type for this node
92- virtual int getType () const
92+ int getType () const override
9393 {
9494 return 0 ;
9595 }
9696
9797 // / Remove all children
9898 virtual void removeChildren ()
9999 {
100- down = static_cast <BaseAST*>(static_cast <AST*>(nullAST));
100+ down = dynamic_cast <BaseAST*>(static_cast <AST*>(nullAST));
101101 }
102102
103103 // / Set the first child of a node.
104- virtual void setFirstChild (RefAST c)
104+ void setFirstChild (RefAST c) override
105105 {
106- down = static_cast <BaseAST*>(static_cast <AST*>(c));
106+ down = dynamic_cast <BaseAST*>(static_cast <AST*>(c));
107107 }
108108
109109 // / Set the next sibling after this one.
110- void setNextSibling (RefAST n)
110+ void setNextSibling (RefAST n) override
111111 {
112- right = static_cast <BaseAST*>(static_cast <AST*>(n));
112+ right = dynamic_cast <BaseAST*>(static_cast <AST*>(n));
113113 }
114114
115115 // / Set the token text for this node
116- virtual void setText (const ANTLR_USE_NAMESPACE (std)string& txt);
116+ void setText (const ANTLR_USE_NAMESPACE (std)string& txt) override ;
117117
118118 // / Set the token type for this node
119- virtual void setType (int type);
119+ void setType (int type) override ;
120120
121121#ifdef ANTLR_SUPPORT_XML
122122 /* * print attributes of this node to 'out'. Override to customize XML
@@ -132,19 +132,19 @@ class ANTLR_API BaseAST : public AST {
132132#endif
133133
134134 // / Return string representation for the AST
135- virtual ANTLR_USE_NAMESPACE (std)string toString() const ;
135+ ANTLR_USE_NAMESPACE (std)string toString() const override ;
136136
137137 // / Print out a child sibling tree in LISP notation
138- virtual ANTLR_USE_NAMESPACE (std)string toStringList() const ;
139- virtual ANTLR_USE_NAMESPACE (std)string toStringTree() const ;
138+ ANTLR_USE_NAMESPACE (std)string toStringList() const override ;
139+ ANTLR_USE_NAMESPACE (std)string toStringTree() const override ;
140140
141141 static const char * const TYPE_NAME;
142142protected:
143143 RefBaseAST down;
144144 RefBaseAST right;
145145private:
146146 void doWorkForFindAll (ANTLR_USE_NAMESPACE(std)vector<RefAST>& v,
147- RefAST target,
147+ const RefAST& target,
148148 bool partialMatch);
149149};
150150
@@ -161,4 +161,4 @@ inline bool BaseAST::equals(RefAST t) const
161161}
162162#endif
163163
164- #endif // INC_BaseAST_hpp__
164+ #endif // INC_BaseAST_hpp_
0 commit comments