1 | /* Generated By:JavaCC: Do not edit this line. VersionParserTokenManager.java */ |
2 | /* |
3 | * Copyright (C) Christian Schulte, 2005-206 |
4 | * All rights reserved. |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
9 | * |
10 | * o Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. |
12 | * |
13 | * o Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in |
15 | * the documentation and/or other materials provided with the |
16 | * distribution. |
17 | * |
18 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, |
19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
20 | * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
21 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | * |
29 | * $JOMC: VersionParser.jj 4613 2012-09-22 10:07:08Z schulte $ |
30 | * |
31 | */ |
32 | package org.jomc.util; |
33 | import java.io.StringReader; |
34 | import java.text.MessageFormat; |
35 | import java.text.NumberFormat; |
36 | import java.util.List; |
37 | import java.util.LinkedList; |
38 | import java.util.Locale; |
39 | import java.util.ResourceBundle; |
40 | |
41 | /** Token Manager. */ |
42 | public class VersionParserTokenManager implements VersionParserConstants |
43 | { |
44 | |
45 | /** Debug output. */ |
46 | public java.io.PrintStream debugStream = System.out; |
47 | /** Set debug output. */ |
48 | public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; } |
49 | private int jjMoveStringLiteralDfa0_0() |
50 | { |
51 | return jjMoveNfa_0(1, 0); |
52 | } |
53 | static final long[] jjbitVec0 = { |
54 | 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL |
55 | }; |
56 | private int jjMoveNfa_0(int startState, int curPos) |
57 | { |
58 | int startsAt = 0; |
59 | jjnewStateCnt = 3; |
60 | int i = 1; |
61 | jjstateSet[0] = startState; |
62 | int kind = 0x7fffffff; |
63 | for (;;) |
64 | { |
65 | if (++jjround == 0x7fffffff) |
66 | ReInitRounds(); |
67 | if (curChar < 64) |
68 | { |
69 | long l = 1L << curChar; |
70 | do |
71 | { |
72 | switch(jjstateSet[--i]) |
73 | { |
74 | case 1: |
75 | if ((0xfc001f7affffc8ffL & l) != 0L) |
76 | { |
77 | if (kind > 3) |
78 | kind = 3; |
79 | jjCheckNAdd(2); |
80 | } |
81 | else if ((0xe08500003700L & l) != 0L) |
82 | { |
83 | if (kind > 2) |
84 | kind = 2; |
85 | } |
86 | else if ((0x3ff000000000000L & l) != 0L) |
87 | { |
88 | if (kind > 1) |
89 | kind = 1; |
90 | jjCheckNAdd(0); |
91 | } |
92 | break; |
93 | case 0: |
94 | if ((0x3ff000000000000L & l) == 0L) |
95 | break; |
96 | kind = 1; |
97 | jjCheckNAdd(0); |
98 | break; |
99 | case 2: |
100 | if ((0xfc001f7affffc8ffL & l) == 0L) |
101 | break; |
102 | kind = 3; |
103 | jjCheckNAdd(2); |
104 | break; |
105 | default : break; |
106 | } |
107 | } while(i != startsAt); |
108 | } |
109 | else if (curChar < 128) |
110 | { |
111 | long l = 1L << (curChar & 077); |
112 | do |
113 | { |
114 | switch(jjstateSet[--i]) |
115 | { |
116 | case 1: |
117 | if ((0xffffffff6ffffffeL & l) != 0L) |
118 | { |
119 | if (kind > 3) |
120 | kind = 3; |
121 | jjCheckNAdd(2); |
122 | } |
123 | else if ((0x90000001L & l) != 0L) |
124 | { |
125 | if (kind > 2) |
126 | kind = 2; |
127 | } |
128 | break; |
129 | case 2: |
130 | if ((0xffffffff6ffffffeL & l) == 0L) |
131 | break; |
132 | kind = 3; |
133 | jjCheckNAdd(2); |
134 | break; |
135 | default : break; |
136 | } |
137 | } while(i != startsAt); |
138 | } |
139 | else |
140 | { |
141 | int i2 = (curChar & 0xff) >> 6; |
142 | long l2 = 1L << (curChar & 077); |
143 | do |
144 | { |
145 | switch(jjstateSet[--i]) |
146 | { |
147 | case 1: |
148 | case 2: |
149 | if ((jjbitVec0[i2] & l2) == 0L) |
150 | break; |
151 | if (kind > 3) |
152 | kind = 3; |
153 | jjCheckNAdd(2); |
154 | break; |
155 | default : break; |
156 | } |
157 | } while(i != startsAt); |
158 | } |
159 | if (kind != 0x7fffffff) |
160 | { |
161 | jjmatchedKind = kind; |
162 | jjmatchedPos = curPos; |
163 | kind = 0x7fffffff; |
164 | } |
165 | ++curPos; |
166 | if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt))) |
167 | return curPos; |
168 | try { curChar = input_stream.readChar(); } |
169 | catch(java.io.IOException e) { return curPos; } |
170 | } |
171 | } |
172 | static final int[] jjnextStates = { |
173 | }; |
174 | |
175 | /** Token literal values. */ |
176 | public static final String[] jjstrLiteralImages = { |
177 | "", null, null, null, }; |
178 | |
179 | /** Lexer state names. */ |
180 | public static final String[] lexStateNames = { |
181 | "DEFAULT", |
182 | }; |
183 | protected SimpleCharStream input_stream; |
184 | private final int[] jjrounds = new int[3]; |
185 | private final int[] jjstateSet = new int[6]; |
186 | protected char curChar; |
187 | /** Constructor. */ |
188 | public VersionParserTokenManager(SimpleCharStream stream){ |
189 | if (SimpleCharStream.staticFlag) |
190 | throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer."); |
191 | input_stream = stream; |
192 | } |
193 | |
194 | /** Constructor. */ |
195 | public VersionParserTokenManager(SimpleCharStream stream, int lexState){ |
196 | this(stream); |
197 | SwitchTo(lexState); |
198 | } |
199 | |
200 | /** Reinitialise parser. */ |
201 | public void ReInit(SimpleCharStream stream) |
202 | { |
203 | jjmatchedPos = jjnewStateCnt = 0; |
204 | curLexState = defaultLexState; |
205 | input_stream = stream; |
206 | ReInitRounds(); |
207 | } |
208 | private void ReInitRounds() |
209 | { |
210 | int i; |
211 | jjround = 0x80000001; |
212 | for (i = 3; i-- > 0;) |
213 | jjrounds[i] = 0x80000000; |
214 | } |
215 | |
216 | /** Reinitialise parser. */ |
217 | public void ReInit(SimpleCharStream stream, int lexState) |
218 | { |
219 | ReInit(stream); |
220 | SwitchTo(lexState); |
221 | } |
222 | |
223 | /** Switch to specified lex state. */ |
224 | public void SwitchTo(int lexState) |
225 | { |
226 | if (lexState >= 1 || lexState < 0) |
227 | throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE); |
228 | else |
229 | curLexState = lexState; |
230 | } |
231 | |
232 | protected Token jjFillToken() |
233 | { |
234 | final Token t; |
235 | final String curTokenImage; |
236 | final int beginLine; |
237 | final int endLine; |
238 | final int beginColumn; |
239 | final int endColumn; |
240 | String im = jjstrLiteralImages[jjmatchedKind]; |
241 | curTokenImage = (im == null) ? input_stream.GetImage() : im; |
242 | beginLine = input_stream.getBeginLine(); |
243 | beginColumn = input_stream.getBeginColumn(); |
244 | endLine = input_stream.getEndLine(); |
245 | endColumn = input_stream.getEndColumn(); |
246 | t = Token.newToken(jjmatchedKind, curTokenImage); |
247 | |
248 | t.beginLine = beginLine; |
249 | t.endLine = endLine; |
250 | t.beginColumn = beginColumn; |
251 | t.endColumn = endColumn; |
252 | |
253 | return t; |
254 | } |
255 | |
256 | int curLexState = 0; |
257 | int defaultLexState = 0; |
258 | int jjnewStateCnt; |
259 | int jjround; |
260 | int jjmatchedPos; |
261 | int jjmatchedKind; |
262 | |
263 | /** Get the next Token. */ |
264 | public Token getNextToken() |
265 | { |
266 | Token matchedToken; |
267 | int curPos = 0; |
268 | |
269 | EOFLoop : |
270 | for (;;) |
271 | { |
272 | try |
273 | { |
274 | curChar = input_stream.BeginToken(); |
275 | } |
276 | catch(java.io.IOException e) |
277 | { |
278 | jjmatchedKind = 0; |
279 | matchedToken = jjFillToken(); |
280 | return matchedToken; |
281 | } |
282 | |
283 | jjmatchedKind = 0x7fffffff; |
284 | jjmatchedPos = 0; |
285 | curPos = jjMoveStringLiteralDfa0_0(); |
286 | if (jjmatchedKind != 0x7fffffff) |
287 | { |
288 | if (jjmatchedPos + 1 < curPos) |
289 | input_stream.backup(curPos - jjmatchedPos - 1); |
290 | matchedToken = jjFillToken(); |
291 | return matchedToken; |
292 | } |
293 | int error_line = input_stream.getEndLine(); |
294 | int error_column = input_stream.getEndColumn(); |
295 | String error_after = null; |
296 | boolean EOFSeen = false; |
297 | try { input_stream.readChar(); input_stream.backup(1); } |
298 | catch (java.io.IOException e1) { |
299 | EOFSeen = true; |
300 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); |
301 | if (curChar == '\n' || curChar == '\r') { |
302 | error_line++; |
303 | error_column = 0; |
304 | } |
305 | else |
306 | error_column++; |
307 | } |
308 | if (!EOFSeen) { |
309 | input_stream.backup(1); |
310 | error_after = curPos <= 1 ? "" : input_stream.GetImage(); |
311 | } |
312 | throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR); |
313 | } |
314 | } |
315 | |
316 | private void jjCheckNAdd(int state) |
317 | { |
318 | if (jjrounds[state] != jjround) |
319 | { |
320 | jjstateSet[jjnewStateCnt++] = state; |
321 | jjrounds[state] = jjround; |
322 | } |
323 | } |
324 | private void jjAddStates(int start, int end) |
325 | { |
326 | do { |
327 | jjstateSet[jjnewStateCnt++] = jjnextStates[start]; |
328 | } while (start++ != end); |
329 | } |
330 | private void jjCheckNAddTwoStates(int state1, int state2) |
331 | { |
332 | jjCheckNAdd(state1); |
333 | jjCheckNAdd(state2); |
334 | } |
335 | |
336 | } |