org.antlr.runtime.debug
Class TraceDebugEventListener

java.lang.Object
  extended by org.antlr.runtime.debug.BlankDebugEventListener
      extended by org.antlr.runtime.debug.TraceDebugEventListener
All Implemented Interfaces:
DebugEventListener

public class TraceDebugEventListener
extends BlankDebugEventListener

Print out (most of) the events... Useful for debugging, testing...


Field Summary
 
Fields inherited from interface org.antlr.runtime.debug.DebugEventListener
FALSE, PROTOCOL_VERSION, TRUE
 
Constructor Summary
TraceDebugEventListener()
           
 
Method Summary
 void addChild(int rootID, int childID)
          Make childID a child of rootID.
 void becomeRoot(int newRootID, int oldRootID)
          Make a node the new root of an existing root.
 void consumeNode(int ID, java.lang.String text, int type)
          Input for a tree parser is an AST, but we know nothing for sure about a node except its type and text (obtained from the adaptor).
 void createNode(int ID, int tokenIndex)
          Announce a new node built from an existing token
 void createNode(int ID, java.lang.String text, int type)
          Announce a new node built from text
 void enterRule(java.lang.String ruleName)
          The parser has just entered a rule.
 void enterSubRule(int decisionNumber)
          Track entry into any (...) subrule other EBNF construct
 void exitRule(java.lang.String ruleName)
          This is the last thing executed before leaving a rule.
 void exitSubRule(int decisionNumber)
           
 void location(int line, int pos)
          To watch a parser move through the grammar, the parser needs to inform the debugger what line/charPos it is passing in the grammar.
 void LT(int i, int ID, java.lang.String text, int type)
          The tree parser lookedahead.
 void nilNode(int ID)
          A nil was created (even nil nodes have a unique ID...
 void setTokenBoundaries(int ID, int tokenStartIndex, int tokenStopIndex)
          Set the token start/stop token index for a subtree root or node
 void trimNilRoot(int ID)
           
 
Methods inherited from class org.antlr.runtime.debug.BlankDebugEventListener
beginBacktrack, beginResync, commence, consumeHiddenToken, consumeToken, endBacktrack, endResync, enterAlt, enterDecision, exitDecision, LT, mark, recognitionException, rewind, rewind, semanticPredicate, terminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TraceDebugEventListener

public TraceDebugEventListener()
Method Detail

enterRule

public void enterRule(java.lang.String ruleName)
Description copied from interface: DebugEventListener
The parser has just entered a rule. No decision has been made about which alt is predicted. This is fired AFTER init actions have been executed. Attributes are defined and available etc...

Specified by:
enterRule in interface DebugEventListener
Overrides:
enterRule in class BlankDebugEventListener

exitRule

public void exitRule(java.lang.String ruleName)
Description copied from interface: DebugEventListener
This is the last thing executed before leaving a rule. It is executed even if an exception is thrown. This is triggered after error reporting and recovery have occurred (unless the exception is not caught in this rule). This implies an "exitAlt" event.

Specified by:
exitRule in interface DebugEventListener
Overrides:
exitRule in class BlankDebugEventListener

enterSubRule

public void enterSubRule(int decisionNumber)
Description copied from interface: DebugEventListener
Track entry into any (...) subrule other EBNF construct

Specified by:
enterSubRule in interface DebugEventListener
Overrides:
enterSubRule in class BlankDebugEventListener

exitSubRule

public void exitSubRule(int decisionNumber)
Specified by:
exitSubRule in interface DebugEventListener
Overrides:
exitSubRule in class BlankDebugEventListener

location

public void location(int line,
                     int pos)
Description copied from interface: DebugEventListener
To watch a parser move through the grammar, the parser needs to inform the debugger what line/charPos it is passing in the grammar. For now, this does not know how to switch from one grammar to the other and back for island grammars etc... This should also allow breakpoints because the debugger can stop the parser whenever it hits this line/pos.

Specified by:
location in interface DebugEventListener
Overrides:
location in class BlankDebugEventListener

consumeNode

public void consumeNode(int ID,
                        java.lang.String text,
                        int type)
Description copied from interface: DebugEventListener
Input for a tree parser is an AST, but we know nothing for sure about a node except its type and text (obtained from the adaptor). This is the analog of the consumeToken method. Again, the ID is the hashCode usually of the node so it only works if hashCode is not implemented. If the type is UP or DOWN, then the ID is not really meaningful as it's fixed--there is just one UP node and one DOWN navigation node.

Specified by:
consumeNode in interface DebugEventListener
Overrides:
consumeNode in class BlankDebugEventListener

LT

public void LT(int i,
               int ID,
               java.lang.String text,
               int type)
Description copied from interface: DebugEventListener
The tree parser lookedahead. If the type is UP or DOWN, then the ID is not really meaningful as it's fixed--there is just one UP node and one DOWN navigation node.

Specified by:
LT in interface DebugEventListener
Overrides:
LT in class BlankDebugEventListener

nilNode

public void nilNode(int ID)
Description copied from interface: DebugEventListener
A nil was created (even nil nodes have a unique ID... they are not "null" per se). As of 4/28/2006, this seems to be uniquely triggered when starting a new subtree such as when entering a subrule in automatic mode and when building a tree in rewrite mode.

Specified by:
nilNode in interface DebugEventListener
Overrides:
nilNode in class BlankDebugEventListener

createNode

public void createNode(int ID,
                       java.lang.String text,
                       int type)
Description copied from interface: DebugEventListener
Announce a new node built from text

Specified by:
createNode in interface DebugEventListener
Overrides:
createNode in class BlankDebugEventListener

createNode

public void createNode(int ID,
                       int tokenIndex)
Description copied from interface: DebugEventListener
Announce a new node built from an existing token

Specified by:
createNode in interface DebugEventListener
Overrides:
createNode in class BlankDebugEventListener

becomeRoot

public void becomeRoot(int newRootID,
                       int oldRootID)
Description copied from interface: DebugEventListener
Make a node the new root of an existing root. See Note: the newRootID parameter is possibly different than the TreeAdaptor.becomeRoot() newRoot parameter. In our case, it will always be the result of calling TreeAdaptor.becomeRoot() and not root_n or whatever. The listener should assume that this event occurs only when the current subrule (or rule) subtree is being reset to newRootID.

Specified by:
becomeRoot in interface DebugEventListener
Overrides:
becomeRoot in class BlankDebugEventListener
See Also:
org.antlr.runtime.tree.TreeAdaptor.becomeRoot()

addChild

public void addChild(int rootID,
                     int childID)
Description copied from interface: DebugEventListener
Make childID a child of rootID.

Specified by:
addChild in interface DebugEventListener
Overrides:
addChild in class BlankDebugEventListener
See Also:
org.antlr.runtime.tree.TreeAdaptor.addChild()

trimNilRoot

public void trimNilRoot(int ID)

setTokenBoundaries

public void setTokenBoundaries(int ID,
                               int tokenStartIndex,
                               int tokenStopIndex)
Description copied from interface: DebugEventListener
Set the token start/stop token index for a subtree root or node

Specified by:
setTokenBoundaries in interface DebugEventListener
Overrides:
setTokenBoundaries in class BlankDebugEventListener