| java.lang.Object org.antlr.runtime.tree.BaseTreeAdaptor
All known Subclasses: org.antlr.runtime.tree.CommonTreeAdaptor,
Method Summary | |
public void | addChild(Object t, Object child) Add a child to the tree t. | public Object | becomeRoot(Object newRoot, Object oldRoot) If oldRoot is a nil root, just copy or move the children to newRoot.
If not a nil root, make oldRoot a child of newRoot.
old=^(nil a b c), new=r yields ^(r a b c)
old=^(a b c), new=r yields ^(r ^(a b c))
If newRoot is a nil-rooted single child tree, use the single
child as the new root node.
old=^(nil a b c), new=^(nil r) yields ^(r a b c)
old=^(a b c), new=^(nil r) yields ^(r ^(a b c))
If oldRoot was null, it's ok, just return newRoot (even if isNil).
old=null, new=r yields r
old=null, new=^(nil r) yields ^(nil r)
Return newRoot. | public Object | becomeRoot(Token newRoot, Object oldRoot) | public Object | create(int tokenType, Token fromToken) | public Object | create(int tokenType, Token fromToken, String text) | public Object | create(int tokenType, String text) | abstract public Token | createToken(int tokenType, String text) Tell me how to create a token for use with imaginary token nodes. | abstract public Token | createToken(Token fromToken) Tell me how to create a token for use with imaginary token nodes.
For example, there is probably no input symbol associated with imaginary
token DECL, but you need to create it as a payload or whatever for
the DECL node as in ^(DECL type ID).
This is a variant of createToken where the new token is derived from
an actual real input token. | public Object | dupTree(Object tree) | public Object | getChild(Object t, int i) | public int | getChildCount(Object t) | public String | getText(Object t) | public int | getType(Object t) | public int | getUniqueID(Object node) | public boolean | isNil(Object tree) | public Object | nil() | public Object | rulePostProcessing(Object root) | public void | setText(Object t, String text) | public void | setType(Object t, int type) |
treeToUniqueIDMap | protected Map treeToUniqueIDMap(Code) | | System.identityHashCode() is not always unique due to GC; we have to
track ourselves. That's ok, it's only for debugging, though it's
expensive: we have to create a hashtable with all tree nodes in it.
|
uniqueNodeID | protected int uniqueNodeID(Code) | | |
addChild | public void addChild(Object t, Object child)(Code) | | Add a child to the tree t. If child is a flat tree (a list), make all
in list children of t. Warning: if t has no children, but child does
and child isNil then you can decide it is ok to move children to t via
t.children = child.children; i.e., without copying the array. Just
make sure that this is consistent with have the user will build
ASTs.
|
becomeRoot | public Object becomeRoot(Object newRoot, Object oldRoot)(Code) | | If oldRoot is a nil root, just copy or move the children to newRoot.
If not a nil root, make oldRoot a child of newRoot.
old=^(nil a b c), new=r yields ^(r a b c)
old=^(a b c), new=r yields ^(r ^(a b c))
If newRoot is a nil-rooted single child tree, use the single
child as the new root node.
old=^(nil a b c), new=^(nil r) yields ^(r a b c)
old=^(a b c), new=^(nil r) yields ^(r ^(a b c))
If oldRoot was null, it's ok, just return newRoot (even if isNil).
old=null, new=r yields r
old=null, new=^(nil r) yields ^(nil r)
Return newRoot. Throw an exception if newRoot is not a
simple node or nil root with a single child node--it must be a root
node. If newRoot is ^(nil x) return x as newRoot.
Be advised that it's ok for newRoot to point at oldRoot's
children; i.e., you don't have to copy the list. We are
constructing these nodes so we should have this control for
efficiency.
|
createToken | abstract public Token createToken(int tokenType, String text)(Code) | | Tell me how to create a token for use with imaginary token nodes.
For example, there is probably no input symbol associated with imaginary
token DECL, but you need to create it as a payload or whatever for
the DECL node as in ^(DECL type ID).
If you care what the token payload objects' type is, you should
override this method and any other createToken variant.
|
createToken | abstract public Token createToken(Token fromToken)(Code) | | Tell me how to create a token for use with imaginary token nodes.
For example, there is probably no input symbol associated with imaginary
token DECL, but you need to create it as a payload or whatever for
the DECL node as in ^(DECL type ID).
This is a variant of createToken where the new token is derived from
an actual real input token. Typically this is for converting '{'
tokens to BLOCK etc... You'll see
r : lc='{' ID+ '}' -> ^(BLOCK[$lc] ID+) ;
If you care what the token payload objects' type is, you should
override this method and any other createToken variant.
|
rulePostProcessing | public Object rulePostProcessing(Object root)(Code) | | Transform ^(nil x) to x
|
|
|