1 | /* Generated By:JavaCC: Do not edit this line. VersionParserTokenManager.java */ |
2 | /* |
3 | * jDTAUS Core RI Client Container |
4 | * Copyright (C) 2005 Christian Schulte |
5 | * <cs@schulte.it> |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with this library; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | * |
21 | * $JDTAUS: VersionParser.jj 8641 2012-09-27 06:45:17Z schulte $ |
22 | * |
23 | */ |
24 | package org.jdtaus.core.container.ri.client.versioning; |
25 | import java.io.StringReader; |
26 | import java.util.List; |
27 | import java.util.LinkedList; |
28 | import java.util.Locale; |
29 | import java.text.NumberFormat; |
30 | |
31 | /** Token Manager. */ |
32 | public class VersionParserTokenManager implements VersionParserConstants |
33 | { |
34 | |
35 | /** Debug output. */ |
36 | public java.io.PrintStream debugStream = System.out; |
37 | /** Set debug output. */ |
38 | public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } |
39 | private int jjMoveStringLiteralDfa0_0() |
40 | { |
41 | return jjMoveNfa_0(1, 0); |
42 | } |
43 | static final long[] jjbitVec0 = { |
44 | 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL |
45 | }; |
46 | private int jjMoveNfa_0(int startState, int curPos) |
47 | { |
48 | int startsAt = 0; |
49 | jjnewStateCnt = 3; |
50 | int i = 1; |
51 | jjstateSet[0] = startState; |
52 | int kind = 0x7fffffff; |
53 | for (;;) |
54 | { |
55 | if (++jjround == 0x7fffffff) |
56 | ReInitRounds(); |
57 | if (curChar < 64) |
58 | { |
59 | long l = 1L << curChar; |
60 | do |
61 | { |
62 | switch(jjstateSet[--i]) |
63 | { |
64 | case 1: |
65 | if ((0xfc001f7affffc8ffL & l) != 0L) |
66 | { |
67 | if (kind > 3) |
68 | kind = 3; |
69 | jjCheckNAdd(2); |
70 | } |
71 | else if ((0xe08500003700L & l) != 0L) |
72 | { |
73 | if (kind > 2) |
74 | kind = 2; |
75 | } |
76 | else if ((0x3ff000000000000L & l) != 0L) |
77 | { |
78 | if (kind > 1) |
79 | kind = 1; |
80 | jjCheckNAdd(0); |
81 | } |
82 | break; |
83 | case 0: |
84 | if ((0x3ff000000000000L & l) == 0L) |
85 | break; |
86 | kind = 1; |
87 | jjCheckNAdd(0); |
88 | break; |
89 | case 2: |
90 | if ((0xfc001f7affffc8ffL & l) == 0L) |
91 | break; |
92 | kind = 3; |
93 | jjCheckNAdd(2); |
94 | break; |
95 | default : break; |
96 | } |
97 | } while(i != startsAt); |
98 | } |
99 | else if (curChar < 128) |
100 | { |
101 | long l = 1L << (curChar & 077); |
102 | do |
103 | { |
104 | switch(jjstateSet[--i]) |
105 | { |
106 | case 1: |
107 | if ((0xffffffff6ffffffeL & l) != 0L) |
108 | { |
109 | if (kind > 3) |
110 | kind = 3; |
111 | jjCheckNAdd(2); |
112 | } |
113 | else if ((0x90000001L & l) != 0L) |
114 | { |
115 | if (kind > 2) |
116 | kind = 2; |
117 | } |
118 | break; |
119 | case 2: |
120 | if ((0xffffffff6ffffffeL & l) == 0L) |
121 | break; |
122 | kind = 3; |
123 | jjCheckNAdd(2); |
124 | break; |
125 | default : break; |
126 | } |
127 | } while(i != startsAt); |
128 | } |
129 | else |
130 | { |
131 | int i2 = (curChar & 0xff) >> 6; |
132 | long l2 = 1L << (curChar & 077); |
133 | do |
134 | { |
135 | switch(jjstateSet[--i]) |
136 | { |
137 | case 1: |
138 | case 2: |
139 | if ((jjbitVec0[i2] & l2) == 0L) |
140 | break; |
141 | if (kind > 3) |
142 | kind = 3; |
143 | jjCheckNAdd(2); |
144 | break; |
145 | default : break; |
146 | } |
147 | } while(i != startsAt); |
148 | } |
149 | if (kind != 0x7fffffff) |
150 | { |
151 | jjmatchedKind = kind; |
152 | jjmatchedPos = curPos; |
153 | kind = 0x7fffffff; |
154 | } |
155 | ++curPos; |
156 | if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) |
157 | return curPos; |
158 | try { curChar = input_stream.readChar(); } |
159 | catch(java.io.IOException e) { return curPos; } |
160 | } |
161 | } |
162 | static final int[] jjnextStates = { |
163 | }; |
164 | |
165 | /** Token literal values. */ |
166 | public static final String[] jjstrLiteralImages = { |
167 | "", null, null, null, }; |
168 | |
169 | /** Lexer state names. */ |
170 | public static final String[] lexStateNames = { |
171 | "DEFAULT", |
172 | }; |
173 | protected SimpleCharStream input_stream; |
174 | private final int[] jjrounds = new int[3]; |
175 | private final int[] jjstateSet = new int[6]; |
176 | protected char curChar; |
177 | /** Constructor. */ |
178 | public VersionParserTokenManager(SimpleCharStream stream){ |
179 | if (SimpleCharStream.staticFlag) |
180 | throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); |
181 | input_stream = stream; |
182 | } |
183 | |
184 | /** Constructor. */ |
185 | public VersionParserTokenManager(SimpleCharStream stream, int lexState){ |
186 | this(stream); |
187 | SwitchTo(lexState); |
188 | } |
189 | |
190 | /** Reinitialise parser. */ |
191 | public void ReInit(SimpleCharStream stream) |
192 | { |
193 | jjmatchedPos = jjnewStateCnt = 0; |
194 | curLexState = defaultLexState; |
195 | input_stream = stream; |
196 | ReInitRounds(); |
197 | } |
198 | private void ReInitRounds() |
199 | { |
200 | int i; |
201 | jjround = 0x80000001; |
202 | for (i = 3; i-- > 0;) |
203 | jjrounds[i] = 0x80000000; |
204 | } |
205 | |
206 | /** Reinitialise parser. */ |
207 | public void ReInit(SimpleCharStream stream, int lexState) |
208 | { |
209 | ReInit(stream); |
210 | SwitchTo(lexState); |
211 | } |
212 | |
213 | /** Switch to specified lex state. */ |
214 | public void SwitchTo(int lexState) |
215 | { |
216 | if (lexState >= 1 || lexState < 0) |
217 | throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); |
218 | else |
219 | curLexState = lexState; |
220 | } |
221 | |
222 | protected Token jjFillToken() |
223 | { |
224 | final Token t; |
225 | final String curTokenImage; |
226 | final int beginLine; |
227 | final int endLine; |
228 | final int beginColumn; |
229 | final int endColumn; |
230 | String im = jjstrLiteralImages[jjmatchedKind]; |
231 | curTokenImage = (im == null) ? input_stream.GetImage() : im; |
232 | beginLine = input_stream.getBeginLine(); |
233 | beginColumn = input_stream.getBeginColumn(); |
234 | endLine = input_stream.getEndLine(); |
235 | endColumn = input_stream.getEndColumn(); |
236 | t = Token.newToken(jjmatchedKind, curTokenImage); |
237 | |
238 | t.beginLine = beginLine; |
239 | t.endLine = endLine; |
240 | t.beginColumn = beginColumn; |
241 | t.endColumn = endColumn; |
242 | |
243 | return t; |
244 | } |
245 | |
246 | int curLexState = 0; |
247 | int defaultLexState = 0; |
248 | int jjnewStateCnt; |
249 | int jjround; |
250 | int jjmatchedPos; |
251 | int jjmatchedKind; |
252 | |
253 | /** Get the next Token. */ |
254 | public Token getNextToken() |
255 | { |
256 | Token matchedToken; |
257 | int curPos = 0; |
258 | |
259 | EOFLoop : |
260 | for (;;) |
261 | { |
262 | try |
263 | { |
264 | curChar = input_stream.BeginToken(); |
265 | } |
266 | catch(java.io.IOException e) |
267 | { |
268 | jjmatchedKind = 0; |
269 | matchedToken = jjFillToken(); |
270 | return matchedToken; |
271 | } |
272 | |
273 | jjmatchedKind = 0x7fffffff; |
274 | jjmatchedPos = 0; |
275 | curPos = jjMoveStringLiteralDfa0_0(); |
276 | if (jjmatchedKind != 0x7fffffff) |
277 | { |
278 | if (jjmatchedPos + 1 < curPos) |
279 | input_stream.backup(curPos - jjmatchedPos - 1); |
280 | matchedToken = jjFillToken(); |
281 | return matchedToken; |
282 | } |
283 | int error_line = input_stream.getEndLine(); |
284 | int error_column = input_stream.getEndColumn(); |
285 | String error_after = null; |
286 | boolean EOFSeen = false; |
287 | try { input_stream.readChar(); input_stream.backup(1); } |
288 | catch (java.io.IOException e1) { |
289 | EOFSeen = true; |
290 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); |
291 | if (curChar == '\n' || curChar == '\r') { |
292 | error_line++; |
293 | error_column = 0; |
294 | } |
295 | else |
296 | error_column++; |
297 | } |
298 | if (!EOFSeen) { |
299 | input_stream.backup(1); |
300 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); |
301 | } |
302 | throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); |
303 | } |
304 | } |
305 | |
306 | private void jjCheckNAdd(int state) |
307 | { |
308 | if (jjrounds[state] != jjround) |
309 | { |
310 | jjstateSet[jjnewStateCnt++] = state; |
311 | jjrounds[state] = jjround; |
312 | } |
313 | } |
314 | private void jjAddStates(int start, int end) |
315 | { |
316 | do { |
317 | jjstateSet[jjnewStateCnt++] = jjnextStates[start]; |
318 | } while (start++ != end); |
319 | } |
320 | private void jjCheckNAddTwoStates(int state1, int state2) |
321 | { |
322 | jjCheckNAdd(state1); |
323 | jjCheckNAdd(state2); |
324 | } |
325 | |
326 | } |