Java Doc for ASTFactory.java in  » IDE-Netbeans » cnd » antlr » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » cnd » antlr 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   antlr.ASTFactory

ASTFactory
public class ASTFactory (Code)
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  StringtheASTNodeType
     Name of AST class to create during tree construction. Null implies that the create method should create a default AST type such as CommonAST.
protected  ClasstheASTNodeTypeClass
    
protected  HashtabletokenTypeToASTClassMap
     How to specify the classname to create for a particular token type.

Constructor Summary
public  ASTFactory()
    
public  ASTFactory(Hashtable tokenTypeToClassMap)
     Create factory with a specific mapping from token type to Java AST node type.

Method Summary
public  voidaddASTChild(ASTPair currentAST, AST child)
    
public  ASTcreate()
     Create a new empty AST node; if the user did not specify an AST node type, then create a default one: CommonAST.
public  ASTcreate(int type)
    
public  ASTcreate(int type, String txt)
    
public  ASTcreate(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.
public  ASTcreate(int type, String txt, AST t)
    
public  ASTcreate(AST tr)
     Create a new empty AST node; if the user did not specify an AST node type, then create a default one: CommonAST.
public  ASTcreate(Token tok)
    
public  ASTcreate(Token tok, String className)
     ANTLR generates reference to this when you reference a token that has a specified heterogeneous AST node type.
public  ASTcreate(String className)
    
protected  ASTcreate(Class c)
    
public  ASTcreateDefault()
    
protected  ASTcreateUsingCtor(Token token, String className)
    
public  ASTdup(AST t)
     Copy a single node with same Java AST objec type. Ignore the tokenType->Class mapping since you know the type of the node, t.getClass(), and doing a dup. clone() is not used because we want all AST creation to go thru the factory so creation can be tracked.
public  ASTdupList(AST t)
     Duplicate tree including siblings of root.
public  ASTdupTree(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.
public  voiderror(String e)
     To change where error messages go, can subclass/override this method and then setASTFactory in Parser and TreeParser.
public  ClassgetASTNodeType(int tokenType)
    
public  HashtablegetTokenTypeToASTClassMap()
    
public  ASTmake(AST[] nodes)
     Make a tree from a list of nodes.
public  ASTmake(ASTArray nodes)
    
public  voidmakeASTRoot(ASTPair currentAST, AST root)
    
public  voidsetASTNodeClass(Class c)
    
public  voidsetASTNodeClass(String t)
    
public  voidsetASTNodeType(String t)
     Specify the type of node to create during tree building.
public  voidsetTokenTypeASTNodeType(int tokenType, String className)
     Specify an "override" for the Java AST object created for a specific token.
public  voidsetTokenTypeToASTClassMap(Hashtable tokenTypeToClassMap)
    

Field Detail
theASTNodeType
protected String theASTNodeType(Code)
Name of AST class to create during tree construction. Null implies that the create method should create a default AST type such as CommonAST. This is for homogeneous nodes.



theASTNodeTypeClass
protected Class theASTNodeTypeClass(Code)



tokenTypeToASTClassMap
protected Hashtable tokenTypeToASTClassMap(Code)
How to specify the classname to create for a particular token type. Note that ANTLR allows you to say, for example, tokens { PLUS; ... } and it tracks everything statically. #[PLUS] will make you a PLUSNode w/o use of this table. For tokens that ANTLR cannot track statically like #[i], you can use this table to map PLUS (Integer) -> PLUSNode (Class) etc... ANTLR sets the class map from the tokens {...} section via the ASTFactory(Hashtable) ctor in antlr.Parser.




Constructor Detail
ASTFactory
public ASTFactory()(Code)



ASTFactory
public ASTFactory(Hashtable tokenTypeToClassMap)(Code)
Create factory with a specific mapping from token type to Java AST node type. Your subclasses of ASTFactory can override and reuse the map stuff.




Method Detail
addASTChild
public void addASTChild(ASTPair currentAST, AST child)(Code)
Add a child to the current AST



create
public AST create()(Code)
Create a new empty AST node; if the user did not specify an AST node type, then create a default one: CommonAST.



create
public AST create(int type)(Code)



create
public AST create(int type, String txt)(Code)



create
public AST create(int type, String txt, String className)(Code)
Create an AST node with the token type and text passed in, but with a specific Java object type. Typically called when you say @[PLUS,"+",PLUSNode] in an antlr action.
since:
   2.7.2



create
public AST create(int type, String txt, AST t)(Code)



create
public AST create(AST tr)(Code)
Create a new empty AST node; if the user did not specify an AST node type, then create a default one: CommonAST.



create
public AST create(Token tok)(Code)



create
public AST create(Token tok, String className)(Code)
ANTLR generates reference to this when you reference a token that has a specified heterogeneous AST node type. This is also a special case node creation routine for backward compatibility. Before, ANTLR generated "new T(tokenObject)" and so I must call the appropriate constructor not T().
since:
   2.7.2



create
public AST create(String className)(Code)

since:
   2.7.2



create
protected AST create(Class c)(Code)

since:
   2.7.2



createDefault
public AST createDefault()(Code)



createUsingCtor
protected AST createUsingCtor(Token token, String className)(Code)

since:
   2.7.2



dup
public AST dup(AST t)(Code)
Copy a single node with same Java AST objec type. Ignore the tokenType->Class mapping since you know the type of the node, t.getClass(), and doing a dup. clone() is not used because we want all AST creation to go thru the factory so creation can be tracked. Returns null if t is null.



dupList
public AST dupList(AST t)(Code)
Duplicate tree including siblings of root.



dupTree
public AST dupTree(AST t)(Code)
Duplicate a tree, assuming this is a root node of a tree-- duplicate that node and what's below; ignore siblings of root node.



error
public void error(String e)(Code)
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.



getASTNodeType
public Class getASTNodeType(int tokenType)(Code)
For a given token type, what is the AST node object type to create for it?
since:
   2.7.2



getTokenTypeToASTClassMap
public Hashtable getTokenTypeToASTClassMap()(Code)



make
public AST make(AST[] nodes)(Code)
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).



make
public AST make(ASTArray nodes)(Code)
Make a tree from a list of nodes, where the nodes are contained in an ASTArray object



makeASTRoot
public void makeASTRoot(ASTPair currentAST, AST root)(Code)
Make an AST the root of current AST



setASTNodeClass
public void setASTNodeClass(Class c)(Code)



setASTNodeClass
public void setASTNodeClass(String t)(Code)



setASTNodeType
public void setASTNodeType(String t)(Code)
Specify the type of node to create during tree building.



setTokenTypeASTNodeType
public void setTokenTypeASTNodeType(int tokenType, String className) throws IllegalArgumentException(Code)
Specify an "override" for the Java AST object created for a specific token. It is provided as a convenience so you can specify node types dynamically. ANTLR sets the token type mapping automatically from the tokens{...} section, but you can change that mapping with this method. ANTLR does it's best to statically determine the node type for generating parsers, but it cannot deal with dynamic values like #[LT(1)]. In this case, it relies on the mapping. Beware differences in the tokens{...} section and what you set via this method. Make sure they are the same. Set className to null to remove the mapping.
since:
   2.7.2



setTokenTypeToASTClassMap
public void setTokenTypeToASTClassMap(Hashtable tokenTypeToClassMap)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.