|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--antlr.ASTFactory
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...
Field Summary | |
protected String |
theASTNodeType
Name of AST class to create during tree construction. |
protected Class |
theASTNodeTypeClass
|
protected Hashtable |
tokenTypeToASTClassMap
How to specify the classname to create for a particular token type. |
Constructor Summary | |
ASTFactory()
|
|
ASTFactory(Hashtable tokenTypeToClassMap)
Create factory with a specific mapping from token type to Java AST node type. |
Method Summary | |
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(Class c)
|
AST |
create(int type)
|
AST |
create(int type,
String txt)
|
AST |
create(int type,
String txt,
String className)
Create an AST node with the token type and text passed in, but with a specific Java object type. |
protected AST |
create(String className)
|
AST |
create(Token tok)
|
AST |
create(Token tok,
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,
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(String e)
To change where error messages go, can subclass/override this method and then setASTFactory in Parser and TreeParser. |
Class |
getASTNodeType(int tokenType)
For a given token type, what is the AST node object type to create for it? |
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(String t)
|
void |
setASTNodeType(String t)
Deprecated. since 2.7.1 |
void |
setTokenTypeASTNodeType(int tokenType,
String className)
Specify an "override" for the Java AST object created for a specific token. |
void |
setTokenTypeToASTClassMap(Hashtable tokenTypeToClassMap)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected String theASTNodeType
protected Class theASTNodeTypeClass
protected Hashtable tokenTypeToASTClassMap
Constructor Detail |
public ASTFactory()
public ASTFactory(Hashtable tokenTypeToClassMap)
Method Detail |
public void setTokenTypeASTNodeType(int tokenType, String className) throws IllegalArgumentException
IllegalArgumentException
public Class getASTNodeType(int tokenType)
public void addASTChild(ASTPair currentAST, AST child)
public AST create()
public AST create(int type)
public AST create(int type, String txt)
public AST create(int type, String txt, String className)
public AST create(AST tr)
public AST create(Token tok)
public AST create(Token tok, String className)
protected AST create(String className)
protected AST createUsingCtor(Token token, String className)
protected AST create(Class c)
public AST dup(AST t)
public AST dupList(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(String t)
public void setASTNodeType(String t)
public Hashtable getTokenTypeToASTClassMap()
public void setTokenTypeToASTClassMap(Hashtable tokenTypeToClassMap)
public void error(String e)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |