Source Code Cross Referenced for GrammarScanner.java in  » Parser » beaver » beaver » spec » parser » 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 » beaver » beaver.spec.parser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* The following code was generated by JFlex 1.4.1 on 11/6/05 1:57 AM */
002:
003:        /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
004:         * This file is part of Beaver Parser Generator.                       *
005:         * Copyright (C) 2003,2005 Alexander Demenchuk <alder@softanvil.com>.  *
006:         * All rights reserved.                                                *
007:         * See the file "LICENSE" for the terms and conditions for copying,    *
008:         * distribution and modification of Beaver.                            *
009:         * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
010:
011:        package beaver.spec.parser;
012:
013:        import beaver.Symbol;
014:        import beaver.Scanner;
015:        import beaver.spec.parser.GrammarParser.Terminals;
016:
017:        /**
018:         * This class is a scanner generated by 
019:         * <a href="http://www.jflex.de/">JFlex</a> 1.4.1
020:         * on 11/6/05 1:57 AM from the specification file
021:         * <tt>C:/Documents and Settings/ademenchuk/workspace/Beaver 0.9/etc/GrammarScanner.flex</tt>
022:         */
023:        public class GrammarScanner extends Scanner {
024:
025:            /** This character denotes the end of file */
026:            public static final int YYEOF = -1;
027:
028:            /** initial size of the lookahead buffer */
029:            private static final int ZZ_BUFFERSIZE = 16384;
030:
031:            /** lexical states */
032:            public static final int CODE = 1;
033:            public static final int EOL_COMMENT = 4;
034:            public static final int EOF_MLN_COMMENT = 7;
035:            public static final int EOF_CODE = 6;
036:            public static final int CODE_END = 5;
037:            public static final int MLN_COMMENT = 3;
038:            public static final int YYINITIAL = 0;
039:            public static final int EOF_EOL_COMMENT = 8;
040:            public static final int TEXT = 2;
041:
042:            /** 
043:             * Translates characters to character classes
044:             */
045:            private static final String ZZ_CMAP_PACKED = "\11\0\1\3\1\2\1\0\1\3\1\1\22\0\1\3\1\0\1\6"
046:                    + "\2\0\1\7\4\0\1\43\1\42\1\33\1\0\1\37\1\46\12\5"
047:                    + "\1\45\1\35\1\0\1\34\1\0\1\41\1\36\32\4\4\0\1\5"
048:                    + "\1\0\1\12\1\27\1\16\1\13\1\11\1\32\1\20\1\10\1\21"
049:                    + "\1\4\1\17\1\25\1\22\1\30\1\23\1\15\1\4\1\14\1\26"
050:                    + "\1\24\4\4\1\31\1\4\1\44\1\40\1\47\54\0\1\4\12\0"
051:                    + "\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0\u013f\4\31\0"
052:                    + "\162\4\4\0\14\4\16\0\5\4\11\0\1\4\213\0\1\4\13\0"
053:                    + "\1\4\1\0\3\4\1\0\1\4\1\0\24\4\1\0\54\4\1\0"
054:                    + "\46\4\1\0\5\4\4\0\202\4\10\0\105\4\1\0\46\4\2\0"
055:                    + "\2\4\6\0\20\4\41\0\46\4\2\0\1\4\7\0\47\4\110\0"
056:                    + "\33\4\5\0\3\4\56\0\32\4\5\0\13\4\25\0\12\5\4\0"
057:                    + "\2\4\1\0\143\4\1\0\1\4\17\0\2\4\7\0\2\4\12\5"
058:                    + "\3\4\2\0\1\4\20\0\1\4\1\0\36\4\35\0\3\4\60\0"
059:                    + "\46\4\13\0\1\4\u0152\0\66\4\3\0\1\4\22\0\1\4\7\0"
060:                    + "\12\4\4\0\12\5\25\0\10\4\2\0\2\4\2\0\26\4\1\0"
061:                    + "\7\4\1\0\1\4\3\0\4\4\3\0\1\4\36\0\2\4\1\0"
062:                    + "\3\4\4\0\12\5\2\4\23\0\6\4\4\0\2\4\2\0\26\4"
063:                    + "\1\0\7\4\1\0\2\4\1\0\2\4\1\0\2\4\37\0\4\4"
064:                    + "\1\0\1\4\7\0\12\5\2\0\3\4\20\0\11\4\1\0\3\4"
065:                    + "\1\0\26\4\1\0\7\4\1\0\2\4\1\0\5\4\3\0\1\4"
066:                    + "\22\0\1\4\17\0\2\4\4\0\12\5\25\0\10\4\2\0\2\4"
067:                    + "\2\0\26\4\1\0\7\4\1\0\2\4\1\0\5\4\3\0\1\4"
068:                    + "\36\0\2\4\1\0\3\4\4\0\12\5\1\0\1\4\21\0\1\4"
069:                    + "\1\0\6\4\3\0\3\4\1\0\4\4\3\0\2\4\1\0\1\4"
070:                    + "\1\0\2\4\3\0\2\4\3\0\3\4\3\0\10\4\1\0\3\4"
071:                    + "\55\0\11\5\25\0\10\4\1\0\3\4\1\0\27\4\1\0\12\4"
072:                    + "\1\0\5\4\46\0\2\4\4\0\12\5\25\0\10\4\1\0\3\4"
073:                    + "\1\0\27\4\1\0\12\4\1\0\5\4\3\0\1\4\40\0\1\4"
074:                    + "\1\0\2\4\4\0\12\5\25\0\10\4\1\0\3\4\1\0\27\4"
075:                    + "\1\0\20\4\46\0\2\4\4\0\12\5\25\0\22\4\3\0\30\4"
076:                    + "\1\0\11\4\1\0\1\4\2\0\7\4\72\0\60\4\1\0\2\4"
077:                    + "\14\0\7\4\11\0\12\5\47\0\2\4\1\0\1\4\2\0\2\4"
078:                    + "\1\0\1\4\2\0\1\4\6\0\4\4\1\0\7\4\1\0\3\4"
079:                    + "\1\0\1\4\1\0\1\4\2\0\2\4\1\0\4\4\1\0\2\4"
080:                    + "\11\0\1\4\2\0\5\4\1\0\1\4\11\0\12\5\2\0\2\4"
081:                    + "\42\0\1\4\37\0\12\5\26\0\10\4\1\0\42\4\35\0\4\4"
082:                    + "\164\0\42\4\1\0\5\4\1\0\2\4\25\0\12\5\6\0\6\4"
083:                    + "\112\0\46\4\12\0\51\4\7\0\132\4\5\0\104\4\5\0\122\4"
084:                    + "\6\0\7\4\1\0\77\4\1\0\1\4\1\0\4\4\2\0\7\4"
085:                    + "\1\0\1\4\1\0\4\4\2\0\47\4\1\0\1\4\1\0\4\4"
086:                    + "\2\0\37\4\1\0\1\4\1\0\4\4\2\0\7\4\1\0\1\4"
087:                    + "\1\0\4\4\2\0\7\4\1\0\7\4\1\0\27\4\1\0\37\4"
088:                    + "\1\0\1\4\1\0\4\4\2\0\7\4\1\0\47\4\1\0\23\4"
089:                    + "\16\0\11\5\56\0\125\4\14\0\u026c\4\2\0\10\4\12\0\32\4"
090:                    + "\5\0\113\4\25\0\15\4\1\0\4\4\16\0\22\4\16\0\22\4"
091:                    + "\16\0\15\4\1\0\3\4\17\0\64\4\43\0\1\4\4\0\1\4"
092:                    + "\3\0\12\5\46\0\12\5\6\0\130\4\10\0\51\4\127\0\35\4"
093:                    + "\51\0\12\5\36\4\2\0\5\4\u038b\0\154\4\224\0\234\4\4\0"
094:                    + "\132\4\6\0\26\4\2\0\6\4\2\0\46\4\2\0\6\4\2\0"
095:                    + "\10\4\1\0\1\4\1\0\1\4\1\0\1\4\1\0\37\4\2\0"
096:                    + "\65\4\1\0\7\4\1\0\1\4\3\0\3\4\1\0\7\4\3\0"
097:                    + "\4\4\2\0\6\4\4\0\15\4\5\0\3\4\1\0\7\4\164\0"
098:                    + "\1\4\15\0\1\4\202\0\1\4\4\0\1\4\2\0\12\4\1\0"
099:                    + "\1\4\3\0\5\4\6\0\1\4\1\0\1\4\1\0\1\4\1\0"
100:                    + "\4\4\1\0\3\4\1\0\7\4\3\0\3\4\5\0\5\4\u0ebb\0"
101:                    + "\2\4\52\0\5\4\5\0\2\4\4\0\126\4\6\0\3\4\1\0"
102:                    + "\132\4\1\0\4\4\5\0\50\4\4\0\136\4\21\0\30\4\70\0"
103:                    + "\20\4\u0200\0\u19b6\4\112\0\u51a6\4\132\0\u048d\4\u0773\0\u2ba4\4\u215c\0"
104:                    + "\u012e\4\2\0\73\4\225\0\7\4\14\0\5\4\5\0\1\4\1\0"
105:                    + "\12\4\1\0\15\4\1\0\5\4\1\0\1\4\1\0\2\4\1\0"
106:                    + "\2\4\1\0\154\4\41\0\u016b\4\22\0\100\4\2\0\66\4\50\0"
107:                    + "\14\4\164\0\5\4\1\0\207\4\23\0\12\5\7\0\32\4\6\0"
108:                    + "\32\4\13\0\131\4\3\0\6\4\2\0\6\4\2\0\6\4\2\0"
109:                    + "\3\4\43\0";
110:
111:            /** 
112:             * Translates characters to character classes
113:             */
114:            private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
115:
116:            /** 
117:             * Translates DFA states to action switch labels.
118:             */
119:            private static final int[] ZZ_ACTION = zzUnpackAction();
120:
121:            private static final String ZZ_ACTION_PACKED_0 = "\1\0\1\1\1\2\1\3\1\4\1\1\1\5\1\6"
122:                    + "\1\7\1\10\2\11\1\12\1\13\1\10\1\14\1\15"
123:                    + "\1\16\1\17\1\20\1\21\1\22\1\23\1\24\2\10"
124:                    + "\2\1\1\25\1\2\1\26\2\3\1\4\2\7\2\1"
125:                    + "\12\0\1\27\1\30\1\31\2\0\1\32\3\0\1\33"
126:                    + "\35\0\1\34\1\0\1\35\2\0\1\36\2\0\1\37"
127:                    + "\1\40\1\0\1\41\4\0\1\42\1\0\1\43\1\0"
128:                    + "\1\44\1\0\1\45\3\0\1\46\1\47";
129:
130:            private static int[] zzUnpackAction() {
131:                int[] result = new int[115];
132:                int offset = 0;
133:                offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
134:                return result;
135:            }
136:
137:            private static int zzUnpackAction(String packed, int offset,
138:                    int[] result) {
139:                int i = 0; /* index in packed string  */
140:                int j = offset; /* index in unpacked array */
141:                int l = packed.length();
142:                while (i < l) {
143:                    int count = packed.charAt(i++);
144:                    int value = packed.charAt(i++);
145:                    do
146:                        result[j++] = value;
147:                    while (--count > 0);
148:                }
149:                return j;
150:            }
151:
152:            /** 
153:             * Translates a state to a row index in the transition table
154:             */
155:            private static final int[] ZZ_ROWMAP = zzUnpackRowMap();
156:
157:            private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\50\0\120\0\170\0\240\0\310\0\360\0\u0118"
158:                    + "\0\u0140\0\u0168\0\u0190\0\u0168\0\u01b8\0\u0168\0\u01e0\0\u0168"
159:                    + "\0\u0168\0\u0168\0\u0168\0\u0168\0\u0168\0\u0168\0\u0168\0\u0168"
160:                    + "\0\u0208\0\u0230\0\u0258\0\u0280\0\u02a8\0\u0168\0\u0168\0\u02d0"
161:                    + "\0\u02f8\0\u0320\0\u0348\0\u0168\0\u0168\0\u0370\0\u0398\0\u03c0"
162:                    + "\0\u03e8\0\u0410\0\u0438\0\u0460\0\u0488\0\u04b0\0\u04d8\0\u0500"
163:                    + "\0\u0168\0\u0168\0\u0168\0\u0258\0\u0280\0\u0168\0\u02d0\0\u02f8"
164:                    + "\0\u0320\0\u0168\0\u0528\0\u0550\0\u0578\0\u05a0\0\u05c8\0\u05f0"
165:                    + "\0\u0618\0\u0640\0\u0668\0\u0690\0\u06b8\0\u06e0\0\u0708\0\u0730"
166:                    + "\0\u0758\0\u0780\0\u07a8\0\u07d0\0\u07f8\0\u0820\0\u0848\0\u0870"
167:                    + "\0\u0898\0\u08c0\0\u08e8\0\u0910\0\u0938\0\u0960\0\u0988\0\u0168"
168:                    + "\0\u09b0\0\u0168\0\u09d8\0\u0a00\0\u0168\0\u0a28\0\u0a50\0\u0168"
169:                    + "\0\u0168\0\u0a78\0\u0168\0\u0aa0\0\u0ac8\0\u0af0\0\u0b18\0\u0168"
170:                    + "\0\u0b40\0\u0168\0\u0b68\0\u0168\0\u0b90\0\u0168\0\u0bb8\0\u0be0"
171:                    + "\0\u0c08\0\u0168\0\u0168";
172:
173:            private static int[] zzUnpackRowMap() {
174:                int[] result = new int[115];
175:                int offset = 0;
176:                offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
177:                return result;
178:            }
179:
180:            private static int zzUnpackRowMap(String packed, int offset,
181:                    int[] result) {
182:                int i = 0; /* index in packed string  */
183:                int j = offset; /* index in unpacked array */
184:                int l = packed.length();
185:                while (i < l) {
186:                    int high = packed.charAt(i++) << 16;
187:                    result[j++] = high | packed.charAt(i++);
188:                }
189:                return j;
190:            }
191:
192:            /** 
193:             * The transition table of the DFA
194:             */
195:            private static final int[] ZZ_TRANS = zzUnpackTrans();
196:
197:            private static final String ZZ_TRANS_PACKED_0 = "\1\12\1\13\2\14\1\15\1\12\1\16\1\17\23\15"
198:                    + "\1\20\1\21\1\22\1\23\1\24\1\25\1\26\1\27"
199:                    + "\1\30\1\31\1\12\1\32\1\12\45\33\1\34\2\33"
200:                    + "\1\35\2\36\3\35\1\37\41\35\43\40\1\41\4\40"
201:                    + "\1\42\1\43\1\44\45\42\45\45\1\46\2\45\50\7"
202:                    + "\50\10\50\11\52\0\1\14\51\0\2\15\2\0\23\15"
203:                    + "\25\0\1\47\1\50\2\0\1\51\1\52\1\53\1\0"
204:                    + "\1\54\1\55\2\0\1\56\1\57\2\0\1\60\64\0"
205:                    + "\1\61\45\0\1\62\2\0\1\63\1\0\45\64\1\65"
206:                    + "\47\64\1\65\1\64\1\66\1\35\2\0\3\35\1\0"
207:                    + "\41\35\43\67\1\70\47\67\1\70\2\67\1\44\1\67"
208:                    + "\1\71\1\43\1\44\45\71\2\0\1\44\114\0\1\72"
209:                    + "\11\0\1\73\60\0\1\74\46\0\1\75\40\0\1\76"
210:                    + "\62\0\1\77\45\0\1\100\46\0\1\101\5\0\1\102"
211:                    + "\30\0\1\103\17\0\1\104\27\0\1\105\61\0\1\106"
212:                    + "\36\0\1\107\64\0\1\110\40\0\1\111\45\0\1\112"
213:                    + "\43\0\1\113\47\0\1\114\52\0\1\115\53\0\1\116"
214:                    + "\42\0\1\117\50\0\1\120\64\0\1\121\45\0\1\122"
215:                    + "\32\0\1\123\45\0\1\124\46\0\1\125\56\0\1\126"
216:                    + "\56\0\1\127\46\0\1\130\45\0\1\131\50\0\1\132"
217:                    + "\45\0\1\133\36\0\1\134\62\0\1\135\35\0\1\136"
218:                    + "\46\0\1\137\51\0\1\140\60\0\1\141\35\0\1\142"
219:                    + "\63\0\1\143\35\0\1\144\54\0\1\145\51\0\1\146"
220:                    + "\52\0\1\147\35\0\1\150\53\0\1\151\53\0\1\152"
221:                    + "\53\0\1\153\51\0\1\154\43\0\1\155\32\0\1\156"
222:                    + "\50\0\1\157\60\0\1\160\51\0\1\161\40\0\1\162"
223:                    + "\57\0\1\163\21\0";
224:
225:            private static int[] zzUnpackTrans() {
226:                int[] result = new int[3120];
227:                int offset = 0;
228:                offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
229:                return result;
230:            }
231:
232:            private static int zzUnpackTrans(String packed, int offset,
233:                    int[] result) {
234:                int i = 0; /* index in packed string  */
235:                int j = offset; /* index in unpacked array */
236:                int l = packed.length();
237:                while (i < l) {
238:                    int count = packed.charAt(i++);
239:                    int value = packed.charAt(i++);
240:                    value--;
241:                    do
242:                        result[j++] = value;
243:                    while (--count > 0);
244:                }
245:                return j;
246:            }
247:
248:            /* error codes */
249:            private static final int ZZ_UNKNOWN_ERROR = 0;
250:            private static final int ZZ_NO_MATCH = 1;
251:            private static final int ZZ_PUSHBACK_2BIG = 2;
252:
253:            /* error messages for the codes above */
254:            private static final String ZZ_ERROR_MSG[] = {
255:                    "Unkown internal scanner error",
256:                    "Error: could not match input",
257:                    "Error: pushback value was too large" };
258:
259:            /**
260:             * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
261:             */
262:            private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute();
263:
264:            private static final String ZZ_ATTRIBUTE_PACKED_0 = "\1\0\10\1\1\11\1\1\1\11\1\1\1\11\1\1"
265:                    + "\11\11\5\1\2\11\4\1\2\11\1\1\12\0\3\11"
266:                    + "\2\0\1\11\3\0\1\11\35\0\1\11\1\0\1\11"
267:                    + "\2\0\1\11\2\0\2\11\1\0\1\11\4\0\1\11"
268:                    + "\1\0\1\11\1\0\1\11\1\0\1\11\3\0\2\11";
269:
270:            private static int[] zzUnpackAttribute() {
271:                int[] result = new int[115];
272:                int offset = 0;
273:                offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset,
274:                        result);
275:                return result;
276:            }
277:
278:            private static int zzUnpackAttribute(String packed, int offset,
279:                    int[] result) {
280:                int i = 0; /* index in packed string  */
281:                int j = offset; /* index in unpacked array */
282:                int l = packed.length();
283:                while (i < l) {
284:                    int count = packed.charAt(i++);
285:                    int value = packed.charAt(i++);
286:                    do
287:                        result[j++] = value;
288:                    while (--count > 0);
289:                }
290:                return j;
291:            }
292:
293:            /** the input device */
294:            private java.io.Reader zzReader;
295:
296:            /** the current state of the DFA */
297:            private int zzState;
298:
299:            /** the current lexical state */
300:            private int zzLexicalState = YYINITIAL;
301:
302:            /** this buffer contains the current text to be matched and is
303:                the source of the yytext() string */
304:            private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
305:
306:            /** the textposition at the last accepting state */
307:            private int zzMarkedPos;
308:
309:            /** the textposition at the last state to be included in yytext */
310:            private int zzPushbackPos;
311:
312:            /** the current text position in the buffer */
313:            private int zzCurrentPos;
314:
315:            /** startRead marks the beginning of the yytext() string in the buffer */
316:            private int zzStartRead;
317:
318:            /** endRead marks the last character in the buffer, that has been read
319:                from input */
320:            private int zzEndRead;
321:
322:            /** number of newlines encountered up to the start of the matched text */
323:            private int yyline;
324:
325:            /** the number of characters up to the start of the matched text */
326:            //private int yychar;
327:            /**
328:             * the number of characters from the last newline up to the start of the 
329:             * matched text
330:             */
331:            private int yycolumn;
332:
333:            /** 
334:             * zzAtBOL == true <=> the scanner is currently at the beginning of a line
335:             */
336:            //private boolean zzAtBOL = true;
337:            /** zzAtEOF == true <=> the scanner is at the EOF */
338:            private boolean zzAtEOF;
339:
340:            /* user code: */
341:            private int token_line;
342:            private int token_column;
343:
344:            private String matched_text;
345:
346:            private Symbol newSymbol(short id) {
347:                return new Symbol(id, yyline + 1, yycolumn + 1, yylength(),
348:                        yytext());
349:            }
350:
351:            private Symbol newSymbol(short id, Object value) {
352:                return new Symbol(id, yyline + 1, yycolumn + 1, yylength(),
353:                        value);
354:            }
355:
356:            /**
357:             * Creates a new scanner
358:             * There is also a java.io.InputStream version of this constructor.
359:             *
360:             * @param   in  the java.io.Reader to read input from.
361:             */
362:            public GrammarScanner(java.io.Reader in) {
363:                this .zzReader = in;
364:            }
365:
366:            /**
367:             * Creates a new scanner.
368:             * There is also java.io.Reader version of this constructor.
369:             *
370:             * @param   in  the java.io.Inputstream to read input from.
371:             */
372:            public GrammarScanner(java.io.InputStream in) {
373:                this (new java.io.InputStreamReader(in));
374:            }
375:
376:            /** 
377:             * Unpacks the compressed character translation table.
378:             *
379:             * @param packed   the packed character translation table
380:             * @return         the unpacked character translation table
381:             */
382:            private static char[] zzUnpackCMap(String packed) {
383:                char[] map = new char[0x10000];
384:                int i = 0; /* index in packed string  */
385:                int j = 0; /* index in unpacked array */
386:                while (i < 1284) {
387:                    int count = packed.charAt(i++);
388:                    char value = packed.charAt(i++);
389:                    do
390:                        map[j++] = value;
391:                    while (--count > 0);
392:                }
393:                return map;
394:            }
395:
396:            /**
397:             * Refills the input buffer.
398:             *
399:             * @return      <code>false</code>, iff there was new input.
400:             * 
401:             * @exception   java.io.IOException  if any I/O-Error occurs
402:             */
403:            private boolean zzRefill() throws java.io.IOException {
404:
405:                /* first: make room (if you can) */
406:                if (zzStartRead > 0) {
407:                    System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0,
408:                            zzEndRead - zzStartRead);
409:
410:                    /* translate stored positions */
411:                    zzEndRead -= zzStartRead;
412:                    zzCurrentPos -= zzStartRead;
413:                    zzMarkedPos -= zzStartRead;
414:                    zzPushbackPos -= zzStartRead;
415:                    zzStartRead = 0;
416:                }
417:
418:                /* is the buffer big enough? */
419:                if (zzCurrentPos >= zzBuffer.length) {
420:                    /* if not: blow it up */
421:                    char newBuffer[] = new char[zzCurrentPos * 2];
422:                    System
423:                            .arraycopy(zzBuffer, 0, newBuffer, 0,
424:                                    zzBuffer.length);
425:                    zzBuffer = newBuffer;
426:                }
427:
428:                /* finally: fill the buffer with new input */
429:                int numRead = zzReader.read(zzBuffer, zzEndRead,
430:                        zzBuffer.length - zzEndRead);
431:
432:                if (numRead < 0) {
433:                    return true;
434:                } else {
435:                    zzEndRead += numRead;
436:                    return false;
437:                }
438:            }
439:
440:            /**
441:             * Closes the input stream.
442:             */
443:            public final void yyclose() throws java.io.IOException {
444:                zzAtEOF = true; /* indicate end of file */
445:                zzEndRead = zzStartRead; /* invalidate buffer    */
446:
447:                if (zzReader != null)
448:                    zzReader.close();
449:            }
450:
451:            /**
452:             * Resets the scanner to read from a new input stream.
453:             * Does not close the old reader.
454:             *
455:             * All internal variables are reset, the old input stream 
456:             * <b>cannot</b> be reused (internal buffer is discarded and lost).
457:             * Lexical state is set to <tt>ZZ_INITIAL</tt>.
458:             *
459:             * @param reader   the new input stream 
460:             */
461:            public final void yyreset(java.io.Reader reader) {
462:                zzReader = reader;
463:                zzAtEOF = false;
464:                zzEndRead = zzStartRead = 0;
465:                zzCurrentPos = zzMarkedPos = zzPushbackPos = 0;
466:                yyline = yycolumn = 0;
467:                zzLexicalState = YYINITIAL;
468:            }
469:
470:            /**
471:             * Returns the current lexical state.
472:             */
473:            public final int yystate() {
474:                return zzLexicalState;
475:            }
476:
477:            /**
478:             * Enters a new lexical state
479:             *
480:             * @param newState the new lexical state
481:             */
482:            public final void yybegin(int newState) {
483:                zzLexicalState = newState;
484:            }
485:
486:            /**
487:             * Returns the text matched by the current regular expression.
488:             */
489:            public final String yytext() {
490:                return new String(zzBuffer, zzStartRead, zzMarkedPos
491:                        - zzStartRead);
492:            }
493:
494:            /**
495:             * Returns the character at position <tt>pos</tt> from the 
496:             * matched text. 
497:             * 
498:             * It is equivalent to yytext().charAt(pos), but faster
499:             *
500:             * @param pos the position of the character to fetch. 
501:             *            A value from 0 to yylength()-1.
502:             *
503:             * @return the character at position pos
504:             */
505:            public final char yycharat(int pos) {
506:                return zzBuffer[zzStartRead + pos];
507:            }
508:
509:            /**
510:             * Returns the length of the matched text region.
511:             */
512:            public final int yylength() {
513:                return zzMarkedPos - zzStartRead;
514:            }
515:
516:            /**
517:             * Reports an error that occured while scanning.
518:             *
519:             * In a wellformed scanner (no or only correct usage of 
520:             * yypushback(int) and a match-all fallback rule) this method 
521:             * will only be called with things that "Can't Possibly Happen".
522:             * If this method is called, something is seriously wrong
523:             * (e.g. a JFlex bug producing a faulty scanner etc.).
524:             *
525:             * Usual syntax/scanner level error handling should be done
526:             * in error fallback rules.
527:             *
528:             * @param   errorCode  the code of the errormessage to display
529:             */
530:            private void zzScanError(int errorCode) {
531:                String message;
532:                try {
533:                    message = ZZ_ERROR_MSG[errorCode];
534:                } catch (ArrayIndexOutOfBoundsException e) {
535:                    message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
536:                }
537:
538:                throw new Error(message);
539:            }
540:
541:            /**
542:             * Pushes the specified amount of characters back into the input stream.
543:             *
544:             * They will be read again by then next call of the scanning method
545:             *
546:             * @param number  the number of characters to be read again.
547:             *                This number must not be greater than yylength()!
548:             */
549:            public void yypushback(int number) {
550:                if (number > yylength())
551:                    zzScanError(ZZ_PUSHBACK_2BIG);
552:
553:                zzMarkedPos -= number;
554:            }
555:
556:            /**
557:             * Resumes scanning until the next regular expression is matched,
558:             * the end of input is encountered or an I/O-Error occurs.
559:             *
560:             * @return      the next token
561:             * @exception   java.io.IOException  if any I/O-Error occurs
562:             */
563:            public Symbol nextToken() throws java.io.IOException,
564:                    Scanner.Exception {
565:                int zzInput;
566:                int zzAction;
567:
568:                // cached fields:
569:                int zzCurrentPosL;
570:                int zzMarkedPosL;
571:                int zzEndReadL = zzEndRead;
572:                char[] zzBufferL = zzBuffer;
573:                char[] zzCMapL = ZZ_CMAP;
574:
575:                int[] zzTransL = ZZ_TRANS;
576:                int[] zzRowMapL = ZZ_ROWMAP;
577:                int[] zzAttrL = ZZ_ATTRIBUTE;
578:
579:                while (true) {
580:                    zzMarkedPosL = zzMarkedPos;
581:
582:                    boolean zzR = false;
583:                    for (zzCurrentPosL = zzStartRead; zzCurrentPosL < zzMarkedPosL; zzCurrentPosL++) {
584:                        switch (zzBufferL[zzCurrentPosL]) {
585:                        case '\u000B':
586:                        case '\u000C':
587:                        case '\u0085':
588:                        case '\u2028':
589:                        case '\u2029':
590:                            yyline++;
591:                            yycolumn = 0;
592:                            zzR = false;
593:                            break;
594:                        case '\r':
595:                            yyline++;
596:                            yycolumn = 0;
597:                            zzR = true;
598:                            break;
599:                        case '\n':
600:                            if (zzR)
601:                                zzR = false;
602:                            else {
603:                                yyline++;
604:                                yycolumn = 0;
605:                            }
606:                            break;
607:                        default:
608:                            zzR = false;
609:                            yycolumn++;
610:                        }
611:                    }
612:
613:                    if (zzR) {
614:                        // peek one character ahead if it is \n (if we have counted one line too much)
615:                        boolean zzPeek;
616:                        if (zzMarkedPosL < zzEndReadL)
617:                            zzPeek = zzBufferL[zzMarkedPosL] == '\n';
618:                        else if (zzAtEOF)
619:                            zzPeek = false;
620:                        else {
621:                            boolean eof = zzRefill();
622:                            zzEndReadL = zzEndRead;
623:                            zzMarkedPosL = zzMarkedPos;
624:                            zzBufferL = zzBuffer;
625:                            if (eof)
626:                                zzPeek = false;
627:                            else
628:                                zzPeek = zzBufferL[zzMarkedPosL] == '\n';
629:                        }
630:                        if (zzPeek)
631:                            yyline--;
632:                    }
633:                    zzAction = -1;
634:
635:                    zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
636:
637:                    zzState = zzLexicalState;
638:
639:                    zzForAction: {
640:                        while (true) {
641:
642:                            if (zzCurrentPosL < zzEndReadL)
643:                                zzInput = zzBufferL[zzCurrentPosL++];
644:                            else if (zzAtEOF) {
645:                                zzInput = YYEOF;
646:                                break zzForAction;
647:                            } else {
648:                                // store back cached positions
649:                                zzCurrentPos = zzCurrentPosL;
650:                                zzMarkedPos = zzMarkedPosL;
651:                                boolean eof = zzRefill();
652:                                // get translated positions and possibly new buffer
653:                                zzCurrentPosL = zzCurrentPos;
654:                                zzMarkedPosL = zzMarkedPos;
655:                                zzBufferL = zzBuffer;
656:                                zzEndReadL = zzEndRead;
657:                                if (eof) {
658:                                    zzInput = YYEOF;
659:                                    break zzForAction;
660:                                } else {
661:                                    zzInput = zzBufferL[zzCurrentPosL++];
662:                                }
663:                            }
664:                            int zzNext = zzTransL[zzRowMapL[zzState]
665:                                    + zzCMapL[zzInput]];
666:                            if (zzNext == -1)
667:                                break zzForAction;
668:                            zzState = zzNext;
669:
670:                            int zzAttributes = zzAttrL[zzState];
671:                            if ((zzAttributes & 1) == 1) {
672:                                zzAction = zzState;
673:                                zzMarkedPosL = zzCurrentPosL;
674:                                if ((zzAttributes & 8) == 8)
675:                                    break zzForAction;
676:                            }
677:
678:                        }
679:                    }
680:
681:                    // store back cached position
682:                    zzMarkedPos = zzMarkedPosL;
683:
684:                    switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
685:                    case 9: { /* ignore */
686:                    }
687:                    case 40:
688:                        break;
689:                    case 28: {
690:                        return newSymbol(Terminals.GOAL);
691:                    }
692:                    case 41:
693:                        break;
694:                    case 10: {
695:                        return newSymbol(Terminals.IDENT, yytext());
696:                    }
697:                    case 42:
698:                        break;
699:                    case 3: {
700:                        yybegin(EOF_MLN_COMMENT);
701:                    }
702:                    case 43:
703:                        break;
704:                    case 35: {
705:                        return newSymbol(Terminals.IMPORT);
706:                    }
707:                    case 44:
708:                        break;
709:                    case 14: {
710:                        return newSymbol(Terminals.SEMI);
711:                    }
712:                    case 45:
713:                        break;
714:                    case 18: {
715:                        return newSymbol(Terminals.QUESTION);
716:                    }
717:                    case 46:
718:                        break;
719:                    case 13: {
720:                        return newSymbol(Terminals.IS);
721:                    }
722:                    case 47:
723:                        break;
724:                    case 4: {
725:                        yybegin(EOF_EOL_COMMENT);
726:                    }
727:                    case 48:
728:                        break;
729:                    case 5: {
730:                        throw new Scanner.Exception(token_line + 1,
731:                                token_column + 1, "end of file in Java code");
732:                    }
733:                    case 49:
734:                        break;
735:                    case 6: {
736:                        throw new Scanner.Exception(token_line + 1,
737:                                token_column + 1, "end of file in comment");
738:                    }
739:                    case 50:
740:                        break;
741:                    case 2: {
742:                        yybegin(YYINITIAL);
743:                        matched_text = null;
744:                        throw new Scanner.Exception(token_line + 1,
745:                                token_column + 1, "unterminated string");
746:                    }
747:                    case 51:
748:                        break;
749:                    case 7: {
750:                        yybegin(YYINITIAL);
751:                    }
752:                    case 52:
753:                        break;
754:                    case 1: {
755:                        yybegin(EOF_CODE);
756:                    }
757:                    case 53:
758:                        break;
759:                    case 33: {
760:                        return newSymbol(Terminals.CLASS);
761:                    }
762:                    case 54:
763:                        break;
764:                    case 36: {
765:                        return newSymbol(Terminals.TYPEOF);
766:                    }
767:                    case 55:
768:                        break;
769:                    case 16: {
770:                        return newSymbol(Terminals.DOT);
771:                    }
772:                    case 56:
773:                        break;
774:                    case 19: {
775:                        return newSymbol(Terminals.PLUS);
776:                    }
777:                    case 57:
778:                        break;
779:                    case 11: {
780:                        token_line = yyline;
781:                        token_column = yycolumn;
782:                        yybegin(TEXT);
783:                    }
784:                    case 58:
785:                        break;
786:                    case 23: {
787:                        token_line = yyline;
788:                        token_column = yycolumn;
789:                        yybegin(CODE);
790:                    }
791:                    case 59:
792:                        break;
793:                    case 24: {
794:                        token_line = yyline;
795:                        token_column = yycolumn;
796:                        yybegin(MLN_COMMENT);
797:                    }
798:                    case 60:
799:                        break;
800:                    case 12: {
801:                        return newSymbol(Terminals.COMMA);
802:                    }
803:                    case 61:
804:                        break;
805:                    case 21: {
806:                        matched_text = yytext();
807:                    }
808:                    case 62:
809:                        break;
810:                    case 22: {
811:                        yybegin(YYINITIAL);
812:                        String txt = matched_text;
813:                        matched_text = null;
814:                        return new Symbol(Terminals.TEXT, Symbol.makePosition(
815:                                token_line + 1, token_column + 1), Symbol
816:                                .makePosition(yyline + 1, yycolumn + 1), txt);
817:                    }
818:                    case 63:
819:                        break;
820:                    case 25: {
821:                        token_line = yyline;
822:                        token_column = yycolumn;
823:                        yybegin(EOL_COMMENT);
824:                    }
825:                    case 64:
826:                        break;
827:                    case 34: {
828:                        return newSymbol(Terminals.HEADER);
829:                    }
830:                    case 65:
831:                        break;
832:                    case 27: {
833:                        yybegin(YYINITIAL);
834:                        return new Symbol(Terminals.CODE, Symbol.makePosition(
835:                                token_line + 1, token_column + 1), Symbol
836:                                .makePosition(yyline + 1, yycolumn + 3),
837:                                matched_text);
838:                    }
839:                    case 66:
840:                        break;
841:                    case 31: {
842:                        return newSymbol(Terminals.EMBED);
843:                    }
844:                    case 67:
845:                        break;
846:                    case 38: {
847:                        return newSymbol(Terminals.NONASSOC);
848:                    }
849:                    case 68:
850:                        break;
851:                    case 29: {
852:                        return newSymbol(Terminals.INIT);
853:                    }
854:                    case 69:
855:                        break;
856:                    case 17: {
857:                        return newSymbol(Terminals.BAR);
858:                    }
859:                    case 70:
860:                        break;
861:                    case 20: {
862:                        return newSymbol(Terminals.STAR);
863:                    }
864:                    case 71:
865:                        break;
866:                    case 26: {
867:                        yypushback(2);
868:                        matched_text = yytext();
869:                        yybegin(CODE_END);
870:                    }
871:                    case 72:
872:                        break;
873:                    case 30: {
874:                        return newSymbol(Terminals.LEFT);
875:                    }
876:                    case 73:
877:                        break;
878:                    case 8: {
879:                        throw new Scanner.Exception(yyline + 1, yycolumn + 1,
880:                                "unrecognized character '" + yytext() + "'");
881:                    }
882:                    case 74:
883:                        break;
884:                    case 39: {
885:                        return newSymbol(Terminals.TERMINALS);
886:                    }
887:                    case 75:
888:                        break;
889:                    case 37: {
890:                        return newSymbol(Terminals.PACKAGE);
891:                    }
892:                    case 76:
893:                        break;
894:                    case 15: {
895:                        return newSymbol(Terminals.AT);
896:                    }
897:                    case 77:
898:                        break;
899:                    case 32: {
900:                        return newSymbol(Terminals.RIGHT);
901:                    }
902:                    case 78:
903:                        break;
904:                    default:
905:                        if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
906:                            zzAtEOF = true;
907:                            {
908:                                return newSymbol(Terminals.EOF, "end-of-file");
909:                            }
910:                        } else {
911:                            zzScanError(ZZ_NO_MATCH);
912:                        }
913:                    }
914:                }
915:            }
916:
917:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.