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).
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
Returns
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
public override function createWithPayload(payload:Token):ObjectParameters
Returns
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
Returns
public override function getChild(t:Object, i:int):ObjectParameters
Returns
public override function getChildCount(t:Object):intParameters
Returns
public override function getChildIndex(t:Object):intParameters
Returns
public override function getParent(t:Object):ObjectParameters
Returns
public override function getText(t:Object):StringParameters
Returns
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
Returns
public override function getTokenStartIndex(t:Object):intParameters
Returns
public override function getTokenStopIndex(t:Object):intParameters
Returns
public override function getType(t:Object):intParameters
Returns
public override function replaceChildren(parent:Object, startChildIndex:int, stopChildIndex:int, t:Object):voidParameters
| parent:Object |
| |
| startChildIndex:int |
| |
| stopChildIndex:int |
| |
| t:Object |
public override function setChildIndex(t:Object, index:int):voidParameters
public override function setParent(t:Object, parent:Object):voidParameters
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