Packageorg.antlr.runtime.tree
Classpublic class CommonTreeAdaptor
InheritanceCommonTreeAdaptor Inheritance BaseTreeAdaptor

A TreeAdaptor that works with any Tree implementation. It provides really just factory methods; all the work is done by BaseTreeAdaptor. If you would like to have different tokens created than ClassicToken objects, you need to override this and then set the parser tree adaptor to use your subclass. To get your parser to build nodes of a different type, override create(Token).



Protected Properties
 PropertyDefined by
 InheritedtreeToUniqueIDMap : Dictionary
System.identityHashCode() is not always unique; we have to track ourselves.
BaseTreeAdaptor
 InheriteduniqueNodeID : int = 1
BaseTreeAdaptor
Public Methods
 MethodDefined by
 Inherited
addChild(t:Object, child:Object):void
Add a child to the tree t.
BaseTreeAdaptor
 Inherited
becomeRoot(newRoot:Object, oldRoot:Object):Object
If oldRoot is a nil root, just copy or move the children to newRoot.
BaseTreeAdaptor
 Inherited
create(... args):Object
BaseTreeAdaptor
 Inherited
createFromToken(tokenType:int, fromToken:Token, text:String = null):Object
BaseTreeAdaptor
 Inherited
createFromType(tokenType:int, text:String):Object
BaseTreeAdaptor
  
createToken(fromToken:Token):Token
Tell me how to create a token for use with imaginary token nodes.
CommonTreeAdaptor
  
createTokenFromType(tokenType:int, text:String):Token
Tell me how to create a token for use with imaginary token nodes.
CommonTreeAdaptor
  
createWithPayload(payload:Token):Object
CommonTreeAdaptor
 Inherited
deleteChild(t:Object, i:int):Object
BaseTreeAdaptor
  
dupNode(t:Object):Object
Duplicate a node.
CommonTreeAdaptor
 Inherited
dupTree(tree:Object):Object
BaseTreeAdaptor
 Inherited
dupTreeWithParent(t:Object, parent:Object):Object
This is generic in the sense that it will work with any kind of tree (not just Tree interface).
BaseTreeAdaptor
 Inherited
errorNode(input:TokenStream, start:Token, stop:Token, e:RecognitionException):Object
create tree node that holds the start and stop tokens associated with an error.
BaseTreeAdaptor
  
getChild(t:Object, i:int):Object
CommonTreeAdaptor
  
getChildCount(t:Object):int
CommonTreeAdaptor
  
getChildIndex(t:Object):int
CommonTreeAdaptor
  
getParent(t:Object):Object
CommonTreeAdaptor
  
getText(t:Object):String
CommonTreeAdaptor
  
getToken(t:Object):Token
What is the Token associated with this node? If you are not using CommonTree, then you must override this in your own adaptor.
CommonTreeAdaptor
  
getTokenStartIndex(t:Object):int
CommonTreeAdaptor
  
getTokenStopIndex(t:Object):int
CommonTreeAdaptor
  
getType(t:Object):int
CommonTreeAdaptor
 Inherited
getUniqueID(node:Object):int
BaseTreeAdaptor
 Inherited
isNil(tree:Object):Boolean
BaseTreeAdaptor
 Inherited
nil():Object
BaseTreeAdaptor
  
replaceChildren(parent:Object, startChildIndex:int, stopChildIndex:int, t:Object):void
CommonTreeAdaptor
 Inherited
rulePostProcessing(root:Object):Object
Transform ^(nil x) to x and nil to null
BaseTreeAdaptor
 Inherited
setChild(t:Object, i:int, child:Object):void
BaseTreeAdaptor
  
setChildIndex(t:Object, index:int):void
CommonTreeAdaptor
  
setParent(t:Object, parent:Object):void
CommonTreeAdaptor
 Inherited
setText(t:Object, text:String):void
BaseTreeAdaptor
  
setTokenBoundaries(t:Object, startToken:Token, stopToken:Token):void
Track start/stop token for subtree root created for a rule.
CommonTreeAdaptor
 Inherited
setType(t:Object, type:int):void
BaseTreeAdaptor
Method detail
createToken()method
public override function createToken(fromToken:Token):Token

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.

Parameters
fromToken:Token

Returns
Token
createTokenFromType()method 
public override function createTokenFromType(tokenType:int, text:String):Token

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.

Parameters
tokenType:int
 
text:String

Returns
Token
createWithPayload()method 
public override function createWithPayload(payload:Token):ObjectParameters
payload:Token

Returns
Object
dupNode()method 
public override function dupNode(t:Object):Object

Duplicate a node. This is part of the factory; override if you want another kind of node to be built. I could use reflection to prevent having to override this but reflection is slow.

Parameters
t:Object

Returns
Object
getChild()method 
public override function getChild(t:Object, i:int):ObjectParameters
t:Object
 
i:int

Returns
Object
getChildCount()method 
public override function getChildCount(t:Object):intParameters
t:Object

Returns
int
getChildIndex()method 
public override function getChildIndex(t:Object):intParameters
t:Object

Returns
int
getParent()method 
public override function getParent(t:Object):ObjectParameters
t:Object

Returns
Object
getText()method 
public override function getText(t:Object):StringParameters
t:Object

Returns
String
getToken()method 
public override function getToken(t:Object):Token

What is the Token associated with this node? If you are not using CommonTree, then you must override this in your own adaptor.

Parameters
t:Object

Returns
Token
getTokenStartIndex()method 
public override function getTokenStartIndex(t:Object):intParameters
t:Object

Returns
int
getTokenStopIndex()method 
public override function getTokenStopIndex(t:Object):intParameters
t:Object

Returns
int
getType()method 
public override function getType(t:Object):intParameters
t:Object

Returns
int
replaceChildren()method 
public override function replaceChildren(parent:Object, startChildIndex:int, stopChildIndex:int, t:Object):voidParameters
parent:Object
 
startChildIndex:int
 
stopChildIndex:int
 
t:Object
setChildIndex()method 
public override function setChildIndex(t:Object, index:int):voidParameters
t:Object
 
index:int
setParent()method 
public override function setParent(t:Object, parent:Object):voidParameters
t:Object
 
parent:Object
setTokenBoundaries()method 
public override function setTokenBoundaries(t:Object, startToken:Token, stopToken:Token):void

Track start/stop token for subtree root created for a rule. Only works with Tree nodes. For rules that match nothing, seems like this will yield start=i and stop=i-1 in a nil node. Might be useful info so I'll not force to be i..i.

Parameters
t:Object
 
startToken:Token
 
stopToken:Token