org.antlr.runtime.debug
Class DebugParser

java.lang.Object
  extended by org.antlr.runtime.BaseRecognizer
      extended by org.antlr.runtime.Parser
          extended by org.antlr.runtime.debug.DebugParser

public class DebugParser
extends Parser


Field Summary
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.Parser
input
 
Fields inherited from class org.antlr.runtime.BaseRecognizer
_fsp, backtracking, DEFAULT_TOKEN_CHANNEL, errorRecovery, failed, following, HIDDEN, INITIAL_FOLLOW_STACK_SIZE, lastErrorIndex, MEMO_RULE_FAILED, MEMO_RULE_FAILED_I, MEMO_RULE_UNKNOWN, NEXT_TOKEN_RULE_NAME, ruleMemo
 
Constructor Summary
DebugParser(TokenStream input)
           
DebugParser(TokenStream input, DebugEventListener dbg)
          Create a normal parser except wrap the token stream in a debug proxy that fires consume events.
DebugParser(TokenStream input, int port)
          Create a proxy to marshall events across socket to another listener.
 
Method Summary
 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 recoverFromMismatchedSet(IntStream input, RecognitionException mte, BitSet follow)
           
 void recoverFromMismatchedToken(IntStream input, RecognitionException mte, int ttype, BitSet follow)
          Attempt to recover from a single missing or extra token.
 void reportError(java.io.IOException e)
           
 void setDebugListener(DebugEventListener dbg)
          Provide a new debug event listener for this parser.
 
Methods inherited from class org.antlr.runtime.Parser
getTokenStream, reset, setTokenStream, traceIn, traceOut
 
Methods inherited from class org.antlr.runtime.BaseRecognizer
alreadyParsedRule, combineFollows, computeContextSensitiveRuleFOLLOW, computeErrorRecoverySet, consumeUntil, consumeUntil, displayRecognitionError, emitErrorMessage, getBacktrackingLevel, getErrorHeader, getErrorMessage, getGrammarFileName, getRuleInvocationStack, getRuleInvocationStack, getRuleMemoization, getRuleMemoizationCacheSize, getTokenErrorDisplay, getTokenNames, match, matchAny, memoize, mismatch, pushFollow, recover, recoverFromMismatchedElement, reportError, toStrings, traceIn, traceOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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)
Create a normal parser except wrap the token stream in a debug proxy that fires consume events.


DebugParser

public DebugParser(TokenStream input)

DebugParser

public DebugParser(TokenStream input,
                   int port)
Create a proxy to marshall events across socket to another listener. This constructor returns after handshaking with debugger so programmer does not have to manually invoke handshake.

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(java.io.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 class BaseRecognizer

endResync

public void endResync()
Overrides:
endResync in class BaseRecognizer

beginBacktrack

public void beginBacktrack(int level)

endBacktrack

public void endBacktrack(int level,
                         boolean successful)

recoverFromMismatchedToken

public void recoverFromMismatchedToken(IntStream input,
                                       RecognitionException mte,
                                       int ttype,
                                       BitSet follow)
                                throws RecognitionException
Description copied from class: BaseRecognizer
Attempt to recover from a single missing or extra token. EXTRA TOKEN LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(), which advances the input. MISSING TOKEN If current token is consistent with what could come after ttype then it is ok to "insert" the missing token, else throw exception For example, Input "i=(3;" is clearly missing the ')'. When the parser returns from the nested call to expr, it will have call chain: stat -> expr -> atom and it will be trying to match the ')' at this point in the derivation: => ID '=' '(' INT ')' ('+' atom)* ';' ^ match() will see that ';' doesn't match ')' and report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'.

Overrides:
recoverFromMismatchedToken in class BaseRecognizer
Throws:
RecognitionException

recoverFromMismatchedSet

public void recoverFromMismatchedSet(IntStream input,
                                     RecognitionException mte,
                                     BitSet follow)
                              throws RecognitionException
Overrides:
recoverFromMismatchedSet in class BaseRecognizer
Throws:
RecognitionException