Package antlr
Class Parser
java.lang.Object
antlr.Parser
- Direct Known Subclasses:
LLkParser
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ASTFactory
AST support code; parser delegates to this object.protected ParserSharedInputState
protected AST
AST return value for a rule is squirreled away hereprotected String[]
Table of token type to token namesprotected Hashtable
Constructed if any AST types specified in tokens{..}.protected int
Used to keep track of indentdepth for traceIn/Out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
void
void
void
abstract void
consume()
Get another token object from the token streamvoid
consumeUntil
(int tokenType) Consume tokens until one matches the given tokenvoid
consumeUntil
(BitSet set) Consume tokens until one matches the given token setprotected void
defaultDebuggingSetup
(TokenStream lexer, TokenBuffer tokBuf) getAST()
Get the AST return value squirreled away in the parsergetTokenName
(int num) String[]
If the user specifies a tokens{} section with heterogeneous AST node types, then ANTLR generates code to fill this mapping.boolean
abstract int
LA
(int i) Return the token type of the ith token of lookahead where i=1 is the current token being examined by the parser (i.e., it has not been matched yet).abstract Token
LT
(int i) Return the ith token of lookaheadint
mark()
void
match
(int t) Make sure current lookahead symbol matches token type t.void
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.void
matchNot
(int t) static void
panic()
Deprecated.as of 2.7.2.void
recover
(RecognitionException ex, BitSet tokenSet) void
void
void
void
void
void
void
void
Parser error-reporting function can be overridden in subclassvoid
Parser error-reporting function can be overridden in subclassvoid
Parser warning-reporting function can be overridden in subclassvoid
rewind
(int pos) void
Specify an object with support code (shared by Parser and TreeParser.void
void
setASTNodeType
(String nodeType) Deprecated.since 2.7.1void
setDebugMode
(boolean debugMode) void
void
setIgnoreInvalidDebugCalls
(boolean value) void
void
Set or change the input token buffervoid
void
void
-
Field Details
-
inputState
-
tokenNames
Table of token type to token names -
returnAST
AST return value for a rule is squirreled away here -
astFactory
AST support code; parser delegates to this object. This is set during parser construction by default to either "new ASTFactory()" or a ctor that has a token type to class map for hetero nodes. -
tokenTypeToASTClassMap
Constructed if any AST types specified in tokens{..}. Maps an Integer->Class object. -
traceDepth
protected int traceDepthUsed to keep track of indentdepth for traceIn/Out
-
-
Constructor Details
-
Parser
public Parser()
-
-
Method Details
-
getTokenTypeToASTClassMap
If the user specifies a tokens{} section with heterogeneous AST node types, then ANTLR generates code to fill this mapping. -
addMessageListener
-
addParserListener
-
addParserMatchListener
-
addParserTokenListener
-
addSemanticPredicateListener
-
addSyntacticPredicateListener
-
addTraceListener
-
consume
Get another token object from the token stream- Throws:
TokenStreamException
-
consumeUntil
Consume tokens until one matches the given token- Throws:
TokenStreamException
-
consumeUntil
Consume tokens until one matches the given token set- Throws:
TokenStreamException
-
defaultDebuggingSetup
-
getAST
Get the AST return value squirreled away in the parser -
getASTFactory
-
getFilename
-
getInputState
-
getTokenName
-
getTokenNames
-
isDebugMode
public boolean isDebugMode() -
LA
Return the token type of the ith token of lookahead where i=1 is the current token being examined by the parser (i.e., it has not been matched yet).- Throws:
TokenStreamException
-
LT
Return the ith token of lookahead- Throws:
TokenStreamException
-
mark
public int mark() -
match
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. -
match
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. -
matchNot
-
panic
public static void panic()Deprecated.as of 2.7.2. This method calls System.exit() and writes directly to stderr, which is usually not appropriate when a parser is embedded into a larger application. Since the method isstatic
, it cannot be overridden to avoid these problems. ANTLR no longer uses this method internally or in generated code. -
removeMessageListener
-
removeParserListener
-
removeParserMatchListener
-
removeParserTokenListener
-
removeSemanticPredicateListener
-
removeSyntacticPredicateListener
-
removeTraceListener
-
reportError
Parser error-reporting function can be overridden in subclass -
reportError
Parser error-reporting function can be overridden in subclass -
reportWarning
Parser warning-reporting function can be overridden in subclass -
recover
- Throws:
TokenStreamException
-
rewind
public void rewind(int pos) -
setASTFactory
Specify an object with support code (shared by Parser and TreeParser. Normally, the programmer does not play with this, using setASTNodeType instead. -
setASTNodeClass
-
setASTNodeType
Deprecated.since 2.7.1Specify the type of node to create during tree building; use setASTNodeClass now to be consistent with Token Object Type accessor. -
setDebugMode
public void setDebugMode(boolean debugMode) -
setFilename
-
setIgnoreInvalidDebugCalls
public void setIgnoreInvalidDebugCalls(boolean value) -
setTokenBuffer
Set or change the input token buffer -
traceIndent
public void traceIndent() -
traceIn
- Throws:
TokenStreamException
-
traceOut
- Throws:
TokenStreamException
-