Source Code Cross Referenced for terminal.java in  » Parser » CUP-develop » java_cup » 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 » CUP develop » java_cup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package java_cup;
002:
003:        import java_cup.assoc;
004:        import java.util.Hashtable;
005:        import java.util.Enumeration;
006:
007:        /** This class represents a terminal symbol in the grammar.  Each terminal 
008:         *  has a textual name, an index, and a string which indicates the type of 
009:         *  object it will be implemented with at runtime (i.e. the class of object 
010:         *  that will be returned by the scanner and pushed on the parse stack to 
011:         *  represent it). 
012:         *
013:         * @version last updated: 7/3/96
014:         * @author  Frank Flannery
015:         */
016:        public class terminal extends symbol {
017:
018:            /*-----------------------------------------------------------*/
019:            /*--- Constructor(s) ----------------------------------------*/
020:            /*-----------------------------------------------------------*/
021:
022:            /** Full constructor.
023:             * @param nm the name of the terminal.
024:             * @param tp the type of the terminal.
025:             */
026:            public terminal(String nm, String tp, int precedence_side,
027:                    int precedence_num) {
028:                /* superclass does most of the work */
029:                super (nm, tp);
030:
031:                /* add to set of all terminals and check for duplicates */
032:                Object conflict = _all.put(nm, this );
033:                if (conflict != null)
034:                    // can't throw an execption here because this is used in static 
035:                    // initializers, so we do a crash instead
036:                    // was:
037:                    // throw new internal_error("Duplicate terminal (" + nm + ") created");
038:                    (new internal_error("Duplicate terminal (" + nm
039:                            + ") created")).crash();
040:
041:                /* assign a unique index */
042:                _index = next_index++;
043:
044:                /* set the precedence */
045:                _precedence_num = precedence_num;
046:                _precedence_side = precedence_side;
047:
048:                /* add to by_index set */
049:                _all_by_index.put(new Integer(_index), this );
050:            }
051:
052:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
053:
054:            /** Constructor for non-precedented terminal
055:             */
056:
057:            public terminal(String nm, String tp) {
058:                this (nm, tp, assoc.no_prec, -1);
059:            }
060:
061:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
062:
063:            /** Constructor with default type. 
064:             * @param nm the name of the terminal.
065:             */
066:            public terminal(String nm) {
067:                this (nm, null);
068:            }
069:
070:            /*-----------------------------------------------------------*/
071:            /*-------------------  Class Variables  ---------------------*/
072:            /*-----------------------------------------------------------*/
073:
074:            private int _precedence_num;
075:            private int _precedence_side;
076:
077:            /*-----------------------------------------------------------*/
078:            /*--- (Access to) Static (Class) Variables ------------------*/
079:            /*-----------------------------------------------------------*/
080:
081:            /** Table of all terminals.  Elements are stored using name strings as 
082:             *  the key 
083:             */
084:            protected static Hashtable _all = new Hashtable();
085:
086:            //Hm Added clear  to clear all static fields
087:            public static void clear() {
088:                _all.clear();
089:                _all_by_index.clear();
090:                next_index = 0;
091:                EOF = new terminal("EOF");
092:                error = new terminal("error");
093:            }
094:
095:            /** Access to all terminals. */
096:            public static Enumeration all() {
097:                return _all.elements();
098:            }
099:
100:            /** Lookup a terminal by name string. */
101:            public static terminal find(String with_name) {
102:                if (with_name == null)
103:                    return null;
104:                else
105:                    return (terminal) _all.get(with_name);
106:            }
107:
108:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
109:
110:            /** Table of all terminals indexed by their index number. */
111:            protected static Hashtable _all_by_index = new Hashtable();
112:
113:            /** Lookup a terminal by index. */
114:            public static terminal find(int indx) {
115:                Integer the_indx = new Integer(indx);
116:
117:                return (terminal) _all_by_index.get(the_indx);
118:            }
119:
120:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
121:
122:            /** Total number of terminals. */
123:            public static int number() {
124:                return _all.size();
125:            }
126:
127:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
128:
129:            /** Static counter to assign unique index. */
130:            protected static int next_index = 0;
131:
132:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
133:
134:            /** Special terminal for end of input. */
135:            public static terminal EOF = new terminal("EOF");
136:
137:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
138:
139:            /** special terminal used for error recovery */
140:            public static terminal error = new terminal("error");
141:
142:            /*-----------------------------------------------------------*/
143:            /*--- General Methods ---------------------------------------*/
144:            /*-----------------------------------------------------------*/
145:
146:            /** Report this symbol as not being a non-terminal. */
147:            public boolean is_non_term() {
148:                return false;
149:            }
150:
151:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
152:
153:            /** Convert to a string. */
154:            public String toString() {
155:                return super .toString() + "[" + index() + "]";
156:            }
157:
158:            /*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/
159:
160:            /** get the precedence of a terminal */
161:            public int precedence_num() {
162:                return _precedence_num;
163:            }
164:
165:            public int precedence_side() {
166:                return _precedence_side;
167:            }
168:
169:            /** set the precedence of a terminal */
170:            public void set_precedence(int p, int new_prec) {
171:                _precedence_side = p;
172:                _precedence_num = new_prec;
173:            }
174:
175:            /*-----------------------------------------------------------*/
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.