Lines Matching refs:parser
2 * Implementation of the base functionality for an ANTLR3 parser.
36 /* Parser API
38 static void setDebugListener (pANTLR3_PARSER parser, pANTLR3_DEBUG_EVENT_LISTENER dbg);
39 static void setTokenStream (pANTLR3_PARSER parser, pANTLR3_TOKEN_STREAM);
40 static pANTLR3_TOKEN_STREAM getTokenStream (pANTLR3_PARSER parser);
41 static void freeParser (pANTLR3_PARSER parser);
46 pANTLR3_PARSER parser;
48 parser = antlr3ParserNewStream(sizeHint, tstream, state);
50 if (parser == NULL)
55 parser->setDebugListener(parser, dbg);
57 return parser;
63 pANTLR3_PARSER parser;
67 parser = (pANTLR3_PARSER) ANTLR3_MALLOC(sizeof(ANTLR3_PARSER));
69 if (parser == NULL)
74 /* Install a base parser
76 parser->rec = antlr3BaseRecognizerNew(ANTLR3_TYPE_PARSER, sizeHint, state);
78 if (parser->rec == NULL)
80 parser->free(parser);
84 parser->rec->super = parser;
86 /* Parser overrides
88 parser->rec->exConstruct = antlr3MTExceptionNew;
92 parser->setDebugListener = setDebugListener;
93 parser->setTokenStream = setTokenStream;
94 parser->getTokenStream = getTokenStream;
96 parser->free = freeParser;
98 return parser;
104 pANTLR3_PARSER parser;
106 parser = antlr3ParserNew(sizeHint, state);
108 if (parser == NULL)
116 parser->setTokenStream(parser, tstream);
118 return parser;
122 freeParser (pANTLR3_PARSER parser)
124 if (parser->rec != NULL)
126 // This may have ben a delegate or delegator parser, in which case the
130 if (parser->rec->state != NULL)
132 if (parser->rec->state->following != NULL)
134 parser->rec->state->following->free(parser->rec->state->following);
135 parser->rec->state->following = NULL;
138 parser->rec->free(parser->rec);
139 parser->rec = NULL;
142 ANTLR3_FREE(parser);
146 setDebugListener (pANTLR3_PARSER parser, pANTLR3_DEBUG_EVENT_LISTENER dbg)
157 parser->rec->debugger = dbg;
162 if (parser->tstream != NULL)
164 parser->tstream->setDebugListener(parser->tstream, dbg);
169 setTokenStream (pANTLR3_PARSER parser, pANTLR3_TOKEN_STREAM tstream)
171 parser->tstream = tstream;
172 parser->rec->reset(parser->rec);
176 getTokenStream (pANTLR3_PARSER parser)
178 return parser->tstream;