xref: /aosp_15_r20/external/antlr/runtime/C/include/antlr3commontreenodestream.h (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot /// \file
2*16467b97STreehugger Robot /// Definition of the ANTLR3 common tree node stream.
3*16467b97STreehugger Robot ///
4*16467b97STreehugger Robot 
5*16467b97STreehugger Robot #ifndef	_ANTLR3_COMMON_TREE_NODE_STREAM__H
6*16467b97STreehugger Robot #define	_ANTLR3_COMMON_TREE_NODE_STREAM__H
7*16467b97STreehugger Robot 
8*16467b97STreehugger Robot // [The "BSD licence"]
9*16467b97STreehugger Robot // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
10*16467b97STreehugger Robot // http://www.temporal-wave.com
11*16467b97STreehugger Robot // http://www.linkedin.com/in/jimidle
12*16467b97STreehugger Robot //
13*16467b97STreehugger Robot // All rights reserved.
14*16467b97STreehugger Robot //
15*16467b97STreehugger Robot // Redistribution and use in source and binary forms, with or without
16*16467b97STreehugger Robot // modification, are permitted provided that the following conditions
17*16467b97STreehugger Robot // are met:
18*16467b97STreehugger Robot // 1. Redistributions of source code must retain the above copyright
19*16467b97STreehugger Robot //    notice, this list of conditions and the following disclaimer.
20*16467b97STreehugger Robot // 2. Redistributions in binary form must reproduce the above copyright
21*16467b97STreehugger Robot //    notice, this list of conditions and the following disclaimer in the
22*16467b97STreehugger Robot //    documentation and/or other materials provided with the distribution.
23*16467b97STreehugger Robot // 3. The name of the author may not be used to endorse or promote products
24*16467b97STreehugger Robot //    derived from this software without specific prior written permission.
25*16467b97STreehugger Robot //
26*16467b97STreehugger Robot // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27*16467b97STreehugger Robot // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28*16467b97STreehugger Robot // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29*16467b97STreehugger Robot // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30*16467b97STreehugger Robot // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31*16467b97STreehugger Robot // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32*16467b97STreehugger Robot // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33*16467b97STreehugger Robot // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34*16467b97STreehugger Robot // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35*16467b97STreehugger Robot // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36*16467b97STreehugger Robot 
37*16467b97STreehugger Robot #include    <antlr3defs.h>
38*16467b97STreehugger Robot #include    <antlr3commontreeadaptor.h>
39*16467b97STreehugger Robot #include    <antlr3commontree.h>
40*16467b97STreehugger Robot #include    <antlr3collections.h>
41*16467b97STreehugger Robot #include    <antlr3intstream.h>
42*16467b97STreehugger Robot #include    <antlr3string.h>
43*16467b97STreehugger Robot 
44*16467b97STreehugger Robot /// Token buffer initial size settings ( will auto increase)
45*16467b97STreehugger Robot ///
46*16467b97STreehugger Robot #define	DEFAULT_INITIAL_BUFFER_SIZE		100
47*16467b97STreehugger Robot #define	INITIAL_CALL_STACK_SIZE			10
48*16467b97STreehugger Robot 
49*16467b97STreehugger Robot #ifdef __cplusplus
50*16467b97STreehugger Robot extern "C" {
51*16467b97STreehugger Robot #endif
52*16467b97STreehugger Robot 
53*16467b97STreehugger Robot typedef	struct ANTLR3_TREE_NODE_STREAM_struct
54*16467b97STreehugger Robot {
55*16467b97STreehugger Robot     /// Any interface that implements this interface (is a
56*16467b97STreehugger Robot     ///  super structure containing this structure), may store the pointer
57*16467b97STreehugger Robot     ///  to itself here in the super pointer, which is not used by
58*16467b97STreehugger Robot     ///  the tree node stream. This will point to an implementation
59*16467b97STreehugger Robot     ///  of ANTLR3_COMMON_TREE_NODE_STREAM in this case.
60*16467b97STreehugger Robot     ///
61*16467b97STreehugger Robot     pANTLR3_COMMON_TREE_NODE_STREAM	ctns;
62*16467b97STreehugger Robot 
63*16467b97STreehugger Robot     /// All input streams implement the ANTLR3_INT_STREAM interface...
64*16467b97STreehugger Robot     ///
65*16467b97STreehugger Robot     pANTLR3_INT_STREAM			istream;
66*16467b97STreehugger Robot 
67*16467b97STreehugger Robot 	/// Get tree node at current input pointer + i ahead where i=1 is next node.
68*16467b97STreehugger Robot 	/// i<0 indicates nodes in the past.  So LT(-1) is previous node, but
69*16467b97STreehugger Robot 	/// implementations are not required to provide results for k < -1.
70*16467b97STreehugger Robot 	/// LT(0) is undefined.  For i>=n, return null.
71*16467b97STreehugger Robot 	/// Return NULL for LT(0) and any index that results in an absolute address
72*16467b97STreehugger Robot 	/// that is negative (beyond the start of the list).
73*16467b97STreehugger Robot 	///
74*16467b97STreehugger Robot 	/// This is analogous to the LT() method of the TokenStream, but this
75*16467b97STreehugger Robot 	/// returns a tree node instead of a token.  Makes code gen identical
76*16467b97STreehugger Robot 	/// for both parser and tree grammars. :)
77*16467b97STreehugger Robot 	///
78*16467b97STreehugger Robot     pANTLR3_BASE_TREE			(*_LT)							(struct ANTLR3_TREE_NODE_STREAM_struct * tns, ANTLR3_INT32 k);
79*16467b97STreehugger Robot 
80*16467b97STreehugger Robot 	/// Where is this stream pulling nodes from?  This is not the name, but
81*16467b97STreehugger Robot 	/// the object that provides node objects.
82*16467b97STreehugger Robot 	///
83*16467b97STreehugger Robot     pANTLR3_BASE_TREE			(*getTreeSource)				(struct ANTLR3_TREE_NODE_STREAM_struct * tns);
84*16467b97STreehugger Robot 
85*16467b97STreehugger Robot 	/// What adaptor can tell me how to interpret/navigate nodes and
86*16467b97STreehugger Robot 	/// trees.  E.g., get text of a node.
87*16467b97STreehugger Robot 	///
88*16467b97STreehugger Robot     pANTLR3_BASE_TREE_ADAPTOR	(*getTreeAdaptor)				(struct ANTLR3_TREE_NODE_STREAM_struct * tns);
89*16467b97STreehugger Robot 
90*16467b97STreehugger Robot 	/// As we flatten the tree, we use UP, DOWN nodes to represent
91*16467b97STreehugger Robot 	/// the tree structure.  When debugging we need unique nodes
92*16467b97STreehugger Robot 	/// so we have to instantiate new ones.  When doing normal tree
93*16467b97STreehugger Robot 	/// parsing, it's slow and a waste of memory to create unique
94*16467b97STreehugger Robot 	/// navigation nodes.  Default should be false;
95*16467b97STreehugger Robot 	///
96*16467b97STreehugger Robot     void						(*setUniqueNavigationNodes)		(struct ANTLR3_TREE_NODE_STREAM_struct * tns, ANTLR3_BOOLEAN uniqueNavigationNodes);
97*16467b97STreehugger Robot 
98*16467b97STreehugger Robot     pANTLR3_STRING				(*toString)						(struct ANTLR3_TREE_NODE_STREAM_struct * tns);
99*16467b97STreehugger Robot 
100*16467b97STreehugger Robot 	/// Return the text of all nodes from start to stop, inclusive.
101*16467b97STreehugger Robot 	/// If the stream does not buffer all the nodes then it can still
102*16467b97STreehugger Robot 	/// walk recursively from start until stop.  You can always return
103*16467b97STreehugger Robot 	/// null or "" too, but users should not access $ruleLabel.text in
104*16467b97STreehugger Robot 	/// an action of course in that case.
105*16467b97STreehugger Robot 	///
106*16467b97STreehugger Robot     pANTLR3_STRING				(*toStringSS)					(struct ANTLR3_TREE_NODE_STREAM_struct * tns, pANTLR3_BASE_TREE start, pANTLR3_BASE_TREE stop);
107*16467b97STreehugger Robot 
108*16467b97STreehugger Robot 	/// Return the text of all nodes from start to stop, inclusive, into the
109*16467b97STreehugger Robot 	/// supplied buffer.
110*16467b97STreehugger Robot 	/// If the stream does not buffer all the nodes then it can still
111*16467b97STreehugger Robot 	/// walk recursively from start until stop.  You can always return
112*16467b97STreehugger Robot 	/// null or "" too, but users should not access $ruleLabel.text in
113*16467b97STreehugger Robot 	/// an action of course in that case.
114*16467b97STreehugger Robot 	///
115*16467b97STreehugger Robot     void						(*toStringWork)					(struct ANTLR3_TREE_NODE_STREAM_struct * tns, pANTLR3_BASE_TREE start, pANTLR3_BASE_TREE stop, pANTLR3_STRING buf);
116*16467b97STreehugger Robot 
117*16467b97STreehugger Robot 	/// Release up any and all space the the interface allocate, including for this structure.
118*16467b97STreehugger Robot 	///
119*16467b97STreehugger Robot     void						(*free)							(struct ANTLR3_TREE_NODE_STREAM_struct * tns);
120*16467b97STreehugger Robot 
121*16467b97STreehugger Robot 	/// Get a tree node at an absolute index i; 0..n-1.
122*16467b97STreehugger Robot 	/// If you don't want to buffer up nodes, then this method makes no
123*16467b97STreehugger Robot 	/// sense for you.
124*16467b97STreehugger Robot 	///
125*16467b97STreehugger Robot 	pANTLR3_BASE_TREE			(*get)							(struct ANTLR3_TREE_NODE_STREAM_struct * tns, ANTLR3_INT32 i);
126*16467b97STreehugger Robot 
127*16467b97STreehugger Robot 	// REWRITING TREES (used by tree parser)
128*16467b97STreehugger Robot 
129*16467b97STreehugger Robot 	/// Replace from start to stop child index of parent with t, which might
130*16467b97STreehugger Robot 	/// be a list.  Number of children may be different
131*16467b97STreehugger Robot 	/// after this call.  The stream is notified because it is walking the
132*16467b97STreehugger Robot 	/// tree and might need to know you are monkeying with the underlying
133*16467b97STreehugger Robot 	/// tree.  Also, it might be able to modify the node stream to avoid
134*16467b97STreehugger Robot 	/// restreaming for future phases.
135*16467b97STreehugger Robot 	///
136*16467b97STreehugger Robot 	/// If parent is null, don't do anything; must be at root of overall tree.
137*16467b97STreehugger Robot 	/// Can't replace whatever points to the parent externally.  Do nothing.
138*16467b97STreehugger Robot 	///
139*16467b97STreehugger Robot 	void						(*replaceChildren)				(struct ANTLR3_TREE_NODE_STREAM_struct * tns, pANTLR3_BASE_TREE parent, ANTLR3_INT32 startChildIndex, ANTLR3_INT32 stopChildIndex, pANTLR3_BASE_TREE t);
140*16467b97STreehugger Robot 
141*16467b97STreehugger Robot }
142*16467b97STreehugger Robot     ANTLR3_TREE_NODE_STREAM;
143*16467b97STreehugger Robot 
144*16467b97STreehugger Robot typedef	struct ANTLR3_COMMON_TREE_NODE_STREAM_struct
145*16467b97STreehugger Robot {
146*16467b97STreehugger Robot     /// Any interface that implements this interface (is a
147*16467b97STreehugger Robot     /// super structure containing this structure), may store the pointer
148*16467b97STreehugger Robot     /// to itself here in the super pointer, which is not used by
149*16467b97STreehugger Robot     /// the common tree node stream.
150*16467b97STreehugger Robot     ///
151*16467b97STreehugger Robot     void						* super;
152*16467b97STreehugger Robot 
153*16467b97STreehugger Robot     /// Pointer to the tree node stream interface
154*16467b97STreehugger Robot     ///
155*16467b97STreehugger Robot     pANTLR3_TREE_NODE_STREAM	tnstream;
156*16467b97STreehugger Robot 
157*16467b97STreehugger Robot     /// String factory for use by anything that wishes to create strings
158*16467b97STreehugger Robot     /// such as a tree representation or some copy of the text etc.
159*16467b97STreehugger Robot     ///
160*16467b97STreehugger Robot     pANTLR3_STRING_FACTORY		stringFactory;
161*16467b97STreehugger Robot 
162*16467b97STreehugger Robot     /// Dummy tree node that indicates a descent into a child
163*16467b97STreehugger Robot     /// tree. Initialized by a call to create a new interface.
164*16467b97STreehugger Robot     ///
165*16467b97STreehugger Robot     ANTLR3_COMMON_TREE			DOWN;
166*16467b97STreehugger Robot 
167*16467b97STreehugger Robot     /// Dummy tree node that indicates a descent up to a parent
168*16467b97STreehugger Robot     /// tree. Initialized by a call to create a new interface.
169*16467b97STreehugger Robot     ///
170*16467b97STreehugger Robot     ANTLR3_COMMON_TREE			UP;
171*16467b97STreehugger Robot 
172*16467b97STreehugger Robot     /// Dummy tree node that indicates the termination point of the
173*16467b97STreehugger Robot     /// tree. Initialized by a call to create a new interface.
174*16467b97STreehugger Robot     ///
175*16467b97STreehugger Robot     ANTLR3_COMMON_TREE			EOF_NODE;
176*16467b97STreehugger Robot 
177*16467b97STreehugger Robot     /// Dummy node that is returned if we need to indicate an invalid node
178*16467b97STreehugger Robot     /// for any reason.
179*16467b97STreehugger Robot     ///
180*16467b97STreehugger Robot     ANTLR3_COMMON_TREE			INVALID_NODE;
181*16467b97STreehugger Robot 
182*16467b97STreehugger Robot 	/// The complete mapping from stream index to tree node.
183*16467b97STreehugger Robot 	/// This buffer includes pointers to DOWN, UP, and EOF nodes.
184*16467b97STreehugger Robot 	/// It is built upon ctor invocation.  The elements are type
185*16467b97STreehugger Robot 	/// Object as we don't what the trees look like.
186*16467b97STreehugger Robot 	///
187*16467b97STreehugger Robot 	/// Load upon first need of the buffer so we can set token types
188*16467b97STreehugger Robot 	/// of interest for reverseIndexing.  Slows us down a wee bit to
189*16467b97STreehugger Robot 	/// do all of the if p==-1 testing everywhere though, though in C
190*16467b97STreehugger Robot 	/// you won't really be able to measure this.
191*16467b97STreehugger Robot 	///
192*16467b97STreehugger Robot 	/// Must be freed when the tree node stream is torn down.
193*16467b97STreehugger Robot 	///
194*16467b97STreehugger Robot 	pANTLR3_VECTOR				nodes;
195*16467b97STreehugger Robot 
196*16467b97STreehugger Robot     /// If set to ANTLR3_TRUE then the navigation nodes UP, DOWN are
197*16467b97STreehugger Robot     /// duplicated rather than reused within the tree.
198*16467b97STreehugger Robot     ///
199*16467b97STreehugger Robot     ANTLR3_BOOLEAN				uniqueNavigationNodes;
200*16467b97STreehugger Robot 
201*16467b97STreehugger Robot     /// Which tree are we navigating ?
202*16467b97STreehugger Robot     ///
203*16467b97STreehugger Robot     pANTLR3_BASE_TREE			root;
204*16467b97STreehugger Robot 
205*16467b97STreehugger Robot     /// Pointer to tree adaptor interface that manipulates/builds
206*16467b97STreehugger Robot     /// the tree.
207*16467b97STreehugger Robot     ///
208*16467b97STreehugger Robot     pANTLR3_BASE_TREE_ADAPTOR	adaptor;
209*16467b97STreehugger Robot 
210*16467b97STreehugger Robot     /// As we walk down the nodes, we must track parent nodes so we know
211*16467b97STreehugger Robot     /// where to go after walking the last child of a node.  When visiting
212*16467b97STreehugger Robot     /// a child, push current node and current index (current index
213*16467b97STreehugger Robot     /// is first stored in the tree node structure to avoid two stacks.
214*16467b97STreehugger Robot     ///
215*16467b97STreehugger Robot     pANTLR3_STACK				nodeStack;
216*16467b97STreehugger Robot 
217*16467b97STreehugger Robot 	/// The current index into the nodes vector of the current tree
218*16467b97STreehugger Robot 	/// we are parsing and possibly rewriting.
219*16467b97STreehugger Robot 	///
220*16467b97STreehugger Robot 	ANTLR3_INT32				p;
221*16467b97STreehugger Robot 
222*16467b97STreehugger Robot     /// Which node are we currently visiting?
223*16467b97STreehugger Robot     ///
224*16467b97STreehugger Robot     pANTLR3_BASE_TREE			currentNode;
225*16467b97STreehugger Robot 
226*16467b97STreehugger Robot     /// Which node did we last visit? Used for LT(-1)
227*16467b97STreehugger Robot     ///
228*16467b97STreehugger Robot     pANTLR3_BASE_TREE			previousNode;
229*16467b97STreehugger Robot 
230*16467b97STreehugger Robot     /// Which child are we currently visiting?  If -1 we have not visited
231*16467b97STreehugger Robot     /// this node yet; next consume() request will set currentIndex to 0.
232*16467b97STreehugger Robot     ///
233*16467b97STreehugger Robot     ANTLR3_INT32				currentChildIndex;
234*16467b97STreehugger Robot 
235*16467b97STreehugger Robot     /// What node index did we just consume?  i=0..n-1 for n node trees.
236*16467b97STreehugger Robot     /// IntStream.next is hence 1 + this value.  Size will be same.
237*16467b97STreehugger Robot     ///
238*16467b97STreehugger Robot     ANTLR3_MARKER				absoluteNodeIndex;
239*16467b97STreehugger Robot 
240*16467b97STreehugger Robot     /// Buffer tree node stream for use with LT(i).  This list grows
241*16467b97STreehugger Robot     /// to fit new lookahead depths, but consume() wraps like a circular
242*16467b97STreehugger Robot     /// buffer.
243*16467b97STreehugger Robot     ///
244*16467b97STreehugger Robot     pANTLR3_BASE_TREE	      * lookAhead;
245*16467b97STreehugger Robot 
246*16467b97STreehugger Robot     /// Number of elements available in the lookahead buffer at any point in
247*16467b97STreehugger Robot     ///  time. This is the current size of the array.
248*16467b97STreehugger Robot     ///
249*16467b97STreehugger Robot     ANTLR3_UINT32				lookAheadLength;
250*16467b97STreehugger Robot 
251*16467b97STreehugger Robot     /// lookAhead[head] is the first symbol of lookahead, LT(1).
252*16467b97STreehugger Robot     ///
253*16467b97STreehugger Robot     ANTLR3_UINT32				head;
254*16467b97STreehugger Robot 
255*16467b97STreehugger Robot     /// Add new lookahead at lookahead[tail].  tail wraps around at the
256*16467b97STreehugger Robot     /// end of the lookahead buffer so tail could be less than head.
257*16467b97STreehugger Robot     ///
258*16467b97STreehugger Robot     ANTLR3_UINT32				tail;
259*16467b97STreehugger Robot 
260*16467b97STreehugger Robot     /// Calls to mark() may be nested so we have to track a stack of
261*16467b97STreehugger Robot     /// them.  The marker is an index into this stack.  Index 0 is
262*16467b97STreehugger Robot     /// the first marker.  This is a List<TreeWalkState>
263*16467b97STreehugger Robot     ///
264*16467b97STreehugger Robot     pANTLR3_VECTOR				markers;
265*16467b97STreehugger Robot 
266*16467b97STreehugger Robot     // INTERFACE
267*16467b97STreehugger Robot 	//
268*16467b97STreehugger Robot     void				(*fill)						(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns, ANTLR3_INT32 k);
269*16467b97STreehugger Robot 
270*16467b97STreehugger Robot     void				(*addLookahead)				(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns, pANTLR3_BASE_TREE node);
271*16467b97STreehugger Robot 
272*16467b97STreehugger Robot     ANTLR3_BOOLEAN	    (*hasNext)					(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
273*16467b97STreehugger Robot 
274*16467b97STreehugger Robot     pANTLR3_BASE_TREE	(*next)						(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
275*16467b97STreehugger Robot 
276*16467b97STreehugger Robot     pANTLR3_BASE_TREE	(*handleRootnode)			(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
277*16467b97STreehugger Robot 
278*16467b97STreehugger Robot     pANTLR3_BASE_TREE	(*visitChild)				(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns, ANTLR3_UINT32 child);
279*16467b97STreehugger Robot 
280*16467b97STreehugger Robot     void				(*addNavigationNode)		(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns, ANTLR3_UINT32 ttype);
281*16467b97STreehugger Robot 
282*16467b97STreehugger Robot     pANTLR3_BASE_TREE	(*newDownNode)				(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
283*16467b97STreehugger Robot 
284*16467b97STreehugger Robot 	pANTLR3_BASE_TREE	(*newUpNode)				(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
285*16467b97STreehugger Robot 
286*16467b97STreehugger Robot     void				(*walkBackToMostRecentNodeWithUnvisitedChildren)
287*16467b97STreehugger Robot 													(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
288*16467b97STreehugger Robot 
289*16467b97STreehugger Robot     ANTLR3_BOOLEAN	    (*hasUniqueNavigationNodes)	(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
290*16467b97STreehugger Robot 
291*16467b97STreehugger Robot     ANTLR3_UINT32	    (*getLookaheadSize)			(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
292*16467b97STreehugger Robot 
293*16467b97STreehugger Robot 	void				(*push)						(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns, ANTLR3_INT32 index);
294*16467b97STreehugger Robot 
295*16467b97STreehugger Robot 	ANTLR3_INT32		(*pop)						(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
296*16467b97STreehugger Robot 
297*16467b97STreehugger Robot     void				(*reset)					(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
298*16467b97STreehugger Robot 
299*16467b97STreehugger Robot     void				(*free)						(struct ANTLR3_COMMON_TREE_NODE_STREAM_struct * ctns);
300*16467b97STreehugger Robot 
301*16467b97STreehugger Robot 	/// Indicates whether this node stream was derived from a prior
302*16467b97STreehugger Robot 	/// node stream to be used by a rewriting tree parser for instance.
303*16467b97STreehugger Robot 	/// If this flag is set to ANTLR3_TRUE, then when this stream is
304*16467b97STreehugger Robot 	/// closed it will not free the root tree as this tree always
305*16467b97STreehugger Robot 	/// belongs to the origniating node stream.
306*16467b97STreehugger Robot 	///
307*16467b97STreehugger Robot 	ANTLR3_BOOLEAN				isRewriter;
308*16467b97STreehugger Robot 
309*16467b97STreehugger Robot }
310*16467b97STreehugger Robot     ANTLR3_COMMON_TREE_NODE_STREAM;
311*16467b97STreehugger Robot 
312*16467b97STreehugger Robot /** This structure is used to save the state information in the treenodestream
313*16467b97STreehugger Robot  *  when walking ahead with cyclic DFA or for syntactic predicates,
314*16467b97STreehugger Robot  *  we need to record the state of the tree node stream.  This
315*16467b97STreehugger Robot  *  class wraps up the current state of the CommonTreeNodeStream.
316*16467b97STreehugger Robot  *  Calling mark() will push another of these on the markers stack.
317*16467b97STreehugger Robot  */
318*16467b97STreehugger Robot typedef struct ANTLR3_TREE_WALK_STATE_struct
319*16467b97STreehugger Robot {
320*16467b97STreehugger Robot     ANTLR3_UINT32			  currentChildIndex;
321*16467b97STreehugger Robot     ANTLR3_MARKER			  absoluteNodeIndex;
322*16467b97STreehugger Robot     pANTLR3_BASE_TREE		  currentNode;
323*16467b97STreehugger Robot     pANTLR3_BASE_TREE		  previousNode;
324*16467b97STreehugger Robot     ANTLR3_UINT32			  nodeStackSize;
325*16467b97STreehugger Robot     pANTLR3_BASE_TREE	    * lookAhead;
326*16467b97STreehugger Robot     ANTLR3_UINT32			  lookAheadLength;
327*16467b97STreehugger Robot     ANTLR3_UINT32			  tail;
328*16467b97STreehugger Robot     ANTLR3_UINT32			  head;
329*16467b97STreehugger Robot }
330*16467b97STreehugger Robot     ANTLR3_TREE_WALK_STATE;
331*16467b97STreehugger Robot 
332*16467b97STreehugger Robot #ifdef __cplusplus
333*16467b97STreehugger Robot }
334*16467b97STreehugger Robot #endif
335*16467b97STreehugger Robot 
336*16467b97STreehugger Robot #endif
337