1324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver/** \file
2324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver * Base implementation of an ANTLR3 parser.
3324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *
4324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver *
5324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver */
6324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#ifndef	_ANTLR3_PARSER_H
7324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#define	_ANTLR3_PARSER_H
8324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
9324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// [The "BSD licence"]
10324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC
11324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// http://www.temporal-wave.com
12324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// http://www.linkedin.com/in/jimidle
13324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//
14324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// All rights reserved.
15324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//
16324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// Redistribution and use in source and binary forms, with or without
17324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// modification, are permitted provided that the following conditions
18324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// are met:
19324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 1. Redistributions of source code must retain the above copyright
20324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    notice, this list of conditions and the following disclaimer.
21324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 2. Redistributions in binary form must reproduce the above copyright
22324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    notice, this list of conditions and the following disclaimer in the
23324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    documentation and/or other materials provided with the distribution.
24324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 3. The name of the author may not be used to endorse or promote products
25324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//    derived from this software without specific prior written permission.
26324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//
27324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
38324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#include    <antlr3defs.h>
39324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#include    <antlr3baserecognizer.h>
40324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
41324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#ifdef __cplusplus
42324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverextern "C" {
43324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#endif
44324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
45324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver/** This is the main interface for an ANTLR3 parser.
46324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver */
47324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvertypedef	struct ANTLR3_PARSER_struct
48324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver{
49324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    /** All superstructure implementers of this interface require a pointer to their selves,
50324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     *  which they can reference using the super pointer here.
51324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     */
52324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    void			* super;
53324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
54324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    /** A pointer to the base recognizer, where most of the parser functions actually
55324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     *  live because they are shared between parser and tree parser and this is the
56324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     *  easier way than copying the interface all over the place. Macros hide this
57324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     *  for the generated code so it is easier on the eye (though not the debugger ;-).
58324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     */
59324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    pANTLR3_BASE_RECOGNIZER			rec;
60324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
61324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    /** A provider of a tokenstream interface, for the parser to consume
62324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     *  tokens from.
63324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     */
64324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    pANTLR3_TOKEN_STREAM			tstream;
65324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
66324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver	/** A pointer to a function that installs a debugger object (it also
67324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver	 *  installs the debugging versions of the parser methods. This means that
68324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver	 *  a non debug parser incurs no overhead because of the debugging stuff.
69324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver	 */
70324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver	void					(*setDebugListener)	(struct ANTLR3_PARSER_struct	* parser, pANTLR3_DEBUG_EVENT_LISTENER dbg);
71324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
72324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    /** A pointer to a function that installs a token stream
73324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     * for the parser.
74324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     */
75324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    void					(*setTokenStream)	(struct ANTLR3_PARSER_struct	* parser, pANTLR3_TOKEN_STREAM);
76324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
77324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    /** A pointer to a function that returns the token stream for this
78324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     *  parser.
79324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     */
80324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    pANTLR3_TOKEN_STREAM	(*getTokenStream)	(struct ANTLR3_PARSER_struct	* parser);
81324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
82324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    /** Pointer to a function that knows how to free resources of an ANTLR3 parser.
83324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver     */
84324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    void			(*free)			(struct ANTLR3_PARSER_struct	* parser);
85324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
86324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver}
87324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver    ANTLR3_PARSER;
88324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
89324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#ifdef __cplusplus
90324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver}
91324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#endif
92324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver
93324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#endif
94