public class ParserInterpreter extends Parser
Parser.TraceListener, Parser.TrimToSizeListener
Modifier and Type | Field and Description |
---|---|
protected Deque<Pair<ParserRuleContext,Integer>> |
_parentContextStack
This stack corresponds to the _parentctx, _parentState pair of locals
that would exist on call stack frames with a recursive descent parser;
in the generated function for a left-recursive rule you'd see:
private EContext e(int _p) throws RecognitionException {
ParserRuleContext _parentctx = _ctx; // Pair.a
int _parentState = getState(); // Pair.b
...
|
protected ATN |
atn |
protected DFA[] |
decisionToDFA |
protected String |
grammarFileName |
protected int |
overrideDecision
We need a map from (decision,inputIndex)->forced alt for computing ambiguous
parse trees.
|
protected int |
overrideDecisionAlt |
protected int |
overrideDecisionInputIndex |
protected boolean |
overrideDecisionReached |
protected InterpreterRuleContext |
overrideDecisionRoot
What is the current context when we override a decisions? This tells
us what the root of the parse tree is when using override
for an ambiguity/lookahead check.
|
protected InterpreterRuleContext |
rootContext |
protected String[] |
ruleNames |
protected PredictionContextCache |
sharedContextCache |
protected String[] |
tokenNames
Deprecated.
|
_buildParseTrees, _ctx, _errHandler, _input, _parseListeners, _precedenceStack, _syntaxErrors, matchedEOF
_interp, EOF
Constructor and Description |
---|
ParserInterpreter(String grammarFileName,
Collection<String> tokenNames,
Collection<String> ruleNames,
ATN atn,
TokenStream input)
Deprecated.
|
ParserInterpreter(String grammarFileName,
Vocabulary vocabulary,
Collection<String> ruleNames,
ATN atn,
TokenStream input) |
Modifier and Type | Method and Description |
---|---|
void |
addDecisionOverride(int decision,
int tokenIndex,
int forcedAlt)
Override this parser interpreters normal decision-making process
at a particular decision and input token index.
|
protected InterpreterRuleContext |
createInterpreterRuleContext(ParserRuleContext parent,
int invokingStateNumber,
int ruleIndex)
Provide simple "factory" for InterpreterRuleContext's.
|
void |
enterRecursionRule(ParserRuleContext localctx,
int state,
int ruleIndex,
int precedence) |
ATN |
getATN()
Get the
ATN used by the recognizer for prediction. |
protected ATNState |
getATNState() |
String |
getGrammarFileName()
For debugging and other purposes, might want the grammar name.
|
InterpreterRuleContext |
getOverrideDecisionRoot() |
InterpreterRuleContext |
getRootContext()
Return the root of the parse, which can be useful if the parser
bails out.
|
String[] |
getRuleNames() |
String[] |
getTokenNames()
Deprecated.
|
Vocabulary |
getVocabulary()
Get the vocabulary used by the recognizer.
|
ParserRuleContext |
parse(int startRuleIndex)
Begin parsing at startRuleIndex
|
protected void |
recover(RecognitionException e)
Rely on the error handler for this parser but, if no tokens are consumed
to recover, add an error node.
|
protected Token |
recoverInline() |
void |
reset()
reset the parser's state
|
protected int |
visitDecisionState(DecisionState p)
Method visitDecisionState() is called when the interpreter reaches
a decision state (instance of DecisionState).
|
protected void |
visitRuleStopState(ATNState p) |
protected void |
visitState(ATNState p) |
addContextToParseTree, addParseListener, compileParseTreePattern, compileParseTreePattern, consume, createErrorNode, createTerminalNode, dumpDFA, enterOuterAlt, enterRecursionRule, enterRule, exitRule, getATNWithBypassAlts, getBuildParseTree, getContext, getCurrentToken, getDFAStrings, getErrorHandler, getExpectedTokens, getExpectedTokensWithinCurrentRule, getInputStream, getInvokingContext, getNumberOfSyntaxErrors, getParseInfo, getParseListeners, getPrecedence, getRuleContext, getRuleIndex, getRuleInvocationStack, getRuleInvocationStack, getSourceName, getTokenFactory, getTokenStream, getTrimParseTree, inContext, isExpectedToken, isMatchedEOF, isTrace, match, matchWildcard, notifyErrorListeners, notifyErrorListeners, precpred, pushNewRecursionContext, removeParseListener, removeParseListeners, setBuildParseTree, setContext, setErrorHandler, setInputStream, setProfile, setTokenFactory, setTokenStream, setTrace, setTrimParseTree, triggerEnterRuleEvent, triggerExitRuleEvent, unrollRecursionContexts
action, addErrorListener, getErrorHeader, getErrorListenerDispatch, getErrorListeners, getInterpreter, getRuleIndexMap, getSerializedATN, getState, getTokenErrorDisplay, getTokenType, getTokenTypeMap, removeErrorListener, removeErrorListeners, sempred, setInterpreter, setState
protected final String grammarFileName
protected final ATN atn
protected final DFA[] decisionToDFA
protected final PredictionContextCache sharedContextCache
@Deprecated protected final String[] tokenNames
protected final String[] ruleNames
protected final Deque<Pair<ParserRuleContext,Integer>> _parentContextStack
protected int overrideDecision
protected int overrideDecisionInputIndex
protected int overrideDecisionAlt
protected boolean overrideDecisionReached
protected InterpreterRuleContext overrideDecisionRoot
protected InterpreterRuleContext rootContext
@Deprecated public ParserInterpreter(String grammarFileName, Collection<String> tokenNames, Collection<String> ruleNames, ATN atn, TokenStream input)
ParserInterpreter(String, Vocabulary, Collection, ATN, TokenStream)
instead.public ParserInterpreter(String grammarFileName, Vocabulary vocabulary, Collection<String> ruleNames, ATN atn, TokenStream input)
public void reset()
Parser
public ATN getATN()
Recognizer
ATN
used by the recognizer for prediction.getATN
in class Recognizer<Token,ParserATNSimulator>
ATN
used by the recognizer for prediction.@Deprecated public String[] getTokenNames()
Recognizer
getTokenNames
in class Recognizer<Token,ParserATNSimulator>
public Vocabulary getVocabulary()
Recognizer
getVocabulary
in class Recognizer<Token,ParserATNSimulator>
Vocabulary
instance providing information about the
vocabulary used by the grammar.public String[] getRuleNames()
getRuleNames
in class Recognizer<Token,ParserATNSimulator>
public String getGrammarFileName()
Recognizer
getGrammarFileName
in class Recognizer<Token,ParserATNSimulator>
public ParserRuleContext parse(int startRuleIndex)
public void enterRecursionRule(ParserRuleContext localctx, int state, int ruleIndex, int precedence)
enterRecursionRule
in class Parser
protected ATNState getATNState()
protected void visitState(ATNState p)
protected int visitDecisionState(DecisionState p)
protected InterpreterRuleContext createInterpreterRuleContext(ParserRuleContext parent, int invokingStateNumber, int ruleIndex)
protected void visitRuleStopState(ATNState p)
public void addDecisionOverride(int decision, int tokenIndex, int forcedAlt)
public InterpreterRuleContext getOverrideDecisionRoot()
protected void recover(RecognitionException e)
protected Token recoverInline()
public InterpreterRuleContext getRootContext()
Copyright © 1992–2020 ANTLR. All rights reserved.