1*16467b97STreehugger Robot /** \file 2*16467b97STreehugger Robot * Base implementation of an ANTLR3 parser. 3*16467b97STreehugger Robot * 4*16467b97STreehugger Robot * 5*16467b97STreehugger Robot */ 6*16467b97STreehugger Robot #ifndef _ANTLR3_PARSER_H 7*16467b97STreehugger Robot #define _ANTLR3_PARSER_H 8*16467b97STreehugger Robot 9*16467b97STreehugger Robot // [The "BSD licence"] 10*16467b97STreehugger Robot // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC 11*16467b97STreehugger Robot // http://www.temporal-wave.com 12*16467b97STreehugger Robot // http://www.linkedin.com/in/jimidle 13*16467b97STreehugger Robot // 14*16467b97STreehugger Robot // All rights reserved. 15*16467b97STreehugger Robot // 16*16467b97STreehugger Robot // Redistribution and use in source and binary forms, with or without 17*16467b97STreehugger Robot // modification, are permitted provided that the following conditions 18*16467b97STreehugger Robot // are met: 19*16467b97STreehugger Robot // 1. Redistributions of source code must retain the above copyright 20*16467b97STreehugger Robot // notice, this list of conditions and the following disclaimer. 21*16467b97STreehugger Robot // 2. Redistributions in binary form must reproduce the above copyright 22*16467b97STreehugger Robot // notice, this list of conditions and the following disclaimer in the 23*16467b97STreehugger Robot // documentation and/or other materials provided with the distribution. 24*16467b97STreehugger Robot // 3. The name of the author may not be used to endorse or promote products 25*16467b97STreehugger Robot // derived from this software without specific prior written permission. 26*16467b97STreehugger Robot // 27*16467b97STreehugger Robot // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 28*16467b97STreehugger Robot // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 29*16467b97STreehugger Robot // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 30*16467b97STreehugger Robot // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 31*16467b97STreehugger Robot // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 32*16467b97STreehugger Robot // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33*16467b97STreehugger Robot // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34*16467b97STreehugger Robot // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35*16467b97STreehugger Robot // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 36*16467b97STreehugger Robot // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37*16467b97STreehugger Robot 38*16467b97STreehugger Robot #include <antlr3defs.h> 39*16467b97STreehugger Robot #include <antlr3baserecognizer.h> 40*16467b97STreehugger Robot 41*16467b97STreehugger Robot #ifdef __cplusplus 42*16467b97STreehugger Robot extern "C" { 43*16467b97STreehugger Robot #endif 44*16467b97STreehugger Robot 45*16467b97STreehugger Robot /** This is the main interface for an ANTLR3 parser. 46*16467b97STreehugger Robot */ 47*16467b97STreehugger Robot typedef struct ANTLR3_PARSER_struct 48*16467b97STreehugger Robot { 49*16467b97STreehugger Robot /** All superstructure implementers of this interface require a pointer to their selves, 50*16467b97STreehugger Robot * which they can reference using the super pointer here. 51*16467b97STreehugger Robot */ 52*16467b97STreehugger Robot void * super; 53*16467b97STreehugger Robot 54*16467b97STreehugger Robot /** A pointer to the base recognizer, where most of the parser functions actually 55*16467b97STreehugger Robot * live because they are shared between parser and tree parser and this is the 56*16467b97STreehugger Robot * easier way than copying the interface all over the place. Macros hide this 57*16467b97STreehugger Robot * for the generated code so it is easier on the eye (though not the debugger ;-). 58*16467b97STreehugger Robot */ 59*16467b97STreehugger Robot pANTLR3_BASE_RECOGNIZER rec; 60*16467b97STreehugger Robot 61*16467b97STreehugger Robot /** A provider of a tokenstream interface, for the parser to consume 62*16467b97STreehugger Robot * tokens from. 63*16467b97STreehugger Robot */ 64*16467b97STreehugger Robot pANTLR3_TOKEN_STREAM tstream; 65*16467b97STreehugger Robot 66*16467b97STreehugger Robot /** A pointer to a function that installs a debugger object (it also 67*16467b97STreehugger Robot * installs the debugging versions of the parser methods. This means that 68*16467b97STreehugger Robot * a non debug parser incurs no overhead because of the debugging stuff. 69*16467b97STreehugger Robot */ 70*16467b97STreehugger Robot void (*setDebugListener) (struct ANTLR3_PARSER_struct * parser, pANTLR3_DEBUG_EVENT_LISTENER dbg); 71*16467b97STreehugger Robot 72*16467b97STreehugger Robot /** A pointer to a function that installs a token stream 73*16467b97STreehugger Robot * for the parser. 74*16467b97STreehugger Robot */ 75*16467b97STreehugger Robot void (*setTokenStream) (struct ANTLR3_PARSER_struct * parser, pANTLR3_TOKEN_STREAM); 76*16467b97STreehugger Robot 77*16467b97STreehugger Robot /** A pointer to a function that returns the token stream for this 78*16467b97STreehugger Robot * parser. 79*16467b97STreehugger Robot */ 80*16467b97STreehugger Robot pANTLR3_TOKEN_STREAM (*getTokenStream) (struct ANTLR3_PARSER_struct * parser); 81*16467b97STreehugger Robot 82*16467b97STreehugger Robot /** Pointer to a function that knows how to free resources of an ANTLR3 parser. 83*16467b97STreehugger Robot */ 84*16467b97STreehugger Robot void (*free) (struct ANTLR3_PARSER_struct * parser); 85*16467b97STreehugger Robot 86*16467b97STreehugger Robot } 87*16467b97STreehugger Robot ANTLR3_PARSER; 88*16467b97STreehugger Robot 89*16467b97STreehugger Robot #ifdef __cplusplus 90*16467b97STreehugger Robot } 91*16467b97STreehugger Robot #endif 92*16467b97STreehugger Robot 93*16467b97STreehugger Robot #endif 94