Java Doc for SymbolTable.java in  » Parser » Rats-Parser-Generators » xtc » util » 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 » Parser » Rats Parser Generators » xtc.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   xtc.util.SymbolTable

SymbolTable
public class SymbolTable (Code)
A symbol table. This class implements a symbol table, which maps symbols represented as strings to values of any type. The mapping is organized into hierarchical Scope scopes , which allows for multiple definitions of the same symbol across different scopes. Additionally, a symbol may have multiple definitions within the same scope: if the corresponding value is a Java collections framework list, it is recognized as a multiply defined symbol. Scopes are named, with names being represented as strings. Both scope names and symbols can be unqualified — that is, they need to be resolved relative to the SymbolTable.current() currentscope — or qualified by the Constants.QUALIFIERqualification character '.' — that is, they are resolved relative to the symbol table's SymbolTable.root() root . Once SymbolTable.enter(String) created , a scope remains in the symbol table and the corresponding AST node should be associated with that scope by setting the corresponding Constants.SCOPE property to the scope's qualified name. Subsequent traversals over that node can then automatically SymbolTable.enter(Node) enter and SymbolTable.exit(Node) exit that scope. Alternatively, if traversing out of tree order, the current scope can be set SymbolTable.setScope(SymbolTable.Scope) explicitly .

To support different name spaces within the same scope, this class can optionally SymbolTable.toNameSpace mangle and SymbolTable.fromNameSpace unmangle unqualified symbols. By convention, a name in any name space besides the default name space is prefixed by the name of the name space and an opening parenthesis '(' and suffixed by a closing parenthesis ')'.
author:
   Robert Grimm
version:
   $Revision: 1.34 $


Inner Class :public static class Scope

Field Summary
protected  Scopecurrent
     The current scope.
protected  intfreshIdCount
     The fresh identifier count.
protected  intfreshNameCount
     The fresh name count.
protected  Scoperoot
     The root scope.

Constructor Summary
public  SymbolTable()
     Create a new symbol table with the empty string as the root scope's name.
public  SymbolTable(String root)
     Create a new symbol table.

Method Summary
public  Scopecurrent()
     Get the current scope.
public  voiddelete(String name)
     Delete the scope with the specified unqualified name.
public  voidenter(String name)
     Enter the scope with the specified unqualified name.
public  voidenter(Node n)
     Enter the specified node.
public  voidexit()
     Exit the current scope.
public  voidexit(Node n)
     Exit the specified node.
public  StringfreshCId()
     Create a fresh C identifier.
public  StringfreshCId(String base)
     Create a fresh C identifier incorporating the specified base name.
public  StringfreshJavaId()
     Create a fresh Java identifier.
public  StringfreshJavaId(String base)
     Create a fresh Java identifier incorporating the specified base name.
public  StringfreshName()
     Create a fresh name.
public  StringfreshName(String base)
     Create a fresh name incorporating the specified base name.
public static  StringfromNameSpace(String symbol)
     Convert the specified unqualified symbol within a name space to a symbol without a name space.
Parameters:
  symbol - The mangled symbol within a name space.
public  ScopegetScope(String name)
     Get the scope with the specified qualified name.
Parameters:
  name - The qualified name.
public static  booleanhasScope(Node n)
     Determine whether the specified node has an associated Constants.SCOPE scope .
Parameters:
  n - The node.
public  booleanisDefined(String symbol)
     Determine whether the specified symbol is defined.
public  booleanisDefinedMultiply(String symbol)
     Determine whether the specified symbol is define multiple times. If the symbol is qualified, this method checks whether the symbol has multiple definitions in the named scope.
public static  booleanisFunctionScopeName(String name)
     Determine whether the specified scope name represents a function's scope.
Parameters:
  name - The name.
public static  booleanisInNameSpace(String symbol, String space)
     Determine whether the specified symbol is in the specified name space.
Parameters:
  symbol - The symbol.
Parameters:
  space - The name space.
public static  booleanisMacroScopeName(String name)
     Determine whether the specified scope name represents a macro's scope.
Parameters:
  name - The name.
public  Objectlookup(String symbol)
     Get the value for the specified symbol.
public  ScopelookupScope(String symbol)
     Get the scope for the specified symbol.
public  voidmark(Node n)
     Mark the specified node.
public  voidreset()
     Clear this symbol table.
public  Scoperoot()
     Get the root scope.
public  voidsetScope(Scope scope)
     Set the current scope to the specified scope.
public static  StringtoFunctionScopeName(String id)
     Convert the specified C function identifier into a symbol table scope name.
Parameters:
  id - The function identifier.
public static  StringtoLabelName(String id)
     Convert the specified label identifier into a symbol table name.
Parameters:
  id - The identifier.
public static  StringtoMacroScopeName(String id)
     Conver the specified C macro identifier into a symbol table scope name.
Parameters:
  id - The macro identifier.
public static  StringtoMethodName(String id)
     Convert the specified method identifier into a symbol table name.
Parameters:
  id - The method identifier.
public static  StringtoNameSpace(String symbol, String space)
     Convert the specified unqualified symbol to a symbol in the specified name space.
Parameters:
  symbol - The symbol
Parameters:
  space - The name space.
public static  StringtoTagName(String tag)
     Convert the specified C struct, union, or enum tag into a symbol table name.
Parameters:
  tag - The tag.

Field Detail
current
protected Scope current(Code)
The current scope.



freshIdCount
protected int freshIdCount(Code)
The fresh identifier count.



freshNameCount
protected int freshNameCount(Code)
The fresh name count.



root
protected Scope root(Code)
The root scope.




Constructor Detail
SymbolTable
public SymbolTable()(Code)
Create a new symbol table with the empty string as the root scope's name.



SymbolTable
public SymbolTable(String root)(Code)
Create a new symbol table.
Parameters:
  root - The name of the root scope.




Method Detail
current
public Scope current()(Code)
Get the current scope. The current scope.



delete
public void delete(String name)(Code)
Delete the scope with the specified unqualified name. If the current scope contains a nested scope with the specified name, this method deletes that scope and all its contents, including nested scopes.
Parameters:
  name - The unqualified name.



enter
public void enter(String name)(Code)
Enter the scope with the specified unqualified name. If the current scope does not have a scope with the specified name, a new scope with the specified name is created. In either case, the scope with that name becomes the current scope.
Parameters:
  name - The unqualified name.



enter
public void enter(Node n)(Code)
Enter the specified node. If the node has an associated Constants.SCOPE scope , this method tries to enter the scope. Otherwise, it does not change the scope.
Parameters:
  n - The node.
throws:
  IllegalStateException - Signals that the node's scope isinvalid or not nested within the current scope.



exit
public void exit()(Code)
Exit the current scope.
throws:
  IllegalStateException - Signals that the current scope is the root scope.



exit
public void exit(Node n)(Code)
Exit the specified node. If the node has an associated Constants.SCOPE scope , the current scope is exited.
Parameters:
  n - The node.



freshCId
public String freshCId()(Code)
Create a fresh C identifier. The returned identifier has "tmp" as its base name.
See Also:   SymbolTable.freshCId(String) A fresh C identifier.



freshCId
public String freshCId(String base)(Code)
Create a fresh C identifier incorporating the specified base name. The returned name is of the form __name_count.
Parameters:
  base - The base name. The corresponding fresh C identifier.



freshJavaId
public String freshJavaId()(Code)
Create a fresh Java identifier. The returned identifier has "tmp" as its base name.
See Also:   SymbolTable.freshJavaId(String) A fresh Java identifier.



freshJavaId
public String freshJavaId(String base)(Code)
Create a fresh Java identifier incorporating the specified base name. The returned name is of the form name$count.
Parameters:
  base - The base name. The corresponding fresh Java identifier.



freshName
public String freshName()(Code)
Create a fresh name. The returned name has "anonymous" as it base name.
See Also:   SymbolTable.freshName(String) A fresh name.



freshName
public String freshName(String base)(Code)
Create a fresh name incorporating the specified base name. The returned name is of the form name(count).
Parameters:
  base - The base name. The corresponding fresh name.



fromNameSpace
public static String fromNameSpace(String symbol)(Code)
Convert the specified unqualified symbol within a name space to a symbol without a name space.
Parameters:
  symbol - The mangled symbol within a name space. The corresponding symbol without a name space.



getScope
public Scope getScope(String name)(Code)
Get the scope with the specified qualified name.
Parameters:
  name - The qualified name. The corresponding scope or null if no suchscope exits.



hasScope
public static boolean hasScope(Node n)(Code)
Determine whether the specified node has an associated Constants.SCOPE scope .
Parameters:
  n - The node. true if the node has an associated scope.



isDefined
public boolean isDefined(String symbol)(Code)
Determine whether the specified symbol is defined. If the symbol is qualified, this method checks whether the symbol is defined in the named scope. Otherwise, it checks whether the symbol is defined in the current scope or one of its ancestors.
Parameters:
  symbol - The symbol. true if the specified symbol is defined.



isDefinedMultiply
public boolean isDefinedMultiply(String symbol)(Code)
Determine whether the specified symbol is define multiple times. If the symbol is qualified, this method checks whether the symbol has multiple definitions in the named scope. Otherwise, it checks whether the symbol has multiple definitions in the current scope or one of its ancestors.
Parameters:
  symbol - The symbol. true if the specified symbol is multiplydefined.



isFunctionScopeName
public static boolean isFunctionScopeName(String name)(Code)
Determine whether the specified scope name represents a function's scope.
Parameters:
  name - The name. true if the name denotes a function scope.



isInNameSpace
public static boolean isInNameSpace(String symbol, String space)(Code)
Determine whether the specified symbol is in the specified name space.
Parameters:
  symbol - The symbol.
Parameters:
  space - The name space. true if the symbol is mangled symbol in thename space.



isMacroScopeName
public static boolean isMacroScopeName(String name)(Code)
Determine whether the specified scope name represents a macro's scope.
Parameters:
  name - The name. true if the name denotes a macro scope.



lookup
public Object lookup(String symbol)(Code)
Get the value for the specified symbol. If the symbol is qualified, this method returns the definition within the named scope. Otherwise, it searches the current scope and all its ancestors, returning the value of the first definition.
Parameters:
  symbol - The symbol. The corresponding value or null if no suchdefinition exists.



lookupScope
public Scope lookupScope(String symbol)(Code)
Get the scope for the specified symbol. If the symbol is qualified, this method returns the named scope (without checking whether the symbol is defined in that scope). Otherwise, it searches the current scope and all its ancestors, returning the first defining scope.
Parameters:
  symbol - The symbol. The corresponding scope or null if no suchscope exits.



mark
public void mark(Node n)(Code)
Mark the specified node. If the node does not have an associated Constants.SCOPE scope , this method set the property with the current scope's qualified name.
Parameters:
  n - The node.



reset
public void reset()(Code)
Clear this symbol table. This method deletes all scopes and their definitions from this symbol table.



root
public Scope root()(Code)
Get the root scope. The root scope.



setScope
public void setScope(Scope scope)(Code)
Set the current scope to the specified scope.
Parameters:
  scope - The new current scope.
throws:
  IllegalArgumentException - Signals that this symbol table'sroot is not the specified scope's root.



toFunctionScopeName
public static String toFunctionScopeName(String id)(Code)
Convert the specified C function identifier into a symbol table scope name.
Parameters:
  id - The function identifier. The corresponding symbol table scope name.



toLabelName
public static String toLabelName(String id)(Code)
Convert the specified label identifier into a symbol table name.
Parameters:
  id - The identifier. The corresponding symbol table name.



toMacroScopeName
public static String toMacroScopeName(String id)(Code)
Conver the specified C macro identifier into a symbol table scope name.
Parameters:
  id - The macro identifier. The corresponding symbol table scope name.



toMethodName
public static String toMethodName(String id)(Code)
Convert the specified method identifier into a symbol table name.
Parameters:
  id - The method identifier. The corresponding symbol table name.



toNameSpace
public static String toNameSpace(String symbol, String space)(Code)
Convert the specified unqualified symbol to a symbol in the specified name space.
Parameters:
  symbol - The symbol
Parameters:
  space - The name space. The mangled symbol.



toTagName
public static String toTagName(String tag)(Code)
Convert the specified C struct, union, or enum tag into a symbol table name.
Parameters:
  tag - The tag. The corresponding symbol table name.



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.