Debian Codegraph @

util/org/j_paine/formatter/FormatParserTokenManager.java

raw
1 /* Generated By:JavaCC: Do not edit this line. FormatParserTokenManager.java */
2 package org.j_paine.formatter;
3
4 public class FormatParserTokenManager implements FormatParserConstants
5 {
6 public static java.io.PrintStream debugStream = System.out;
7 public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
8 private static final int jjStopStringLiteralDfa_0(int pos, long active0)
9 {
10 switch (pos)
11 {
12 default :
13 return -1;
14 }
15 }
16 private static final int jjStartNfa_0(int pos, long active0)
17 {
18 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
19 }
20 static private final int jjStopAtPos(int pos, int kind)
21 {
22 jjmatchedKind = kind;
23 jjmatchedPos = pos;
24 return pos + 1;
25 }
26 static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
27 {
28 jjmatchedKind = kind;
29 jjmatchedPos = pos;
30 try { curChar = input_stream.readChar(); }
31 catch(java.io.IOException e) { return pos + 1; }
32 return jjMoveNfa_0(state, pos + 1);
33 }
34 static private final int jjMoveStringLiteralDfa0_0()
35 {
36 switch(curChar)
37 {
38 case 40:
39 return jjStopAtPos(0, 15);
40 case 41:
41 return jjStopAtPos(0, 16);
42 case 44:
43 return jjStopAtPos(0, 17);
44 case 46:
45 return jjStopAtPos(0, 13);
46 case 47:
47 return jjStopAtPos(0, 14);
48 default :
49 return jjMoveNfa_0(2, 0);
50 }
51 }
52 static private final void jjCheckNAdd(int state)
53 {
54 if (jjrounds[state] != jjround)
55 {
56 jjstateSet[jjnewStateCnt++] = state;
57 jjrounds[state] = jjround;
58 }
59 }
60 static private final void jjAddStates(int start, int end)
61 {
62 do {
63 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
64 } while (start++ != end);
65 }
66 static private final void jjCheckNAddTwoStates(int state1, int state2)
67 {
68 jjCheckNAdd(state1);
69 jjCheckNAdd(state2);
70 }
71 static private final void jjCheckNAddStates(int start, int end)
72 {
73 do {
74 jjCheckNAdd(jjnextStates[start]);
75 } while (start++ != end);
76 }
77 static private final void jjCheckNAddStates(int start)
78 {
79 jjCheckNAdd(jjnextStates[start]);
80 jjCheckNAdd(jjnextStates[start + 1]);
81 }
82 static final long[] jjbitVec0 = {
83 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
84 };
85 static private final int jjMoveNfa_0(int startState, int curPos)
86 {
87 int[] nextStates;
88 int startsAt = 0;
89 jjnewStateCnt = 14;
90 int i = 1;
91 jjstateSet[0] = startState;
92 int j, kind = 0x7fffffff;
93 for (;;)
94 {
95 if (++jjround == 0x7fffffff)
96 ReInitRounds();
97 if (curChar < 64)
98 {
99 long l = 1L << curChar;
100 MatchLoop: do
101 {
102 switch(jjstateSet[--i])
103 {
104 case 2:
105 if ((0x3ff000000000000L & l) != 0L)
106 {
107 if (kind > 2)
108 kind = 2;
109 jjCheckNAdd(1);
110 }
111 else if (curChar == 39)
112 jjCheckNAddTwoStates(3, 4);
113 else if (curChar == 32)
114 {
115 if (kind > 1)
116 kind = 1;
117 jjCheckNAdd(0);
118 }
119 break;
120 case 0:
121 if (curChar != 32)
122 break;
123 if (kind > 1)
124 kind = 1;
125 jjCheckNAdd(0);
126 break;
127 case 1:
128 if ((0x3ff000000000000L & l) == 0L)
129 break;
130 if (kind > 2)
131 kind = 2;
132 jjCheckNAdd(1);
133 break;
134 case 3:
135 if ((0xffffff7fffffffffL & l) != 0L)
136 jjCheckNAddTwoStates(3, 4);
137 break;
138 case 4:
139 if (curChar == 39 && kind > 3)
140 kind = 3;
141 break;
142 default : break;
143 }
144 } while(i != startsAt);
145 }
146 else if (curChar < 128)
147 {
148 long l = 1L << (curChar & 077);
149 MatchLoop: do
150 {
151 switch(jjstateSet[--i])
152 {
153 case 2:
154 if ((0x100000001000L & l) != 0L)
155 {
156 if (kind > 12)
157 kind = 12;
158 }
159 else if ((0x8000000080L & l) != 0L)
160 {
161 if (kind > 11)
162 kind = 11;
163 }
164 else if ((0x2000000020L & l) != 0L)
165 {
166 if (kind > 10)
167 kind = 10;
168 }
169 else if ((0x1000000010L & l) != 0L)
170 {
171 if (kind > 9)
172 kind = 9;
173 }
174 else if ((0x4000000040L & l) != 0L)
175 {
176 if (kind > 8)
177 kind = 8;
178 }
179 else if ((0x20000000200L & l) != 0L)
180 {
181 if (kind > 7)
182 kind = 7;
183 }
184 else if ((0x100000001000000L & l) != 0L)
185 {
186 if (kind > 6)
187 kind = 6;
188 }
189 else if ((0x1000000010000L & l) != 0L)
190 {
191 if (kind > 5)
192 kind = 5;
193 }
194 else if ((0x200000002L & l) != 0L)
195 {
196 if (kind > 4)
197 kind = 4;
198 }
199 break;
200 case 3:
201 jjAddStates(0, 1);
202 break;
203 case 5:
204 if ((0x200000002L & l) != 0L && kind > 4)
205 kind = 4;
206 break;
207 case 6:
208 if ((0x1000000010000L & l) != 0L && kind > 5)
209 kind = 5;
210 break;
211 case 7:
212 if ((0x100000001000000L & l) != 0L && kind > 6)
213 kind = 6;
214 break;
215 case 8:
216 if ((0x20000000200L & l) != 0L && kind > 7)
217 kind = 7;
218 break;
219 case 9:
220 if ((0x4000000040L & l) != 0L && kind > 8)
221 kind = 8;
222 break;
223 case 10:
224 if ((0x1000000010L & l) != 0L && kind > 9)
225 kind = 9;
226 break;
227 case 11:
228 if ((0x2000000020L & l) != 0L && kind > 10)
229 kind = 10;
230 break;
231 case 12:
232 if ((0x8000000080L & l) != 0L && kind > 11)
233 kind = 11;
234 break;
235 case 13:
236 if ((0x100000001000L & l) != 0L && kind > 12)
237 kind = 12;
238 break;
239 default : break;
240 }
241 } while(i != startsAt);
242 }
243 else
244 {
245 int i2 = (curChar & 0xff) >> 6;
246 long l2 = 1L << (curChar & 077);
247 MatchLoop: do
248 {
249 switch(jjstateSet[--i])
250 {
251 case 3:
252 if ((jjbitVec0[i2] & l2) != 0L)
253 jjAddStates(0, 1);
254 break;
255 default : break;
256 }
257 } while(i != startsAt);
258 }
259 if (kind != 0x7fffffff)
260 {
261 jjmatchedKind = kind;
262 jjmatchedPos = curPos;
263 kind = 0x7fffffff;
264 }
265 ++curPos;
266 if ((i = jjnewStateCnt) == (startsAt = 14 - (jjnewStateCnt = startsAt)))
267 return curPos;
268 try { curChar = input_stream.readChar(); }
269 catch(java.io.IOException e) { return curPos; }
270 }
271 }
272 static final int[] jjnextStates = {
273 3, 4,
274 };
275 public static final String[] jjstrLiteralImages = {
276 "", null, null, null, null, null, null, null, null, null, null, null, null,
277 "\56", "\57", "\50", "\51", "\54", };
278 public static final String[] lexStateNames = {
279 "DEFAULT",
280 };
281 static final long[] jjtoToken = {
282 0x3fffdL,
283 };
284 static final long[] jjtoSkip = {
285 0x2L,
286 };
287 static protected SimpleCharStream input_stream;
288 static private final int[] jjrounds = new int[14];
289 static private final int[] jjstateSet = new int[28];
290 static protected char curChar;
291 public FormatParserTokenManager(SimpleCharStream stream){
292 if (input_stream != null)
293 throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
294 input_stream = stream;
295 }
296 public FormatParserTokenManager(SimpleCharStream stream, int lexState){
297 this(stream);
298 SwitchTo(lexState);
299 }
300 static public void ReInit(SimpleCharStream stream)
301 {
302 jjmatchedPos = jjnewStateCnt = 0;
303 curLexState = defaultLexState;
304 input_stream = stream;
305 ReInitRounds();
306 }
307 static private final void ReInitRounds()
308 {
309 int i;
310 jjround = 0x80000001;
311 for (i = 14; i-- > 0;)
312 jjrounds[i] = 0x80000000;
313 }
314 static public void ReInit(SimpleCharStream stream, int lexState)
315 {
316 ReInit(stream);
317 SwitchTo(lexState);
318 }
319 static public void SwitchTo(int lexState)
320 {
321 if (lexState >= 1 || lexState < 0)
322 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
323 else
324 curLexState = lexState;
325 }
326
327 static protected Token jjFillToken()
328 {
329 Token t = Token.newToken(jjmatchedKind);
330 t.kind = jjmatchedKind;
331 String im = jjstrLiteralImages[jjmatchedKind];
332 t.image = (im == null) ? input_stream.GetImage() : im;
333 t.beginLine = input_stream.getBeginLine();
334 t.beginColumn = input_stream.getBeginColumn();
335 t.endLine = input_stream.getEndLine();
336 t.endColumn = input_stream.getEndColumn();
337 return t;
338 }
339
340 static int curLexState = 0;
341 static int defaultLexState = 0;
342 static int jjnewStateCnt;
343 static int jjround;
344 static int jjmatchedPos;
345 static int jjmatchedKind;
346
347 public static Token getNextToken()
348 {
349 int kind;
350 Token specialToken = null;
351 Token matchedToken;
352 int curPos = 0;
353
354 EOFLoop :
355 for (;;)
356 {
357 try
358 {
359 curChar = input_stream.BeginToken();
360 }
361 catch(java.io.IOException e)
362 {
363 jjmatchedKind = 0;
364 matchedToken = jjFillToken();
365 return matchedToken;
366 }
367
368 jjmatchedKind = 0x7fffffff;
369 jjmatchedPos = 0;
370 curPos = jjMoveStringLiteralDfa0_0();
371 if (jjmatchedKind != 0x7fffffff)
372 {
373 if (jjmatchedPos + 1 < curPos)
374 input_stream.backup(curPos - jjmatchedPos - 1);
375 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
376 {
377 matchedToken = jjFillToken();
378 return matchedToken;
379 }
380 else
381 {
382 continue EOFLoop;
383 }
384 }
385 int error_line = input_stream.getEndLine();
386 int error_column = input_stream.getEndColumn();
387 String error_after = null;
388 boolean EOFSeen = false;
389 try { input_stream.readChar(); input_stream.backup(1); }
390 catch (java.io.IOException e1) {
391 EOFSeen = true;
392 error_after = curPos <= 1 ? "" : input_stream.GetImage();
393 if (curChar == '\n' || curChar == '\r') {
394 error_line++;
395 error_column = 0;
396 }
397 else
398 error_column++;
399 }
400 if (!EOFSeen) {
401 input_stream.backup(1);
402 error_after = curPos <= 1 ? "" : input_stream.GetImage();
403 }
404 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
405 }
406 }
407
408 }