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


001:        package java_cup.runtime;
002:
003:        /**
004:         * Default Implementation for SymbolFactory, creates
005:         * plain old Symbols
006:         *
007:         * @version last updated 27-03-2006
008:         * @author Michael Petter
009:         */
010:
011:        /* *************************************************
012:         class DefaultSymbolFactory
013:
014:         interface for creating new symbols  
015:         ***************************************************/
016:        public class ComplexSymbolFactory implements  SymbolFactory {
017:            public static class Location {
018:                private String unit = "unknown";
019:                private int line, column;
020:
021:                public Location(String unit, int line, int column) {
022:                    this .unit = unit;
023:                    this .line = line;
024:                    this .column = column;
025:                }
026:
027:                public Location(int line, int column) {
028:                    this .line = line;
029:                    this .column = column;
030:                }
031:
032:                public String toString() {
033:                    return unit + ":" + line + "/" + column;
034:                }
035:
036:                public int getColumn() {
037:                    return column;
038:                }
039:
040:                public int getLine() {
041:                    return line;
042:                }
043:
044:                public String getUnit() {
045:                    return unit;
046:                }
047:            }
048:
049:            /**
050:             * ComplexSymbol with detailed Location Informations and a Name
051:             */
052:            public static class ComplexSymbol extends Symbol {
053:                protected String name;
054:                protected Location xleft, xright;
055:
056:                public ComplexSymbol(String name, int id) {
057:                    super (id);
058:                    this .name = name;
059:                }
060:
061:                public ComplexSymbol(String name, int id, Object value) {
062:                    super (id, value);
063:                    this .name = name;
064:                }
065:
066:                public String toString() {
067:                    if (xleft == null || xright == null)
068:                        return "Symbol: " + name;
069:                    return "Symbol: " + name + " (" + xleft + " - " + xright
070:                            + ")";
071:                }
072:
073:                public ComplexSymbol(String name, int id, int state) {
074:                    super (id, state);
075:                    this .name = name;
076:                }
077:
078:                public ComplexSymbol(String name, int id, Symbol left,
079:                        Symbol right) {
080:                    super (id, left, right);
081:                    this .name = name;
082:                    if (left != null)
083:                        this .xleft = ((ComplexSymbol) left).xleft;
084:                    if (right != null)
085:                        this .xright = ((ComplexSymbol) right).xright;
086:                }
087:
088:                public ComplexSymbol(String name, int id, Location left,
089:                        Location right) {
090:                    super (id);
091:                    this .name = name;
092:                    this .xleft = left;
093:                    this .xright = right;
094:                }
095:
096:                public ComplexSymbol(String name, int id, Symbol left,
097:                        Symbol right, Object value) {
098:                    super (id, value);
099:                    this .name = name;
100:                    if (left != null)
101:                        this .xleft = ((ComplexSymbol) left).xleft;
102:                    if (right != null)
103:                        this .xright = ((ComplexSymbol) right).xright;
104:                }
105:
106:                public ComplexSymbol(String name, int id, Location left,
107:                        Location right, Object value) {
108:                    super (id, value);
109:                    this .name = name;
110:                    this .xleft = left;
111:                    this .xright = right;
112:                }
113:
114:                public Location getLeft() {
115:                    return xleft;
116:                }
117:
118:                public Location getRight() {
119:                    return xright;
120:                }
121:            }
122:
123:            // Factory methods
124:            public Symbol newSymbol(String name, int id, Location left,
125:                    Location right, Object value) {
126:                return new ComplexSymbol(name, id, left, right, value);
127:            }
128:
129:            public Symbol newSymbol(String name, int id, Location left,
130:                    Location right) {
131:                return new ComplexSymbol(name, id, left, right);
132:            }
133:
134:            public Symbol newSymbol(String name, int id, Symbol left,
135:                    Symbol right, Object value) {
136:                return new ComplexSymbol(name, id, left, right, value);
137:            }
138:
139:            public Symbol newSymbol(String name, int id, Symbol left,
140:                    Symbol right) {
141:                return new ComplexSymbol(name, id, left, right);
142:            }
143:
144:            public Symbol newSymbol(String name, int id) {
145:                return new ComplexSymbol(name, id);
146:            }
147:
148:            public Symbol newSymbol(String name, int id, Object value) {
149:                return new ComplexSymbol(name, id, value);
150:            }
151:
152:            public Symbol startSymbol(String name, int id, int state) {
153:                return new ComplexSymbol(name, id, state);
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.