ANTLR Support Libraries 2.7.1+
|
#include <Parser.hpp>
Classes | |
class | Tracer |
Protected Member Functions | |
Parser (TokenBuffer &input) | |
Parser (TokenBuffer *input) | |
Parser (const ParserSharedInputState &state) | |
Protected Attributes | |
ParserSharedInputState | inputState |
ASTFactory * | astFactory |
AST support code; parser and treeparser delegate to this object. | |
int | traceDepth |
Private Member Functions | |
Parser (const Parser &) | |
const Parser & | operator= (const Parser &) |
A generic ANTLR parser (LL(k) for k>=1) containing a bunch of utility routines useful at any lookahead depth. We distinguish between the LL(1) and LL(k) parsers because of efficiency. This may not be necessary in the near future.
Each parser object contains the state of the parse including a lookahead cache (the form of which is determined by the subclass), whether or not the parser is in guess mode, where tokens come from, etc...
During guess mode, the current lookahead token(s) and token type(s) cache must be saved because the token stream may not have been informed to save the token (via mark
) before the try
block. Guessing is started by:
After guessing, the parser state is restored by:
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlinevirtual |
Get another token object from the token stream.
Implemented in LLkParser.
Consume tokens until one matches the given token set.
Consume tokens until one matches the given token.
|
inlinevirtual |
Return a pointer to the ASTFactory used. So you might use it in subsequent treewalkers or to reload AST's from disk.
|
inlinevirtual |
Return the filename of the input file.
|
inlinevirtual |
Get the number of tokens defined. This one should be overridden in subclasses.
get the token name for the token number 'num'
get a vector with all token names
Return the i-th token of lookahead.
Implemented in LLkParser.
Mark a spot in the input and return the position. Forwarded to TokenBuffer.
Make sure current lookahead symbol matches the given set Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.
Make sure current lookahead symbol matches token type t
. Throw an exception upon mismatch, which is catch by either the error handler or by the syntactic predicate.
|
inlinevirtual |
called by the generated parser to do error recovery, override to customize the behaviour.
|
virtual |
rewind to a previously marked position
|
inlinevirtual |
Specify the factory to be used during tree building. (Compulsory) Setting the factory is nowadays compulsory.
|
inlinevirtual |
DEPRECATED! Specify the factory to be used during tree building. (Compulsory) Setting the factory is nowadays compulsory.
Set the filename of the input file (used for error reporting).
|
inlinevirtual |
|
virtual |
Set or change the input token buffer
|
protected |
AST support code; parser and treeparser delegate to this object.
|
protected |
|
protected |