Logo Search packages:      
Sourcecode: antlr version File versions

antlr::ASTFactory Class Reference

List of all members.


Detailed Description

AST Support code shared by TreeParser and Parser.

AST Support code shared by TreeParser and Parser. We use delegation to share code (and have only one bit of code to maintain) rather than subclassing or superclassing (forces AST support code to be loaded even when you don't want to do AST stuff).

Typically, setASTNodeType is used to specify the homogeneous type of node to create, but you can override create to make heterogeneous nodes etc...

We use delegation to share code (and have only one bit of code to maintain) rather than subclassing or superclassing (forces AST support code to be loaded even when you don't want to do AST stuff).

Typically, setASTNodeType is used to specify the homogeneous type of node to create, but you can override create to make heterogeneous nodes etc...

Definition at line 26 of file ASTFactory.java.


Public Member Functions

virtual void addASTChild (ASTPair currentAST, AST child)
 Add a child to the current AST.
void addASTChild (ASTPair currentAST, AST child)
 ASTFactory (string nodeTypeName)
 Constructs an ASTFactory and use the specified AST node type as the default.
 ASTFactory ()
 Constructs an ASTFactory with the default AST node type of antlr.CommonAST.
 ASTFactory (Hashtable tokenTypeToClassMap)
virtual AST create (Token tok)
 Creates and initializes a new AST node using the specified Token instance. The System.Type used for creating this new AST node is determined by the following: .
virtual AST create (AST aNode)
 Creates and initializes a new AST node using the specified AST Node instance. the new AST node is initialized with the specified Token type ID and string. The System.Type used for creating this new AST node is determined solely by aNode. The AST Node type must have a default/parameterless constructor.
virtual AST create (Token tok, string ASTNodeTypeName)
 Creates a new AST node using the specified AST Node Type name.
virtual AST create (int type, string txt, string ASTNodeTypeName)
 Creates a new AST node using the specified AST Node Type name. Once created, the new AST node is initialized with the specified Token type ID and string. The System.Type used for creating this new AST node is determined solely by ASTNodeTypeName. The AST Node type must have a default/parameterless constructor.
virtual AST create (int type, string txt)
 Creates and initializes a new AST node using the specified Token Type ID. The System.Type used for creating this new AST node is determined by the following: .
virtual AST create (int type)
 Creates and initializes a new AST node using the specified Token Type ID. The System.Type used for creating this new AST node is determined by the following: .
virtual AST create ()
 Creates a new uninitialized AST node. Since a specific AST Node Type wasn't indicated, the new AST node is created using the current default AST Node type - defaultASTNodeTypeObject_.
AST create (Token tok, String className)
AST create (Token tok)
AST create (AST tr)
AST create (int type, String txt, String className)
AST create (int type, String txt)
AST create (int type)
AST create ()
virtual AST dup (AST t)
 Returns a copy of the specified AST Node instance. The copy is obtained by using the ICloneable method Clone().
AST dup (AST t)
virtual AST dupList (AST t)
 Duplicate AST Node tree rooted at specified AST node and all of it's siblings.
AST dupList (AST t)
virtual AST dupTree (AST t)
 Duplicate AST Node tree rooted at specified AST node. Ignore it's siblings.
AST dupTree (AST t)
virtual void error (string e)
 To change where error messages go, can subclass/override this method and then setASTFactory in Parser and TreeParser. This method removes a prior dependency on class antlr.Tool.
void error (String e)
Class getASTNodeType (int tokenType)
Hashtable getTokenTypeToASTClassMap ()
virtual AST make (ASTArray nodes)
 Make a tree from a list of nodes, where the nodes are contained in an ASTArray object.
virtual AST make (AST[] nodes)
 Make a tree from a list of nodes. The first element in the array is the root. If the root is null, then the tree is a simple list not a tree. Handles null children nodes correctly. For example, build(a, b, null, c) yields tree (a b c). build(null,a,b) yields tree (nil a b).
AST make (ASTArray nodes)
AST make (AST[] nodes)
virtual void makeASTRoot (ASTPair currentAST, AST root)
 Make an AST the root of current AST.
void makeASTRoot (ASTPair currentAST, AST root)
void registerFactory (int NodeType, string NodeTypeName)
 Register an AST Node Type for a given Token type ID.
void setASTNodeClass (String t)
virtual void setASTNodeType (string t)
 Sets the global default AST Node Type for this ASTFactory instance. This method also attempts to load the System.Type instance for the specified typename.
void setASTNodeType (String t)
void setMaxNodeType (int NodeType)
 Pre-expands the internal list of TokenTypeID-to-ASTNodeType mappings to the specified size. This is primarily a convenience method that can be used to prevent unnecessary and costly re-org of the mappings list.
void setTokenTypeASTNodeType (int tokenType, string NodeTypeName)
 Specify an "override" for the AST type created for the specified Token type.
void setTokenTypeASTNodeType (int tokenType, String className) throws IllegalArgumentException
void setTokenTypeToASTClassMap (Hashtable tokenTypeToClassMap)

Protected Member Functions

AST create (Class c)
AST create (String className)
AST createUsingCtor (Token token, String className)

Protected Attributes

Type defaultASTNodeTypeObject_
 Stores the Type of the default AST node class to be used during tree construction.
Type[] nodeTypeObjectList_
 Stores the mapping between custom AST NodeTypes and their NodeTypeName/NodeTypeClass.
String theASTNodeType = null
Class theASTNodeTypeClass = null
Hashtable tokenTypeToASTClassMap = null

Private Member Functions

AST createFromNodeName (string nodeTypeName)
AST createFromNodeType (int nodeTypeIndex)
AST createFromNodeTypeObject (Type nodeTypeObject)
Type loadNodeTypeObject (string nodeTypeName)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index