Package org.antlr.runtime.debug
Class DebugParser
- java.lang.Object
-
- org.antlr.runtime.BaseRecognizer
-
- org.antlr.runtime.Parser
-
- org.antlr.runtime.debug.DebugParser
-
public class DebugParser extends Parser
-
-
Field Summary
Fields Modifier and Type Field Description protected DebugEventListener
dbg
Who to notify when events in the parser occur.boolean
isCyclicDecision
Used to differentiate between fixed lookahead and cyclic DFA decisions while profiling.-
Fields inherited from class org.antlr.runtime.BaseRecognizer
DEFAULT_TOKEN_CHANNEL, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, MEMO_RULE_FAILED, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, state
-
-
Constructor Summary
Constructors Constructor Description DebugParser(TokenStream input, DebugEventListener dbg)
DebugParser(TokenStream input, DebugEventListener dbg, RecognizerSharedState state)
Create a normal parser except wrap the token stream in a debug proxy that fires consume events.DebugParser(TokenStream input, RecognizerSharedState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginBacktrack(int level)
void
beginResync()
A hook to listen in on the token consumption during error recovery.void
endBacktrack(int level, boolean successful)
void
endResync()
DebugEventListener
getDebugListener()
void
reportError(IOException e)
void
reportError(RecognitionException e)
Report a recognition problem.void
setDebugListener(DebugEventListener dbg)
Provide a new debug event listener for this parser.-
Methods inherited from class org.antlr.runtime.Parser
getCurrentInputSymbol, getMissingSymbol, getSourceName, getTokenStream, reset, setTokenStream, traceIn, traceOut
-
Methods inherited from class org.antlr.runtime.BaseRecognizer
alreadyParsedRule, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, consumeUntil, displayRecognitionError, emitErrorMessage, failed, getBacktrackingLevel, getErrorHeader, getErrorMessage, getGrammarFileName, getNumberOfSyntaxErrors, getRuleInvocationStack, getRuleInvocationStack, getRuleMemoization, getRuleMemoizationCacheSize, getTokenErrorDisplay, getTokenNames, match, matchAny, memoize, mismatchIsMissingToken, mismatchIsUnwantedToken, pushFollow, recover, recoverFromMismatchedSet, recoverFromMismatchedToken, setBacktrackingLevel, toStrings, traceIn, traceOut
-
-
-
-
Field Detail
-
dbg
protected DebugEventListener dbg
Who to notify when events in the parser occur.
-
isCyclicDecision
public boolean isCyclicDecision
Used to differentiate between fixed lookahead and cyclic DFA decisions while profiling.
-
-
Constructor Detail
-
DebugParser
public DebugParser(TokenStream input, DebugEventListener dbg, RecognizerSharedState state)
Create a normal parser except wrap the token stream in a debug proxy that fires consume events.
-
DebugParser
public DebugParser(TokenStream input, RecognizerSharedState state)
-
DebugParser
public DebugParser(TokenStream input, DebugEventListener dbg)
-
-
Method Detail
-
setDebugListener
public void setDebugListener(DebugEventListener dbg)
Provide a new debug event listener for this parser. Notify the input stream too that it should send events to this listener.
-
getDebugListener
public DebugEventListener getDebugListener()
-
reportError
public void reportError(IOException e)
-
beginResync
public void beginResync()
Description copied from class:BaseRecognizer
A hook to listen in on the token consumption during error recovery. The DebugParser subclasses this to fire events to the listenter.- Overrides:
beginResync
in classBaseRecognizer
-
endResync
public void endResync()
- Overrides:
endResync
in classBaseRecognizer
-
beginBacktrack
public void beginBacktrack(int level)
-
endBacktrack
public void endBacktrack(int level, boolean successful)
-
reportError
public void reportError(RecognitionException e)
Description copied from class:BaseRecognizer
Report a recognition problem. This method sets errorRecovery to indicate the parser is recovering not parsing. Once in recovery mode, no errors are generated. To get out of recovery mode, the parser must successfully match a token (after a resync). So it will go: 1. error occurs 2. enter recovery mode, report error 3. consume until token found in resynch set 4. try to resume parsing 5. next match() will reset errorRecovery mode If you override, make sure to update syntaxErrors if you care about that.- Overrides:
reportError
in classBaseRecognizer
-
-