1 | |
|
2 | |
package org.apache.maven.surefire.group.parse; |
3 | |
|
4 | |
import org.apache.maven.surefire.group.match.*; |
5 | |
import java.io.*; |
6 | |
|
7 | |
public class GroupMatcherParser implements GroupMatcherParserConstants { |
8 | |
public static void main( String[] args ) |
9 | |
throws Exception |
10 | |
{ |
11 | 0 | BufferedReader reader = new BufferedReader( new InputStreamReader( System.in ) ); |
12 | |
while( true ) |
13 | |
{ |
14 | |
try |
15 | |
{ |
16 | 0 | System.out.print( "Enter expression: " ); |
17 | 0 | String expr = reader.readLine(); |
18 | 0 | GroupMatcherParser parser = new GroupMatcherParser( expr ); |
19 | 0 | GroupMatcher matcher = parser.parse(); |
20 | 0 | System.out.println( matcher ); |
21 | |
} |
22 | 0 | catch ( ParseException e ) |
23 | |
{ |
24 | 0 | e.printStackTrace(); |
25 | 0 | } |
26 | |
} |
27 | |
} |
28 | |
|
29 | |
public GroupMatcherParser( String expression ) |
30 | |
{ |
31 | 11 | this( (Reader)(new StringReader( expression ) ) ); |
32 | 11 | } |
33 | |
|
34 | |
private GroupMatcher getMatcher( Op op, GroupMatcher...matchers ) |
35 | |
{ |
36 | 7 | GroupMatcher matcher = null; |
37 | 7 | if ( Op.AND == op ) |
38 | |
{ |
39 | 3 | matcher = new AndGroupMatcher( matchers ); |
40 | |
} |
41 | |
else |
42 | |
{ |
43 | 4 | matcher = new OrGroupMatcher( matchers ); |
44 | |
} |
45 | |
|
46 | 7 | return matcher; |
47 | |
} |
48 | |
|
49 | 3 | public enum Op |
50 | |
{ |
51 | 1 | AND, OR; |
52 | |
} |
53 | |
|
54 | |
final public GroupMatcher parse() throws ParseException { |
55 | 11 | GroupMatcher matcher = null; |
56 | 11 | matcher = expr(); |
57 | 11 | {if (true) return matcher;} |
58 | |
throw new Error("Missing return statement in function"); |
59 | |
} |
60 | |
|
61 | |
final public GroupMatcher expr() throws ParseException { |
62 | 22 | GroupMatcher matcher=null; |
63 | 22 | if (jj_2_1(3)) { |
64 | 18 | matcher = igroup(); |
65 | 4 | } else if (jj_2_2(3)) { |
66 | 4 | matcher = group(); |
67 | |
} else { |
68 | 0 | jj_consume_token(-1); |
69 | 0 | throw new ParseException(); |
70 | |
} |
71 | 22 | {if (true) return matcher;} |
72 | |
throw new Error("Missing return statement in function"); |
73 | |
} |
74 | |
|
75 | |
final public GroupMatcher igroup() throws ParseException { |
76 | 18 | GroupMatcher lhs=null; |
77 | 18 | GroupMatcher rhs=null; |
78 | 18 | Op op=null; |
79 | 18 | lhs = value(); |
80 | 18 | if (jj_2_3(3)) { |
81 | 7 | op = op(); |
82 | 7 | rhs = expr(); |
83 | |
} else { |
84 | |
; |
85 | |
} |
86 | 18 | GroupMatcher matcher = lhs; |
87 | 18 | if ( op != null ) |
88 | |
{ |
89 | 7 | matcher = getMatcher( op, lhs, rhs ); |
90 | |
} |
91 | |
|
92 | 18 | {if (true) return matcher;} |
93 | |
throw new Error("Missing return statement in function"); |
94 | |
} |
95 | |
|
96 | |
final public GroupMatcher group() throws ParseException { |
97 | 4 | boolean inverted=false; |
98 | 4 | GroupMatcher lhs=null; |
99 | 4 | GroupMatcher rhs=null; |
100 | 4 | Op op=null; |
101 | 4 | if (jj_2_4(3)) { |
102 | 2 | not(); |
103 | 2 | inverted=true; |
104 | |
} else { |
105 | |
; |
106 | |
} |
107 | 4 | jj_consume_token(LPAREN); |
108 | 4 | lhs = expr(); |
109 | 4 | if (jj_2_5(3)) { |
110 | 0 | op = op(); |
111 | 0 | rhs = expr(); |
112 | |
} else { |
113 | |
; |
114 | |
} |
115 | 4 | jj_consume_token(RPAREN); |
116 | 4 | GroupMatcher matcher = lhs; |
117 | 4 | if ( op != null ) |
118 | |
{ |
119 | 0 | matcher = getMatcher( op, lhs, rhs ); |
120 | |
} |
121 | |
|
122 | 4 | {if (true) return inverted ? new InverseGroupMatcher( matcher ) : matcher;} |
123 | |
throw new Error("Missing return statement in function"); |
124 | |
} |
125 | |
|
126 | |
final public GroupMatcher value() throws ParseException { |
127 | 18 | boolean inverted=false; |
128 | 18 | Token val=null; |
129 | 18 | if (jj_2_6(3)) { |
130 | 1 | not(); |
131 | 1 | inverted=true; |
132 | |
} else { |
133 | |
; |
134 | |
} |
135 | 18 | val = jj_consume_token(STRING); |
136 | 18 | GroupMatcher m = new SingleGroupMatcher( val.image ); |
137 | 18 | {if (true) return inverted ? new InverseGroupMatcher( m ) : m;} |
138 | |
throw new Error("Missing return statement in function"); |
139 | |
} |
140 | |
|
141 | |
final public Op op() throws ParseException { |
142 | 7 | Op o=null; |
143 | 7 | if (jj_2_7(3)) { |
144 | 3 | jj_consume_token(AND); |
145 | 3 | o=Op.AND; |
146 | 4 | } else if (jj_2_8(3)) { |
147 | 3 | jj_consume_token(OR); |
148 | 3 | o=Op.OR; |
149 | 1 | } else if (jj_2_9(3)) { |
150 | 0 | jj_consume_token(AMP2); |
151 | 0 | o=Op.AND; |
152 | 1 | } else if (jj_2_10(3)) { |
153 | 0 | jj_consume_token(PIPE2); |
154 | 0 | o=Op.OR; |
155 | 1 | } else if (jj_2_11(3)) { |
156 | 1 | jj_consume_token(COMMA); |
157 | 1 | o=Op.OR; |
158 | |
} else { |
159 | 0 | jj_consume_token(-1); |
160 | 0 | throw new ParseException(); |
161 | |
} |
162 | 7 | {if (true) return o;} |
163 | |
throw new Error("Missing return statement in function"); |
164 | |
} |
165 | |
|
166 | |
final public void not() throws ParseException { |
167 | 3 | if (jj_2_12(3)) { |
168 | 3 | jj_consume_token(NOT); |
169 | 0 | } else if (jj_2_13(3)) { |
170 | 0 | jj_consume_token(BANG); |
171 | |
} else { |
172 | 0 | jj_consume_token(-1); |
173 | 0 | throw new ParseException(); |
174 | |
} |
175 | 3 | } |
176 | |
|
177 | |
private boolean jj_2_1(int xla) { |
178 | 22 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
179 | 22 | try { return !jj_3_1(); } |
180 | 7 | catch(LookaheadSuccess ls) { return true; } |
181 | 22 | finally { jj_save(0, xla); } |
182 | |
} |
183 | |
|
184 | |
private boolean jj_2_2(int xla) { |
185 | 4 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
186 | 4 | try { return !jj_3_2(); } |
187 | 4 | catch(LookaheadSuccess ls) { return true; } |
188 | 4 | finally { jj_save(1, xla); } |
189 | |
} |
190 | |
|
191 | |
private boolean jj_2_3(int xla) { |
192 | 18 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
193 | 18 | try { return !jj_3_3(); } |
194 | 0 | catch(LookaheadSuccess ls) { return true; } |
195 | 18 | finally { jj_save(2, xla); } |
196 | |
} |
197 | |
|
198 | |
private boolean jj_2_4(int xla) { |
199 | 4 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
200 | 4 | try { return !jj_3_4(); } |
201 | 0 | catch(LookaheadSuccess ls) { return true; } |
202 | 4 | finally { jj_save(3, xla); } |
203 | |
} |
204 | |
|
205 | |
private boolean jj_2_5(int xla) { |
206 | 4 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
207 | 4 | try { return !jj_3_5(); } |
208 | 0 | catch(LookaheadSuccess ls) { return true; } |
209 | 4 | finally { jj_save(4, xla); } |
210 | |
} |
211 | |
|
212 | |
private boolean jj_2_6(int xla) { |
213 | 18 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
214 | 18 | try { return !jj_3_6(); } |
215 | 0 | catch(LookaheadSuccess ls) { return true; } |
216 | 18 | finally { jj_save(5, xla); } |
217 | |
} |
218 | |
|
219 | |
private boolean jj_2_7(int xla) { |
220 | 7 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
221 | 7 | try { return !jj_3_7(); } |
222 | 0 | catch(LookaheadSuccess ls) { return true; } |
223 | 7 | finally { jj_save(6, xla); } |
224 | |
} |
225 | |
|
226 | |
private boolean jj_2_8(int xla) { |
227 | 4 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
228 | 4 | try { return !jj_3_8(); } |
229 | 0 | catch(LookaheadSuccess ls) { return true; } |
230 | 4 | finally { jj_save(7, xla); } |
231 | |
} |
232 | |
|
233 | |
private boolean jj_2_9(int xla) { |
234 | 1 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
235 | 1 | try { return !jj_3_9(); } |
236 | 0 | catch(LookaheadSuccess ls) { return true; } |
237 | 1 | finally { jj_save(8, xla); } |
238 | |
} |
239 | |
|
240 | |
private boolean jj_2_10(int xla) { |
241 | 1 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
242 | 1 | try { return !jj_3_10(); } |
243 | 0 | catch(LookaheadSuccess ls) { return true; } |
244 | 1 | finally { jj_save(9, xla); } |
245 | |
} |
246 | |
|
247 | |
private boolean jj_2_11(int xla) { |
248 | 1 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
249 | 1 | try { return !jj_3_11(); } |
250 | 0 | catch(LookaheadSuccess ls) { return true; } |
251 | 1 | finally { jj_save(10, xla); } |
252 | |
} |
253 | |
|
254 | |
private boolean jj_2_12(int xla) { |
255 | 3 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
256 | 3 | try { return !jj_3_12(); } |
257 | 0 | catch(LookaheadSuccess ls) { return true; } |
258 | 3 | finally { jj_save(11, xla); } |
259 | |
} |
260 | |
|
261 | |
private boolean jj_2_13(int xla) { |
262 | 0 | jj_la = xla; jj_lastpos = jj_scanpos = token; |
263 | 0 | try { return !jj_3_13(); } |
264 | 0 | catch(LookaheadSuccess ls) { return true; } |
265 | 0 | finally { jj_save(12, xla); } |
266 | |
} |
267 | |
|
268 | |
private boolean jj_3_8() { |
269 | 46 | if (jj_scan_token(OR)) return true; |
270 | 9 | return false; |
271 | |
} |
272 | |
|
273 | |
private boolean jj_3_7() { |
274 | 56 | if (jj_scan_token(AND)) return true; |
275 | 9 | return false; |
276 | |
} |
277 | |
|
278 | |
private boolean jj_3_3() { |
279 | 45 | if (jj_3R_3()) return true; |
280 | 14 | if (jj_3R_4()) return true; |
281 | 7 | return false; |
282 | |
} |
283 | |
|
284 | |
private boolean jj_3R_3() { |
285 | |
Token xsp; |
286 | 49 | xsp = jj_scanpos; |
287 | 49 | if (jj_3_7()) { |
288 | 42 | jj_scanpos = xsp; |
289 | 42 | if (jj_3_8()) { |
290 | 35 | jj_scanpos = xsp; |
291 | 35 | if (jj_3_9()) { |
292 | 35 | jj_scanpos = xsp; |
293 | 35 | if (jj_3_10()) { |
294 | 35 | jj_scanpos = xsp; |
295 | 35 | if (jj_3_11()) return true; |
296 | |
} |
297 | |
} |
298 | |
} |
299 | |
} |
300 | 14 | return false; |
301 | |
} |
302 | |
|
303 | |
private boolean jj_3_6() { |
304 | 58 | if (jj_3R_5()) return true; |
305 | 4 | return false; |
306 | |
} |
307 | |
|
308 | |
private boolean jj_3R_6() { |
309 | |
Token xsp; |
310 | 40 | xsp = jj_scanpos; |
311 | 40 | if (jj_3_6()) jj_scanpos = xsp; |
312 | 40 | if (jj_scan_token(STRING)) return true; |
313 | 27 | return false; |
314 | |
} |
315 | |
|
316 | |
private boolean jj_3R_1() { |
317 | 40 | if (jj_3R_6()) return true; |
318 | |
Token xsp; |
319 | 27 | xsp = jj_scanpos; |
320 | 27 | if (jj_3_3()) jj_scanpos = xsp; |
321 | 18 | return false; |
322 | |
} |
323 | |
|
324 | |
private boolean jj_3_13() { |
325 | 58 | if (jj_scan_token(BANG)) return true; |
326 | 0 | return false; |
327 | |
} |
328 | |
|
329 | |
private boolean jj_3_2() { |
330 | 4 | if (jj_3R_2()) return true; |
331 | 0 | return false; |
332 | |
} |
333 | |
|
334 | |
private boolean jj_3_1() { |
335 | 40 | if (jj_3R_1()) return true; |
336 | 18 | return false; |
337 | |
} |
338 | |
|
339 | |
private boolean jj_3R_5() { |
340 | |
Token xsp; |
341 | 66 | xsp = jj_scanpos; |
342 | 66 | if (jj_3_12()) { |
343 | 58 | jj_scanpos = xsp; |
344 | 58 | if (jj_3_13()) return true; |
345 | |
} |
346 | 8 | return false; |
347 | |
} |
348 | |
|
349 | |
private boolean jj_3_12() { |
350 | 69 | if (jj_scan_token(NOT)) return true; |
351 | 11 | return false; |
352 | |
} |
353 | |
|
354 | |
private boolean jj_3R_4() { |
355 | |
Token xsp; |
356 | 18 | xsp = jj_scanpos; |
357 | 18 | if (jj_3_1()) { |
358 | 0 | jj_scanpos = xsp; |
359 | 0 | if (jj_3_2()) return true; |
360 | |
} |
361 | 7 | return false; |
362 | |
} |
363 | |
|
364 | |
private boolean jj_3_5() { |
365 | 4 | if (jj_3R_3()) return true; |
366 | 0 | if (jj_3R_4()) return true; |
367 | 0 | return false; |
368 | |
} |
369 | |
|
370 | |
private boolean jj_3_11() { |
371 | 36 | if (jj_scan_token(COMMA)) return true; |
372 | 3 | return false; |
373 | |
} |
374 | |
|
375 | |
private boolean jj_3_10() { |
376 | 36 | if (jj_scan_token(PIPE2)) return true; |
377 | 0 | return false; |
378 | |
} |
379 | |
|
380 | |
private boolean jj_3_4() { |
381 | 8 | if (jj_3R_5()) return true; |
382 | 4 | return false; |
383 | |
} |
384 | |
|
385 | |
private boolean jj_3R_2() { |
386 | |
Token xsp; |
387 | 4 | xsp = jj_scanpos; |
388 | 4 | if (jj_3_4()) jj_scanpos = xsp; |
389 | 4 | if (jj_scan_token(LPAREN)) return true; |
390 | 4 | if (jj_3R_4()) return true; |
391 | 0 | xsp = jj_scanpos; |
392 | 0 | if (jj_3_5()) jj_scanpos = xsp; |
393 | 0 | if (jj_scan_token(RPAREN)) return true; |
394 | 0 | return false; |
395 | |
} |
396 | |
|
397 | |
private boolean jj_3_9() { |
398 | 36 | if (jj_scan_token(AMP2)) return true; |
399 | 0 | return false; |
400 | |
} |
401 | |
|
402 | |
|
403 | |
public GroupMatcherParserTokenManager token_source; |
404 | |
SimpleCharStream jj_input_stream; |
405 | |
|
406 | |
public Token token; |
407 | |
|
408 | |
public Token jj_nt; |
409 | |
private int jj_ntk; |
410 | |
private Token jj_scanpos, jj_lastpos; |
411 | |
private int jj_la; |
412 | |
private int jj_gen; |
413 | 11 | final private int[] jj_la1 = new int[0]; |
414 | |
static private int[] jj_la1_0; |
415 | |
static { |
416 | 1 | jj_la1_init_0(); |
417 | 1 | } |
418 | |
private static void jj_la1_init_0() { |
419 | 1 | jj_la1_0 = new int[] {}; |
420 | 1 | } |
421 | 11 | final private JJCalls[] jj_2_rtns = new JJCalls[13]; |
422 | 11 | private boolean jj_rescan = false; |
423 | 11 | private int jj_gc = 0; |
424 | |
|
425 | |
|
426 | |
public GroupMatcherParser(java.io.InputStream stream) { |
427 | 0 | this(stream, null); |
428 | 0 | } |
429 | |
|
430 | 0 | public GroupMatcherParser(java.io.InputStream stream, String encoding) { |
431 | 0 | try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } |
432 | 0 | token_source = new GroupMatcherParserTokenManager(jj_input_stream); |
433 | 0 | token = new Token(); |
434 | 0 | jj_ntk = -1; |
435 | 0 | jj_gen = 0; |
436 | 0 | for (int i = 0; i < 0; i++) jj_la1[i] = -1; |
437 | 0 | for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
438 | 0 | } |
439 | |
|
440 | |
|
441 | |
public void ReInit(java.io.InputStream stream) { |
442 | 0 | ReInit(stream, null); |
443 | 0 | } |
444 | |
|
445 | |
public void ReInit(java.io.InputStream stream, String encoding) { |
446 | 0 | try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } |
447 | 0 | token_source.ReInit(jj_input_stream); |
448 | 0 | token = new Token(); |
449 | 0 | jj_ntk = -1; |
450 | 0 | jj_gen = 0; |
451 | 0 | for (int i = 0; i < 0; i++) jj_la1[i] = -1; |
452 | 0 | for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
453 | 0 | } |
454 | |
|
455 | |
|
456 | 11 | public GroupMatcherParser(java.io.Reader stream) { |
457 | 11 | jj_input_stream = new SimpleCharStream(stream, 1, 1); |
458 | 11 | token_source = new GroupMatcherParserTokenManager(jj_input_stream); |
459 | 11 | token = new Token(); |
460 | 11 | jj_ntk = -1; |
461 | 11 | jj_gen = 0; |
462 | 11 | for (int i = 0; i < 0; i++) jj_la1[i] = -1; |
463 | 11 | for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
464 | 11 | } |
465 | |
|
466 | |
|
467 | |
public void ReInit(java.io.Reader stream) { |
468 | 0 | jj_input_stream.ReInit(stream, 1, 1); |
469 | 0 | token_source.ReInit(jj_input_stream); |
470 | 0 | token = new Token(); |
471 | 0 | jj_ntk = -1; |
472 | 0 | jj_gen = 0; |
473 | 0 | for (int i = 0; i < 0; i++) jj_la1[i] = -1; |
474 | 0 | for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
475 | 0 | } |
476 | |
|
477 | |
|
478 | 0 | public GroupMatcherParser(GroupMatcherParserTokenManager tm) { |
479 | 0 | token_source = tm; |
480 | 0 | token = new Token(); |
481 | 0 | jj_ntk = -1; |
482 | 0 | jj_gen = 0; |
483 | 0 | for (int i = 0; i < 0; i++) jj_la1[i] = -1; |
484 | 0 | for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
485 | 0 | } |
486 | |
|
487 | |
|
488 | |
public void ReInit(GroupMatcherParserTokenManager tm) { |
489 | 0 | token_source = tm; |
490 | 0 | token = new Token(); |
491 | 0 | jj_ntk = -1; |
492 | 0 | jj_gen = 0; |
493 | 0 | for (int i = 0; i < 0; i++) jj_la1[i] = -1; |
494 | 0 | for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); |
495 | 0 | } |
496 | |
|
497 | |
private Token jj_consume_token(int kind) throws ParseException { |
498 | |
Token oldToken; |
499 | 36 | if ((oldToken = token).next != null) token = token.next; |
500 | 0 | else token = token.next = token_source.getNextToken(); |
501 | 36 | jj_ntk = -1; |
502 | 36 | if (token.kind == kind) { |
503 | 36 | jj_gen++; |
504 | 36 | if (++jj_gc > 100) { |
505 | 0 | jj_gc = 0; |
506 | 0 | for (int i = 0; i < jj_2_rtns.length; i++) { |
507 | 0 | JJCalls c = jj_2_rtns[i]; |
508 | 0 | while (c != null) { |
509 | 0 | if (c.gen < jj_gen) c.first = null; |
510 | 0 | c = c.next; |
511 | |
} |
512 | |
} |
513 | |
} |
514 | 36 | return token; |
515 | |
} |
516 | 0 | token = oldToken; |
517 | 0 | jj_kind = kind; |
518 | 0 | throw generateParseException(); |
519 | |
} |
520 | |
|
521 | 22 | static private final class LookaheadSuccess extends java.lang.Error { } |
522 | 11 | final private LookaheadSuccess jj_ls = new LookaheadSuccess(); |
523 | |
private boolean jj_scan_token(int kind) { |
524 | 381 | if (jj_scanpos == jj_lastpos) { |
525 | 137 | jj_la--; |
526 | 137 | if (jj_scanpos.next == null) { |
527 | 43 | jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); |
528 | |
} else { |
529 | 94 | jj_lastpos = jj_scanpos = jj_scanpos.next; |
530 | |
} |
531 | |
} else { |
532 | 244 | jj_scanpos = jj_scanpos.next; |
533 | |
} |
534 | 381 | if (jj_rescan) { |
535 | 0 | int i = 0; Token tok = token; |
536 | 0 | while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } |
537 | 0 | if (tok != null) jj_add_error_token(kind, i); |
538 | |
} |
539 | 381 | if (jj_scanpos.kind != kind) return true; |
540 | 74 | if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; |
541 | 63 | return false; |
542 | |
} |
543 | |
|
544 | |
|
545 | |
|
546 | |
final public Token getNextToken() { |
547 | 0 | if (token.next != null) token = token.next; |
548 | 0 | else token = token.next = token_source.getNextToken(); |
549 | 0 | jj_ntk = -1; |
550 | 0 | jj_gen++; |
551 | 0 | return token; |
552 | |
} |
553 | |
|
554 | |
|
555 | |
final public Token getToken(int index) { |
556 | 0 | Token t = token; |
557 | 0 | for (int i = 0; i < index; i++) { |
558 | 0 | if (t.next != null) t = t.next; |
559 | 0 | else t = t.next = token_source.getNextToken(); |
560 | |
} |
561 | 0 | return t; |
562 | |
} |
563 | |
|
564 | |
private int jj_ntk() { |
565 | 0 | if ((jj_nt=token.next) == null) |
566 | 0 | return (jj_ntk = (token.next=token_source.getNextToken()).kind); |
567 | |
else |
568 | 0 | return (jj_ntk = jj_nt.kind); |
569 | |
} |
570 | |
|
571 | 11 | private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>(); |
572 | |
private int[] jj_expentry; |
573 | 11 | private int jj_kind = -1; |
574 | 11 | private int[] jj_lasttokens = new int[100]; |
575 | |
private int jj_endpos; |
576 | |
|
577 | |
private void jj_add_error_token(int kind, int pos) { |
578 | 0 | if (pos >= 100) return; |
579 | 0 | if (pos == jj_endpos + 1) { |
580 | 0 | jj_lasttokens[jj_endpos++] = kind; |
581 | 0 | } else if (jj_endpos != 0) { |
582 | 0 | jj_expentry = new int[jj_endpos]; |
583 | 0 | for (int i = 0; i < jj_endpos; i++) { |
584 | 0 | jj_expentry[i] = jj_lasttokens[i]; |
585 | |
} |
586 | 0 | jj_entries_loop: for (java.util.Iterator<?> it = jj_expentries.iterator(); it.hasNext();) { |
587 | 0 | int[] oldentry = (int[])(it.next()); |
588 | 0 | if (oldentry.length == jj_expentry.length) { |
589 | 0 | for (int i = 0; i < jj_expentry.length; i++) { |
590 | 0 | if (oldentry[i] != jj_expentry[i]) { |
591 | 0 | continue jj_entries_loop; |
592 | |
} |
593 | |
} |
594 | 0 | jj_expentries.add(jj_expentry); |
595 | 0 | break jj_entries_loop; |
596 | |
} |
597 | 0 | } |
598 | 0 | if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; |
599 | |
} |
600 | 0 | } |
601 | |
|
602 | |
|
603 | |
public ParseException generateParseException() { |
604 | 0 | jj_expentries.clear(); |
605 | 0 | boolean[] la1tokens = new boolean[16]; |
606 | 0 | if (jj_kind >= 0) { |
607 | 0 | la1tokens[jj_kind] = true; |
608 | 0 | jj_kind = -1; |
609 | |
} |
610 | 0 | for (int i = 0; i < 0; i++) { |
611 | 0 | if (jj_la1[i] == jj_gen) { |
612 | 0 | for (int j = 0; j < 32; j++) { |
613 | 0 | if ((jj_la1_0[i] & (1<<j)) != 0) { |
614 | 0 | la1tokens[j] = true; |
615 | |
} |
616 | |
} |
617 | |
} |
618 | |
} |
619 | 0 | for (int i = 0; i < 16; i++) { |
620 | 0 | if (la1tokens[i]) { |
621 | 0 | jj_expentry = new int[1]; |
622 | 0 | jj_expentry[0] = i; |
623 | 0 | jj_expentries.add(jj_expentry); |
624 | |
} |
625 | |
} |
626 | 0 | jj_endpos = 0; |
627 | 0 | jj_rescan_token(); |
628 | 0 | jj_add_error_token(0, 0); |
629 | 0 | int[][] exptokseq = new int[jj_expentries.size()][]; |
630 | 0 | for (int i = 0; i < jj_expentries.size(); i++) { |
631 | 0 | exptokseq[i] = jj_expentries.get(i); |
632 | |
} |
633 | 0 | return new ParseException(token, exptokseq, tokenImage); |
634 | |
} |
635 | |
|
636 | |
|
637 | |
final public void enable_tracing() { |
638 | 0 | } |
639 | |
|
640 | |
|
641 | |
final public void disable_tracing() { |
642 | 0 | } |
643 | |
|
644 | |
private void jj_rescan_token() { |
645 | 0 | jj_rescan = true; |
646 | 0 | for (int i = 0; i < 13; i++) { |
647 | |
try { |
648 | 0 | JJCalls p = jj_2_rtns[i]; |
649 | |
do { |
650 | 0 | if (p.gen > jj_gen) { |
651 | 0 | jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; |
652 | 0 | switch (i) { |
653 | 0 | case 0: jj_3_1(); break; |
654 | 0 | case 1: jj_3_2(); break; |
655 | 0 | case 2: jj_3_3(); break; |
656 | 0 | case 3: jj_3_4(); break; |
657 | 0 | case 4: jj_3_5(); break; |
658 | 0 | case 5: jj_3_6(); break; |
659 | 0 | case 6: jj_3_7(); break; |
660 | 0 | case 7: jj_3_8(); break; |
661 | 0 | case 8: jj_3_9(); break; |
662 | 0 | case 9: jj_3_10(); break; |
663 | 0 | case 10: jj_3_11(); break; |
664 | 0 | case 11: jj_3_12(); break; |
665 | 0 | case 12: jj_3_13(); break; |
666 | |
} |
667 | |
} |
668 | 0 | p = p.next; |
669 | 0 | } while (p != null); |
670 | 0 | } catch(LookaheadSuccess ls) { } |
671 | |
} |
672 | 0 | jj_rescan = false; |
673 | 0 | } |
674 | |
|
675 | |
private void jj_save(int index, int xla) { |
676 | 87 | JJCalls p = jj_2_rtns[index]; |
677 | 87 | while (p.gen > jj_gen) { |
678 | 14 | if (p.next == null) { p = p.next = new JJCalls(); break; } |
679 | 0 | p = p.next; |
680 | |
} |
681 | 87 | p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; |
682 | 87 | } |
683 | |
|
684 | 157 | static final class JJCalls { |
685 | |
int gen; |
686 | |
Token first; |
687 | |
int arg; |
688 | |
JJCalls next; |
689 | |
} |
690 | |
|
691 | |
} |