Package schrodinger :: Package application :: Package desmond :: Package antlr3 :: Module debug :: Class TraceDebugEventListener
[hide private]
[frames] | no frames]

Class TraceDebugEventListener

        object --+    
                 |    
DebugEventListener --+
                     |
                    TraceDebugEventListener
Known Subclasses:

A listener that simply records text representations of the events.

Useful for debugging the debugging facility ;)

Subclasses can override the record() method (which defaults to printing to stdout) to record the events in a different way.

Instance Methods [hide private]
 
__init__(self, adaptor=None)
x.__init__(...) initializes x; see help(type(x)) for signature
 
record(self, event)
 
enterRule(self, grammarFileName, ruleName)
The parser has just entered a rule.
 
exitRule(self, grammarFileName, ruleName)
This is the last thing executed before leaving a rule.
 
enterSubRule(self, decisionNumber)
Track entry into any (...) subrule other EBNF construct
 
exitSubRule(self, decisionNumber)
 
location(self, line, 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.
 
consumeNode(self, t)
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).
 
LT(self, i, t)
The tree parser lookedahead.
 
nilNode(self, t)
A nil was created (even nil nodes have a unique ID...
 
createNode(self, t, token=None)
Announce a new node built from token elements such as type etc...
 
becomeRoot(self, newRoot, oldRoot)
Make a node the new root of an existing root.
 
addChild(self, root, child)
Make childID a child of rootID.
 
setTokenBoundaries(self, t, tokenStartIndex, tokenStopIndex)
Set the token start/stop token index for a subtree root or node.

Inherited from DebugEventListener: beginBacktrack, beginResync, commence, consumeHiddenToken, consumeToken, endBacktrack, endResync, enterAlt, enterDecision, errorNode, exitDecision, mark, recognitionException, rewind, semanticPredicate, terminate

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from DebugEventListener: PROTOCOL_VERSION

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, adaptor=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

enterRule(self, grammarFileName, ruleName)

 

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... The grammarFileName allows composite grammars to jump around among multiple grammar files.

Overrides: DebugEventListener.enterRule
(inherited documentation)

exitRule(self, grammarFileName, ruleName)

 

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. The grammarFileName allows composite grammars to jump around among multiple grammar files.

Overrides: DebugEventListener.exitRule
(inherited documentation)

enterSubRule(self, decisionNumber)

 

Track entry into any (...) subrule other EBNF construct

Overrides: DebugEventListener.enterSubRule
(inherited documentation)

exitSubRule(self, decisionNumber)

 
Overrides: DebugEventListener.exitSubRule

location(self, line, 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. 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.

Overrides: DebugEventListener.location
(inherited documentation)

consumeNode(self, t)

 

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.

Overrides: DebugEventListener.consumeNode
(inherited documentation)

LT(self, i, t)

 

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.

Overrides: DebugEventListener.LT
(inherited documentation)

nilNode(self, t)

 

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.

If you are receiving this event over a socket via RemoteDebugEventSocketListener then only t.ID is set.

Overrides: DebugEventListener.nilNode
(inherited documentation)

createNode(self, t, token=None)

 

Announce a new node built from token elements such as type etc...

If you are receiving this event over a socket via RemoteDebugEventSocketListener then only t.ID, type, text are set.

Overrides: DebugEventListener.createNode
(inherited documentation)

becomeRoot(self, newRoot, oldRoot)

 

Make a node the new root of an existing root.

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.

If you are receiving this event over a socket via RemoteDebugEventSocketListener then only IDs are set.

@see antlr3.tree.TreeAdaptor.becomeRoot()

Overrides: DebugEventListener.becomeRoot
(inherited documentation)

addChild(self, root, child)

 

Make childID a child of rootID.

If you are receiving this event over a socket via RemoteDebugEventSocketListener then only IDs are set.

@see antlr3.tree.TreeAdaptor.addChild()

Overrides: DebugEventListener.addChild
(inherited documentation)

setTokenBoundaries(self, t, tokenStartIndex, tokenStopIndex)

 

Set the token start/stop token index for a subtree root or node.

If you are receiving this event over a socket via RemoteDebugEventSocketListener then only t.ID is set.

Overrides: DebugEventListener.setTokenBoundaries
(inherited documentation)