Click or drag to resize

CommonTreeAdaptor Class

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.
Inheritance Hierarchy

Namespace:  Stimulsoft.Data.Expressions.Antlr.Runtime.Tree
Assembly:  Stimulsoft.Data (in Stimulsoft.Data.dll) Version: 2019.3.1.0
Syntax
public class CommonTreeAdaptor : BaseTreeAdaptor

The CommonTreeAdaptor type exposes the following members.

Constructors
  NameDescription
Public methodCommonTreeAdaptor
Initializes a new instance of the CommonTreeAdaptor class
Top
Methods
  NameDescription
Public methodAddChild
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.
(Inherited from BaseTreeAdaptor.)
Public methodBecomeRoot(Object, Object)
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.
(Inherited from BaseTreeAdaptor.)
Public methodBecomeRoot(IToken, Object) (Inherited from BaseTreeAdaptor.)
Public methodCreate(IToken) (Overrides BaseTreeAdaptorCreate(IToken).)
Public methodCreate(Int32, IToken) (Inherited from BaseTreeAdaptor.)
Public methodCreate(Int32, String) (Inherited from BaseTreeAdaptor.)
Public methodCreate(IToken, String) (Inherited from BaseTreeAdaptor.)
Public methodCreate(Int32, IToken, String) (Inherited from BaseTreeAdaptor.)
Public methodCreateToken(IToken)
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).
(Overrides BaseTreeAdaptorCreateToken(IToken).)
Public methodCreateToken(Int32, String)
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).
(Overrides BaseTreeAdaptorCreateToken(Int32, String).)
Public methodDeleteChild (Inherited from BaseTreeAdaptor.)
Public methodDupNode(Object)
Duplicate a node. This is part of the factory; override if you want another kind of node to be built.
(Inherited from BaseTreeAdaptor.)
Public methodDupNode(Int32, Object) (Inherited from BaseTreeAdaptor.)
Public methodDupNode(Object, String) (Inherited from BaseTreeAdaptor.)
Public methodDupNode(Int32, Object, String) (Inherited from BaseTreeAdaptor.)
Public methodDupTree(Object) (Inherited from BaseTreeAdaptor.)
Public methodDupTree(Object, Object)
This is generic in the sense that it will work with any kind of tree (not just ITree interface). It invokes the adaptor routines not the tree node routines to do the construction.
(Inherited from BaseTreeAdaptor.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodErrorNode
Create tree node that holds the start and stop tokens associated with an error.
(Inherited from BaseTreeAdaptor.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetChild (Inherited from BaseTreeAdaptor.)
Public methodGetChildCount (Inherited from BaseTreeAdaptor.)
Public methodGetChildIndex (Inherited from BaseTreeAdaptor.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetParent (Inherited from BaseTreeAdaptor.)
Public methodGetText (Inherited from BaseTreeAdaptor.)
Public methodGetToken
What is the Token associated with this node? If you are not using CommonTree, then you must override this in your own adaptor.
(Overrides BaseTreeAdaptorGetToken(Object).)
Public methodGetTokenStartIndex (Inherited from BaseTreeAdaptor.)
Public methodGetTokenStopIndex (Inherited from BaseTreeAdaptor.)
Protected methodGetTree (Inherited from BaseTreeAdaptor.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetType(Object) (Inherited from BaseTreeAdaptor.)
Public methodGetUniqueID (Inherited from BaseTreeAdaptor.)
Public methodIsNil (Inherited from BaseTreeAdaptor.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNil (Inherited from BaseTreeAdaptor.)
Public methodReplaceChildren (Inherited from BaseTreeAdaptor.)
Public methodRulePostProcessing
Transform ^(nil x) to x and nil to null
(Inherited from BaseTreeAdaptor.)
Public methodSetChild (Inherited from BaseTreeAdaptor.)
Public methodSetChildIndex (Inherited from BaseTreeAdaptor.)
Public methodSetParent (Inherited from BaseTreeAdaptor.)
Public methodSetText (Inherited from BaseTreeAdaptor.)
Public methodSetTokenBoundaries
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.
(Inherited from BaseTreeAdaptor.)
Public methodSetType (Inherited from BaseTreeAdaptor.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Fields
  NameDescription
Protected fieldtreeToUniqueIDMap
System.identityHashCode() is not always unique; 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.
(Inherited from BaseTreeAdaptor.)
Protected fielduniqueNodeID (Inherited from BaseTreeAdaptor.)
Top
Remarks
To get your parser to build nodes of a different type, override create(Token), errorNode(), and to be safe, YourTreeClass.dupNode(). dupNode is called to duplicate nodes during rewrite operations.
See Also