xref: /aosp_15_r20/external/antlr/runtime/C/include/antlr3commontoken.h (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot /** \file
2*16467b97STreehugger Robot  * \brief Defines the interface for a common token.
3*16467b97STreehugger Robot  *
4*16467b97STreehugger Robot  * All token streams should provide their tokens using an instance
5*16467b97STreehugger Robot  * of this common token. A custom pointer is provided, wher you may attach
6*16467b97STreehugger Robot  * a further structure to enhance the common token if you feel the need
7*16467b97STreehugger Robot  * to do so. The C runtime will assume that a token provides implementations
8*16467b97STreehugger Robot  * of the interface functions, but all of them may be rplaced by your own
9*16467b97STreehugger Robot  * implementation if you require it.
10*16467b97STreehugger Robot  */
11*16467b97STreehugger Robot #ifndef	_ANTLR3_COMMON_TOKEN_H
12*16467b97STreehugger Robot #define	_ANTLR3_COMMON_TOKEN_H
13*16467b97STreehugger Robot 
14*16467b97STreehugger Robot // [The "BSD licence"]
15*16467b97STreehugger Robot // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
16*16467b97STreehugger Robot // http://www.temporal-wave.com
17*16467b97STreehugger Robot // http://www.linkedin.com/in/jimidle
18*16467b97STreehugger Robot //
19*16467b97STreehugger Robot // All rights reserved.
20*16467b97STreehugger Robot //
21*16467b97STreehugger Robot // Redistribution and use in source and binary forms, with or without
22*16467b97STreehugger Robot // modification, are permitted provided that the following conditions
23*16467b97STreehugger Robot // are met:
24*16467b97STreehugger Robot // 1. Redistributions of source code must retain the above copyright
25*16467b97STreehugger Robot //    notice, this list of conditions and the following disclaimer.
26*16467b97STreehugger Robot // 2. Redistributions in binary form must reproduce the above copyright
27*16467b97STreehugger Robot //    notice, this list of conditions and the following disclaimer in the
28*16467b97STreehugger Robot //    documentation and/or other materials provided with the distribution.
29*16467b97STreehugger Robot // 3. The name of the author may not be used to endorse or promote products
30*16467b97STreehugger Robot //    derived from this software without specific prior written permission.
31*16467b97STreehugger Robot //
32*16467b97STreehugger Robot // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
33*16467b97STreehugger Robot // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
34*16467b97STreehugger Robot // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
35*16467b97STreehugger Robot // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
36*16467b97STreehugger Robot // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
37*16467b97STreehugger Robot // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38*16467b97STreehugger Robot // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39*16467b97STreehugger Robot // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40*16467b97STreehugger Robot // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
41*16467b97STreehugger Robot // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42*16467b97STreehugger Robot 
43*16467b97STreehugger Robot #include    <antlr3defs.h>
44*16467b97STreehugger Robot 
45*16467b97STreehugger Robot /** How many tokens to allocate at once in the token factory
46*16467b97STreehugger Robot  */
47*16467b97STreehugger Robot #define	ANTLR3_FACTORY_POOL_SIZE    1024
48*16467b97STreehugger Robot 
49*16467b97STreehugger Robot /* Base token types, which all lexer/parser tokens come after in sequence.
50*16467b97STreehugger Robot  */
51*16467b97STreehugger Robot 
52*16467b97STreehugger Robot /** Indicator of an invalid token
53*16467b97STreehugger Robot  */
54*16467b97STreehugger Robot #define	ANTLR3_TOKEN_INVALID	0
55*16467b97STreehugger Robot 
56*16467b97STreehugger Robot #define	ANTLR3_EOR_TOKEN_TYPE	1
57*16467b97STreehugger Robot 
58*16467b97STreehugger Robot /** Imaginary token type to cause a traversal of child nodes in a tree parser
59*16467b97STreehugger Robot  */
60*16467b97STreehugger Robot #define	ANTLR3_TOKEN_DOWN		2
61*16467b97STreehugger Robot 
62*16467b97STreehugger Robot /** Imaginary token type to signal the end of a stream of child nodes.
63*16467b97STreehugger Robot  */
64*16467b97STreehugger Robot #define	ANTLR3_TOKEN_UP		3
65*16467b97STreehugger Robot 
66*16467b97STreehugger Robot /** First token that can be used by users/generated code
67*16467b97STreehugger Robot  */
68*16467b97STreehugger Robot 
69*16467b97STreehugger Robot #define	ANTLR3_MIN_TOKEN_TYPE	ANTLR3_TOKEN_UP + 1
70*16467b97STreehugger Robot 
71*16467b97STreehugger Robot /** End of file token
72*16467b97STreehugger Robot  */
73*16467b97STreehugger Robot #define	ANTLR3_TOKEN_EOF	(ANTLR3_CHARSTREAM_EOF & 0xFFFFFFFF)
74*16467b97STreehugger Robot 
75*16467b97STreehugger Robot /** Default channel for a token
76*16467b97STreehugger Robot  */
77*16467b97STreehugger Robot #define	ANTLR3_TOKEN_DEFAULT_CHANNEL	0
78*16467b97STreehugger Robot 
79*16467b97STreehugger Robot /** Reserved channel number for a HIDDEN token - a token that
80*16467b97STreehugger Robot  *  is hidden from the parser.
81*16467b97STreehugger Robot  */
82*16467b97STreehugger Robot #define	HIDDEN				99
83*16467b97STreehugger Robot 
84*16467b97STreehugger Robot #ifdef __cplusplus
85*16467b97STreehugger Robot extern "C" {
86*16467b97STreehugger Robot #endif
87*16467b97STreehugger Robot 
88*16467b97STreehugger Robot // Indicates whether this token is carrying:
89*16467b97STreehugger Robot //
90*16467b97STreehugger Robot // State | Meaning
91*16467b97STreehugger Robot // ------+--------------------------------------
92*16467b97STreehugger Robot //     0 | Nothing (neither rewrite text, nor setText)
93*16467b97STreehugger Robot //     1 | char * to user supplied rewrite text
94*16467b97STreehugger Robot //     2 | pANTLR3_STRING because of setText or similar action
95*16467b97STreehugger Robot //
96*16467b97STreehugger Robot #define	ANTLR3_TEXT_NONE	0
97*16467b97STreehugger Robot #define	ANTLR3_TEXT_CHARP	1
98*16467b97STreehugger Robot #define	ANTLR3_TEXT_STRING	2
99*16467b97STreehugger Robot 
100*16467b97STreehugger Robot /** The definition of an ANTLR3 common token structure, which all implementations
101*16467b97STreehugger Robot  * of a token stream should provide, installing any further structures in the
102*16467b97STreehugger Robot  * custom pointer element of this structure.
103*16467b97STreehugger Robot  *
104*16467b97STreehugger Robot  * \remark
105*16467b97STreehugger Robot  * Token streams are in essence provided by lexers or other programs that serve
106*16467b97STreehugger Robot  * as lexers.
107*16467b97STreehugger Robot  */
108*16467b97STreehugger Robot typedef	struct ANTLR3_COMMON_TOKEN_struct
109*16467b97STreehugger Robot {
110*16467b97STreehugger Robot     /** The actual type of this token
111*16467b97STreehugger Robot      */
112*16467b97STreehugger Robot     ANTLR3_UINT32   type;
113*16467b97STreehugger Robot 
114*16467b97STreehugger Robot     /** Indicates that a token was produced from the token factory and therefore
115*16467b97STreehugger Robot      *  the the freeToken() method should not do anything itself because
116*16467b97STreehugger Robot      *  token factory is responsible for deleting it.
117*16467b97STreehugger Robot      */
118*16467b97STreehugger Robot     ANTLR3_BOOLEAN  factoryMade;
119*16467b97STreehugger Robot 
120*16467b97STreehugger Robot 	/// A string factory that we can use if we ever need the text of a token
121*16467b97STreehugger Robot 	/// and need to manufacture a pANTLR3_STRING
122*16467b97STreehugger Robot 	///
123*16467b97STreehugger Robot 	pANTLR3_STRING_FACTORY	strFactory;
124*16467b97STreehugger Robot 
125*16467b97STreehugger Robot     /** The line number in the input stream where this token was derived from
126*16467b97STreehugger Robot      */
127*16467b97STreehugger Robot     ANTLR3_UINT32   line;
128*16467b97STreehugger Robot 
129*16467b97STreehugger Robot     /** The offset into the input stream that the line in which this
130*16467b97STreehugger Robot      *  token resides starts.
131*16467b97STreehugger Robot      */
132*16467b97STreehugger Robot     void	    * lineStart;
133*16467b97STreehugger Robot 
134*16467b97STreehugger Robot     /** The character position in the line that this token was derived from
135*16467b97STreehugger Robot      */
136*16467b97STreehugger Robot     ANTLR3_INT32    charPosition;
137*16467b97STreehugger Robot 
138*16467b97STreehugger Robot     /** The virtual channel that this token exists in.
139*16467b97STreehugger Robot      */
140*16467b97STreehugger Robot     ANTLR3_UINT32   channel;
141*16467b97STreehugger Robot 
142*16467b97STreehugger Robot     /** Pointer to the input stream that this token originated in.
143*16467b97STreehugger Robot      */
144*16467b97STreehugger Robot     pANTLR3_INPUT_STREAM    input;
145*16467b97STreehugger Robot 
146*16467b97STreehugger Robot     /** What the index of this token is, 0, 1, .., n-2, n-1 tokens
147*16467b97STreehugger Robot      */
148*16467b97STreehugger Robot     ANTLR3_MARKER   index;
149*16467b97STreehugger Robot 
150*16467b97STreehugger Robot     /** The character offset in the input stream where the text for this token
151*16467b97STreehugger Robot      *  starts.
152*16467b97STreehugger Robot      */
153*16467b97STreehugger Robot     ANTLR3_MARKER   start;
154*16467b97STreehugger Robot 
155*16467b97STreehugger Robot     /** The character offset in the input stream where the text for this token
156*16467b97STreehugger Robot      *  stops.
157*16467b97STreehugger Robot      */
158*16467b97STreehugger Robot     ANTLR3_MARKER   stop;
159*16467b97STreehugger Robot 
160*16467b97STreehugger Robot 	/// Indicates whether this token is carrying:
161*16467b97STreehugger Robot 	///
162*16467b97STreehugger Robot 	/// State | Meaning
163*16467b97STreehugger Robot 	/// ------+--------------------------------------
164*16467b97STreehugger Robot 	///     0 | Nothing (neither rewrite text, nor setText)
165*16467b97STreehugger Robot 	///     1 | char * to user supplied rewrite text
166*16467b97STreehugger Robot 	///     2 | pANTLR3_STRING because of setText or similar action
167*16467b97STreehugger Robot 	///
168*16467b97STreehugger Robot 	/// Affects the union structure tokText below
169*16467b97STreehugger Robot 	/// (uses 32 bit so alignment is always good)
170*16467b97STreehugger Robot 	///
171*16467b97STreehugger Robot 	ANTLR3_UINT32	textState;
172*16467b97STreehugger Robot 
173*16467b97STreehugger Robot 	union
174*16467b97STreehugger Robot 	{
175*16467b97STreehugger Robot 		/// Pointer that is used when the token just has a pointer to
176*16467b97STreehugger Robot 		/// a char *, such as when a rewrite of an imaginary token supplies
177*16467b97STreehugger Robot 		/// a string in the grammar. No sense in constructing a pANTLR3_STRING just
178*16467b97STreehugger Robot 		/// for that, as mostly the text will not be accessed - if it is, then
179*16467b97STreehugger Robot 		/// we will build a pANTLR3_STRING for it a that point.
180*16467b97STreehugger Robot 		///
181*16467b97STreehugger Robot 		pANTLR3_UCHAR	chars;
182*16467b97STreehugger Robot 
183*16467b97STreehugger Robot 		/// Some token types actually do carry around their associated text, hence
184*16467b97STreehugger Robot 		/// (*getText)() will return this pointer if it is not NULL
185*16467b97STreehugger Robot 		///
186*16467b97STreehugger Robot 		pANTLR3_STRING	text;
187*16467b97STreehugger Robot 	}
188*16467b97STreehugger Robot 		tokText;
189*16467b97STreehugger Robot 
190*16467b97STreehugger Robot     /**  Because it is a bit more of a hassle to override an ANTLR3_COMMON_TOKEN
191*16467b97STreehugger Robot      *   as the standard structure for a token, a number of user programmable
192*16467b97STreehugger Robot      *	 elements are allowed in a token. This is one of them.
193*16467b97STreehugger Robot      */
194*16467b97STreehugger Robot     ANTLR3_UINT32   user1;
195*16467b97STreehugger Robot 
196*16467b97STreehugger Robot     /**  Because it is a bit more of a hassle to override an ANTLR3_COMMON_TOKEN
197*16467b97STreehugger Robot      *   as the standard structure for a token, a number of user programmable
198*16467b97STreehugger Robot      *	 elements are allowed in a token. This is one of them.
199*16467b97STreehugger Robot      */
200*16467b97STreehugger Robot     ANTLR3_UINT32   user2;
201*16467b97STreehugger Robot 
202*16467b97STreehugger Robot     /**  Because it is a bit more of a hassle to override an ANTLR3_COMMON_TOKEN
203*16467b97STreehugger Robot      *   as the standard structure for a token, a number of user programmable
204*16467b97STreehugger Robot      *	 elements are allowed in a token. This is one of them.
205*16467b97STreehugger Robot      */
206*16467b97STreehugger Robot     ANTLR3_UINT32   user3;
207*16467b97STreehugger Robot 
208*16467b97STreehugger Robot     /** Pointer to a custom element that the ANTLR3 programmer may define and install
209*16467b97STreehugger Robot      */
210*16467b97STreehugger Robot     void    * custom;
211*16467b97STreehugger Robot 
212*16467b97STreehugger Robot     /** Pointer to a function that knows how to free the custom structure when the
213*16467b97STreehugger Robot      *  token is destroyed.
214*16467b97STreehugger Robot      */
215*16467b97STreehugger Robot     void    (*freeCustom)(void * custom);
216*16467b97STreehugger Robot 
217*16467b97STreehugger Robot     /* ==============================
218*16467b97STreehugger Robot      * API
219*16467b97STreehugger Robot      */
220*16467b97STreehugger Robot 
221*16467b97STreehugger Robot     /** Pointer to function that returns the text pointer of a token, use
222*16467b97STreehugger Robot      *  toString() if you want a pANTLR3_STRING version of the token.
223*16467b97STreehugger Robot      */
224*16467b97STreehugger Robot     pANTLR3_STRING  (*getText)(struct ANTLR3_COMMON_TOKEN_struct * token);
225*16467b97STreehugger Robot 
226*16467b97STreehugger Robot     /** Pointer to a function that 'might' be able to set the text associated
227*16467b97STreehugger Robot      *  with a token. Imaginary tokens such as an ANTLR3_CLASSIC_TOKEN may actually
228*16467b97STreehugger Robot      *  do this, however many tokens such as ANTLR3_COMMON_TOKEN do not actaully have
229*16467b97STreehugger Robot      *  strings associated with them but just point into the current input stream. These
230*16467b97STreehugger Robot      *  tokens will implement this function with a function that errors out (probably
231*16467b97STreehugger Robot      *  drastically.
232*16467b97STreehugger Robot      */
233*16467b97STreehugger Robot     void	    (*setText)(struct ANTLR3_COMMON_TOKEN_struct * token, pANTLR3_STRING text);
234*16467b97STreehugger Robot 
235*16467b97STreehugger Robot     /** Pointer to a function that 'might' be able to set the text associated
236*16467b97STreehugger Robot      *  with a token. Imaginary tokens such as an ANTLR3_CLASSIC_TOKEN may actually
237*16467b97STreehugger Robot      *  do this, however many tokens such as ANTLR3_COMMON_TOKEN do not actully have
238*16467b97STreehugger Robot      *  strings associated with them but just point into the current input stream. These
239*16467b97STreehugger Robot      *  tokens will implement this function with a function that errors out (probably
240*16467b97STreehugger Robot      *  drastically.
241*16467b97STreehugger Robot      */
242*16467b97STreehugger Robot     void	    (*setText8)(struct ANTLR3_COMMON_TOKEN_struct * token, pANTLR3_UINT8 text);
243*16467b97STreehugger Robot 
244*16467b97STreehugger Robot     /** Pointer to a function that returns the token type of this token
245*16467b97STreehugger Robot      */
246*16467b97STreehugger Robot     ANTLR3_UINT32   (*getType)(struct ANTLR3_COMMON_TOKEN_struct * token);
247*16467b97STreehugger Robot 
248*16467b97STreehugger Robot     /** Pointer to a function that sets the type of this token
249*16467b97STreehugger Robot      */
250*16467b97STreehugger Robot     void	    (*setType)(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_UINT32 ttype);
251*16467b97STreehugger Robot 
252*16467b97STreehugger Robot     /** Pointer to a function that gets the 'line' number where this token resides
253*16467b97STreehugger Robot      */
254*16467b97STreehugger Robot     ANTLR3_UINT32   (*getLine)(struct ANTLR3_COMMON_TOKEN_struct * token);
255*16467b97STreehugger Robot 
256*16467b97STreehugger Robot     /** Pointer to a function that sets the 'line' number where this token reside
257*16467b97STreehugger Robot      */
258*16467b97STreehugger Robot     void	    (*setLine)(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_UINT32 line);
259*16467b97STreehugger Robot 
260*16467b97STreehugger Robot     /** Pointer to a function that gets the offset in the line where this token exists
261*16467b97STreehugger Robot      */
262*16467b97STreehugger Robot     ANTLR3_INT32    (*getCharPositionInLine)	(struct ANTLR3_COMMON_TOKEN_struct * token);
263*16467b97STreehugger Robot 
264*16467b97STreehugger Robot     /** Pointer to a function that sets the offset in the line where this token exists
265*16467b97STreehugger Robot      */
266*16467b97STreehugger Robot     void	    (*setCharPositionInLine)	(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_INT32 pos);
267*16467b97STreehugger Robot 
268*16467b97STreehugger Robot     /** Pointer to a function that gets the channel that this token was placed in (parsers
269*16467b97STreehugger Robot      *  can 'tune' to these channels.
270*16467b97STreehugger Robot      */
271*16467b97STreehugger Robot     ANTLR3_UINT32   (*getChannel)	(struct ANTLR3_COMMON_TOKEN_struct * token);
272*16467b97STreehugger Robot 
273*16467b97STreehugger Robot     /** Pointer to a function that sets the channel that this token should belong to
274*16467b97STreehugger Robot      */
275*16467b97STreehugger Robot     void	    (*setChannel)	(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_UINT32 channel);
276*16467b97STreehugger Robot 
277*16467b97STreehugger Robot     /** Pointer to a function that returns an index 0...n-1 of the token in the token
278*16467b97STreehugger Robot      *  input stream.
279*16467b97STreehugger Robot      */
280*16467b97STreehugger Robot     ANTLR3_MARKER   (*getTokenIndex)	(struct ANTLR3_COMMON_TOKEN_struct * token);
281*16467b97STreehugger Robot 
282*16467b97STreehugger Robot     /** Pointer to a function that can set the token index of this token in the token
283*16467b97STreehugger Robot      *  input stream.
284*16467b97STreehugger Robot      */
285*16467b97STreehugger Robot     void			(*setTokenIndex)	(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_MARKER);
286*16467b97STreehugger Robot 
287*16467b97STreehugger Robot     /** Pointer to a function that gets the start index in the input stream for this token.
288*16467b97STreehugger Robot      */
289*16467b97STreehugger Robot     ANTLR3_MARKER   (*getStartIndex)	(struct ANTLR3_COMMON_TOKEN_struct * token);
290*16467b97STreehugger Robot 
291*16467b97STreehugger Robot     /** Pointer to a function that sets the start index in the input stream for this token.
292*16467b97STreehugger Robot      */
293*16467b97STreehugger Robot     void			(*setStartIndex)	(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_MARKER index);
294*16467b97STreehugger Robot 
295*16467b97STreehugger Robot     /** Pointer to a function that gets the stop index in the input stream for this token.
296*16467b97STreehugger Robot      */
297*16467b97STreehugger Robot     ANTLR3_MARKER   (*getStopIndex)	(struct ANTLR3_COMMON_TOKEN_struct * token);
298*16467b97STreehugger Robot 
299*16467b97STreehugger Robot     /** Pointer to a function that sets the stop index in the input stream for this token.
300*16467b97STreehugger Robot      */
301*16467b97STreehugger Robot     void			(*setStopIndex)	(struct ANTLR3_COMMON_TOKEN_struct * token, ANTLR3_MARKER index);
302*16467b97STreehugger Robot 
303*16467b97STreehugger Robot     /** Pointer to a function that returns this token as a text representation that can be
304*16467b97STreehugger Robot      *  printed with embedded control codes such as \n replaced with the printable sequence "\\n"
305*16467b97STreehugger Robot      *  This also yields a string structure that can be used more easily than the pointer to
306*16467b97STreehugger Robot      *  the input stream in certain situations.
307*16467b97STreehugger Robot      */
308*16467b97STreehugger Robot     pANTLR3_STRING  (*toString)		(struct ANTLR3_COMMON_TOKEN_struct * token);
309*16467b97STreehugger Robot }
310*16467b97STreehugger Robot     ANTLR3_COMMON_TOKEN;
311*16467b97STreehugger Robot 
312*16467b97STreehugger Robot /** \brief ANTLR3 Token factory interface to create lots of tokens efficiently
313*16467b97STreehugger Robot  *  rather than creating and freeing lots of little bits of memory.
314*16467b97STreehugger Robot  */
315*16467b97STreehugger Robot typedef	struct ANTLR3_TOKEN_FACTORY_struct
316*16467b97STreehugger Robot {
317*16467b97STreehugger Robot     /** Pointers to the array of tokens that this factory has produced so far
318*16467b97STreehugger Robot      */
319*16467b97STreehugger Robot     pANTLR3_COMMON_TOKEN    *pools;
320*16467b97STreehugger Robot 
321*16467b97STreehugger Robot     /** Current pool tokens we are allocating from
322*16467b97STreehugger Robot      */
323*16467b97STreehugger Robot     ANTLR3_INT32	    thisPool;
324*16467b97STreehugger Robot 
325*16467b97STreehugger Robot     /** Maximum pool count we have available
326*16467b97STreehugger Robot      */
327*16467b97STreehugger Robot     ANTLR3_INT32            maxPool;
328*16467b97STreehugger Robot 
329*16467b97STreehugger Robot     /** The next token to throw out from the pool, will cause a new pool allocation
330*16467b97STreehugger Robot      *  if this exceeds the available tokenCount
331*16467b97STreehugger Robot      */
332*16467b97STreehugger Robot     ANTLR3_UINT32	    nextToken;
333*16467b97STreehugger Robot 
334*16467b97STreehugger Robot     /** Trick to initialize tokens and their API quickly, we set up this token when the
335*16467b97STreehugger Robot      *  factory is created, then just copy the memory it uses into the new token.
336*16467b97STreehugger Robot      */
337*16467b97STreehugger Robot     ANTLR3_COMMON_TOKEN	    unTruc;
338*16467b97STreehugger Robot 
339*16467b97STreehugger Robot     /** Pointer to an input stream that is using this token factory (may be NULL)
340*16467b97STreehugger Robot      *  which will be assigned to the tokens automatically.
341*16467b97STreehugger Robot      */
342*16467b97STreehugger Robot     pANTLR3_INPUT_STREAM    input;
343*16467b97STreehugger Robot 
344*16467b97STreehugger Robot     /** Pointer to a function that returns a new token
345*16467b97STreehugger Robot      */
346*16467b97STreehugger Robot     pANTLR3_COMMON_TOKEN    (*newToken)	    (struct ANTLR3_TOKEN_FACTORY_struct * factory);
347*16467b97STreehugger Robot 
348*16467b97STreehugger Robot     /** Pointer to a function that resets the factory so you can reuse the pools it
349*16467b97STreehugger Robot      *  has laready allocated
350*16467b97STreehugger Robot      */
351*16467b97STreehugger Robot     void                    (*reset)	    (struct ANTLR3_TOKEN_FACTORY_struct * factory);
352*16467b97STreehugger Robot 
353*16467b97STreehugger Robot     /** Pointer to a function that changes teh curent inptu stream so that
354*16467b97STreehugger Robot      *  new tokens are created with reference to their originating text.
355*16467b97STreehugger Robot      */
356*16467b97STreehugger Robot     void		    (*setInputStream)	(struct ANTLR3_TOKEN_FACTORY_struct * factory, pANTLR3_INPUT_STREAM input);
357*16467b97STreehugger Robot     /** Pointer to a function the destroys the factory
358*16467b97STreehugger Robot      */
359*16467b97STreehugger Robot     void		    (*close)	    (struct ANTLR3_TOKEN_FACTORY_struct * factory);
360*16467b97STreehugger Robot }
361*16467b97STreehugger Robot     ANTLR3_TOKEN_FACTORY;
362*16467b97STreehugger Robot 
363*16467b97STreehugger Robot #ifdef __cplusplus
364*16467b97STreehugger Robot }
365*16467b97STreehugger Robot #endif
366*16467b97STreehugger Robot 
367*16467b97STreehugger Robot #endif
368