public class ASTFactory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
theASTNodeType
Name of AST class to create during tree construction.
|
protected java.lang.Class |
theASTNodeTypeClass |
protected java.util.Hashtable |
tokenTypeToASTClassMap
How to specify the classname to create for a particular
token type.
|
Constructor and Description |
---|
ASTFactory() |
ASTFactory(java.util.Hashtable tokenTypeToClassMap)
Create factory with a specific mapping from token type
to Java AST node type.
|
Modifier and Type | Method and Description |
---|---|
void |
addASTChild(ASTPair currentAST,
AST child)
Add a child to the current AST
|
AST |
create()
Create a new empty AST node; if the user did not specify
an AST node type, then create a default one: CommonAST.
|
AST |
create(AST tr)
Create a new empty AST node; if the user did not specify
an AST node type, then create a default one: CommonAST.
|
protected AST |
create(java.lang.Class c) |
AST |
create(int type) |
AST |
create(int type,
java.lang.String txt) |
AST |
create(int type,
java.lang.String txt,
java.lang.String className)
Create an AST node with the token type and text passed in, but
with a specific Java object type.
|
AST |
create(java.lang.String className) |
AST |
create(Token tok) |
AST |
create(Token tok,
java.lang.String className)
ANTLR generates reference to this when you reference a token
that has a specified heterogeneous AST node type.
|
protected AST |
createUsingCtor(Token token,
java.lang.String className) |
AST |
dup(AST t)
Copy a single node with same Java AST objec type.
|
AST |
dupList(AST t)
Duplicate tree including siblings of root.
|
AST |
dupTree(AST t)
Duplicate a tree, assuming this is a root node of a tree--
duplicate that node and what's below; ignore siblings of root node.
|
void |
error(java.lang.String e)
To change where error messages go, can subclass/override this method
and then setASTFactory in Parser and TreeParser.
|
java.lang.Class |
getASTNodeType(int tokenType)
For a given token type, what is the AST node object type to create
for it?
|
java.util.Hashtable |
getTokenTypeToASTClassMap() |
AST |
make(AST[] nodes)
Make a tree from a list of nodes.
|
AST |
make(ASTArray nodes)
Make a tree from a list of nodes, where the nodes are contained
in an ASTArray object
|
void |
makeASTRoot(ASTPair currentAST,
AST root)
Make an AST the root of current AST
|
void |
setASTNodeClass(java.lang.Class c) |
void |
setASTNodeClass(java.lang.String t) |
void |
setASTNodeType(java.lang.String t)
Deprecated.
since 2.7.1
|
void |
setTokenTypeASTNodeType(int tokenType,
java.lang.String className)
Specify an "override" for the Java AST object created for a
specific token.
|
void |
setTokenTypeToASTClassMap(java.util.Hashtable tokenTypeToClassMap) |
protected java.lang.String theASTNodeType
protected java.lang.Class theASTNodeTypeClass
protected java.util.Hashtable tokenTypeToASTClassMap
public ASTFactory()
public ASTFactory(java.util.Hashtable tokenTypeToClassMap)
public void setTokenTypeASTNodeType(int tokenType, java.lang.String className) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public java.lang.Class getASTNodeType(int tokenType)
public AST create()
public AST create(int type)
public AST create(int type, java.lang.String txt)
public AST create(int type, java.lang.String txt, java.lang.String className)
public AST create(AST tr)
public AST create(Token tok, java.lang.String className)
public AST create(java.lang.String className)
protected AST create(java.lang.Class c)
public AST dup(AST t)
public AST dupTree(AST t)
public AST make(AST[] nodes)
public AST make(ASTArray nodes)
public void makeASTRoot(ASTPair currentAST, AST root)
public void setASTNodeClass(java.lang.Class c)
public void setASTNodeClass(java.lang.String t)
public void setASTNodeType(java.lang.String t)
public java.util.Hashtable getTokenTypeToASTClassMap()
public void setTokenTypeToASTClassMap(java.util.Hashtable tokenTypeToClassMap)
public void error(java.lang.String e)