1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
8 #include "antlr4-common.h"
13 class ANTLR4CPP_PUBLIC ParseTreeWalker {
15 static ParseTreeWalker &DEFAULT;
17 virtual ~ParseTreeWalker();
21 * Performs a walk on the given parse tree starting at the root and going down recursively
22 * with depth-first search. On each node, <seealso cref="ParseTreeWalker#enterRule"/> is called before
23 * recursively walking down into child nodes, then
24 * <seealso cref="ParseTreeWalker#exitRule"/> is called after the recursive call to wind up.
26 * <param name='listener'> The listener used by the walker to process grammar rules </param>
27 * <param name='t'> The parse tree to be walked on </param>
29 virtual void walk(ParseTreeListener *listener, ParseTree *t) const;
35 * Enters a grammar rule by first triggering the generic event <seealso cref="ParseTreeListener#enterEveryRule"/>
36 * then by triggering the event specific to the given parse tree node
38 * <param name='listener'> The listener responding to the trigger events </param>
39 * <param name='r'> The grammar rule containing the rule context </param>
41 virtual void enterRule(ParseTreeListener *listener, ParseTree *r) const;
45 * Exits a grammar rule by first triggering the event specific to the given parse tree node
46 * then by triggering the generic event <seealso cref="ParseTreeListener#exitEveryRule"/>
48 * <param name='listener'> The listener responding to the trigger events </param>
49 * <param name='r'> The grammar rule containing the rule context </param>
51 virtual void exitRule(ParseTreeListener *listener, ParseTree *r) const;