public class DebugTreeAdaptor extends Object implements TreeAdaptor
Modifier and Type | Field and Description |
---|---|
protected TreeAdaptor |
adaptor |
protected DebugEventListener |
dbg |
Constructor and Description |
---|
DebugTreeAdaptor(DebugEventListener dbg,
TreeAdaptor adaptor) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(Object t,
Object child)
Add a child to the tree t.
|
void |
addChild(Object t,
Token child) |
Object |
becomeRoot(Object newRoot,
Object oldRoot)
If oldRoot is a nil root, just copy or move the children to newRoot.
|
Object |
becomeRoot(Token newRoot,
Object oldRoot)
Create a node for newRoot make it the root of oldRoot.
|
Object |
create(int tokenType,
String text)
Create a new node derived from a token, with a new token type.
|
Object |
create(int tokenType,
Token fromToken)
Create a new node derived from a token, with a new token type.
|
Object |
create(int tokenType,
Token fromToken,
String text)
Same as create(tokenType,fromToken) except set the text too.
|
Object |
create(Token payload)
Create a tree node from Token object; for CommonTree type trees,
then the token just becomes the payload.
|
Object |
deleteChild(Object t,
int i)
Remove ith child and shift children down from right.
|
Object |
dupNode(Object treeNode)
Duplicate a single tree node.
|
Object |
dupTree(Object tree)
Duplicate tree recursively, using dupNode() for each node
|
Object |
errorNode(TokenStream input,
Token start,
Token stop,
RecognitionException e)
Return a tree node representing an error.
|
Object |
getChild(Object t,
int i)
Get a child 0..n-1 node
|
int |
getChildCount(Object t)
How many children? If 0, then this is a leaf node
|
int |
getChildIndex(Object t)
What index is this node in the child list? Range: 0..n-1
If your node type doesn't handle this, it's ok but the tree rewrites
in tree parsers need this functionality.
|
DebugEventListener |
getDebugListener() |
Object |
getParent(Object t)
Who is the parent node of this node; if null, implies node is root.
|
String |
getText(Object t) |
Token |
getToken(Object t)
Return the token object from which this node was created.
|
int |
getTokenStartIndex(Object t)
Get the token start index for this subtree; return -1 if no such index
|
int |
getTokenStopIndex(Object t)
Get the token stop index for this subtree; return -1 if no such index
|
TreeAdaptor |
getTreeAdaptor() |
int |
getType(Object t)
For tree parsing, I need to know the token type of a node
|
int |
getUniqueID(Object node)
For identifying trees.
|
boolean |
isNil(Object tree)
Is tree considered a nil node used to make lists of child nodes?
|
Object |
nil()
Return a nil node (an empty but non-null node) that can hold
a list of element as the children.
|
void |
replaceChildren(Object parent,
int startChildIndex,
int stopChildIndex,
Object t)
Replace from start to stop child index of parent with t, which might
be a list.
|
Object |
rulePostProcessing(Object root)
Given the root of the subtree created for this rule, post process
it to do any simplifications or whatever you want.
|
void |
setChild(Object t,
int i,
Object child)
Set ith child (0..n-1) to t; t must be non-null and non-nil node
|
void |
setChildIndex(Object t,
int index) |
void |
setDebugListener(DebugEventListener dbg) |
void |
setParent(Object t,
Object parent) |
void |
setText(Object t,
String text)
Node constructors can set the text of a node
|
void |
setTokenBoundaries(Object t,
Token startToken,
Token stopToken)
Where are the bounds in the input token stream for this node and
all children? Each rule that creates AST nodes will call this
method right before returning.
|
void |
setType(Object t,
int type)
Node constructors can set the type of a node
|
protected void |
simulateTreeConstruction(Object t)
^(A B C): emit create A, create B, add child, ...
|
protected DebugEventListener dbg
protected TreeAdaptor adaptor
public DebugTreeAdaptor(DebugEventListener dbg, TreeAdaptor adaptor)
public Object create(Token payload)
TreeAdaptor
create
in interface TreeAdaptor
public Object errorNode(TokenStream input, Token start, Token stop, RecognitionException e)
TreeAdaptor
errorNode
in interface TreeAdaptor
public Object dupTree(Object tree)
TreeAdaptor
dupTree
in interface TreeAdaptor
protected void simulateTreeConstruction(Object t)
public Object dupNode(Object treeNode)
TreeAdaptor
dupNode
in interface TreeAdaptor
public Object nil()
TreeAdaptor
nil
in interface TreeAdaptor
public boolean isNil(Object tree)
TreeAdaptor
isNil
in interface TreeAdaptor
public void addChild(Object t, Object child)
TreeAdaptor
addChild
in interface TreeAdaptor
public Object becomeRoot(Object newRoot, Object oldRoot)
TreeAdaptor
becomeRoot
in interface TreeAdaptor
public Object rulePostProcessing(Object root)
TreeAdaptor
rulePostProcessing
in interface TreeAdaptor
public Object becomeRoot(Token newRoot, Object oldRoot)
TreeAdaptor
becomeRoot
in interface TreeAdaptor
public Object create(int tokenType, Token fromToken)
TreeAdaptor
create
in interface TreeAdaptor
public Object create(int tokenType, Token fromToken, String text)
TreeAdaptor
create
in interface TreeAdaptor
public Object create(int tokenType, String text)
TreeAdaptor
create
in interface TreeAdaptor
public int getType(Object t)
TreeAdaptor
getType
in interface TreeAdaptor
public void setType(Object t, int type)
TreeAdaptor
setType
in interface TreeAdaptor
public String getText(Object t)
getText
in interface TreeAdaptor
public void setText(Object t, String text)
TreeAdaptor
setText
in interface TreeAdaptor
public Token getToken(Object t)
TreeAdaptor
getToken
in interface TreeAdaptor
public void setTokenBoundaries(Object t, Token startToken, Token stopToken)
TreeAdaptor
setTokenBoundaries
in interface TreeAdaptor
public int getTokenStartIndex(Object t)
TreeAdaptor
getTokenStartIndex
in interface TreeAdaptor
public int getTokenStopIndex(Object t)
TreeAdaptor
getTokenStopIndex
in interface TreeAdaptor
public Object getChild(Object t, int i)
TreeAdaptor
getChild
in interface TreeAdaptor
public void setChild(Object t, int i, Object child)
TreeAdaptor
setChild
in interface TreeAdaptor
public Object deleteChild(Object t, int i)
TreeAdaptor
deleteChild
in interface TreeAdaptor
public int getChildCount(Object t)
TreeAdaptor
getChildCount
in interface TreeAdaptor
public int getUniqueID(Object node)
TreeAdaptor
getUniqueID
in interface TreeAdaptor
public Object getParent(Object t)
TreeAdaptor
getParent
in interface TreeAdaptor
public int getChildIndex(Object t)
TreeAdaptor
getChildIndex
in interface TreeAdaptor
public void setParent(Object t, Object parent)
setParent
in interface TreeAdaptor
public void setChildIndex(Object t, int index)
setChildIndex
in interface TreeAdaptor
public void replaceChildren(Object parent, int startChildIndex, int stopChildIndex, Object t)
TreeAdaptor
replaceChildren
in interface TreeAdaptor
public DebugEventListener getDebugListener()
public void setDebugListener(DebugEventListener dbg)
public TreeAdaptor getTreeAdaptor()
Copyright © 1992–2015 ANTLR. All rights reserved.