Package antlr
Class Parser
java.lang.Object
antlr.Parser
- Direct Known Subclasses:
LLkParser
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ASTFactoryAST support code; parser delegates to this object.protected ParserSharedInputStateprotected ASTAST return value for a rule is squirreled away hereprotected String[]Table of token type to token namesprotected HashtableConstructed if any AST types specified in tokens{..}.protected intUsed to keep track of indentdepth for traceIn/Out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidvoidvoidabstract voidconsume()Get another token object from the token streamvoidconsumeUntil(int tokenType) Consume tokens until one matches the given tokenvoidconsumeUntil(BitSet set) Consume tokens until one matches the given token setprotected voiddefaultDebuggingSetup(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.booleanabstract intLA(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 TokenLT(int i) Return the ith token of lookaheadintmark()voidmatch(int t) Make sure current lookahead symbol matches token type t.voidMake 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.voidmatchNot(int t) static voidpanic()Deprecated.as of 2.7.2.voidrecover(RecognitionException ex, BitSet tokenSet) voidvoidvoidvoidvoidvoidvoidvoidParser error-reporting function can be overridden in subclassvoidParser error-reporting function can be overridden in subclassvoidParser warning-reporting function can be overridden in subclassvoidrewind(int pos) voidSpecify an object with support code (shared by Parser and TreeParser.voidvoidsetASTNodeType(String nodeType) Deprecated.since 2.7.1voidsetDebugMode(boolean debugMode) voidvoidsetIgnoreInvalidDebugCalls(boolean value) voidvoidSet or change the input token buffervoidvoidvoid
-
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
-