1 | |
|
2 | |
|
3 | |
package org.xembly; |
4 | |
import java.util.Collection; |
5 | |
import java.util.LinkedList; |
6 | |
|
7 | |
|
8 | |
import org.antlr.runtime.*; |
9 | |
import java.util.Stack; |
10 | |
import java.util.List; |
11 | |
import java.util.ArrayList; |
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
@SuppressWarnings("all") |
43 | |
public class XemblyParser extends Parser { |
44 | 1 | public static final String[] tokenNames = new String[] { |
45 | |
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "COLON", "COMMA", "DIGIT", "SEMICOLON", |
46 | |
"SPACE", "TEXT", "'ADD'", "'ADDIF'", "'ATTR'", "'CDATA'", "'PI'", "'POP'", |
47 | |
"'PUSH'", "'REMOVE'", "'SET'", "'STRICT'", "'UP'", "'XPATH'", "'XSET'" |
48 | |
}; |
49 | |
public static final int EOF=-1; |
50 | |
public static final int T__10=10; |
51 | |
public static final int T__11=11; |
52 | |
public static final int T__12=12; |
53 | |
public static final int T__13=13; |
54 | |
public static final int T__14=14; |
55 | |
public static final int T__15=15; |
56 | |
public static final int T__16=16; |
57 | |
public static final int T__17=17; |
58 | |
public static final int T__18=18; |
59 | |
public static final int T__19=19; |
60 | |
public static final int T__20=20; |
61 | |
public static final int T__21=21; |
62 | |
public static final int T__22=22; |
63 | |
public static final int COLON=4; |
64 | |
public static final int COMMA=5; |
65 | |
public static final int DIGIT=6; |
66 | |
public static final int SEMICOLON=7; |
67 | |
public static final int SPACE=8; |
68 | |
public static final int TEXT=9; |
69 | |
|
70 | |
|
71 | |
public Parser[] getDelegates() { |
72 | 0 | return new Parser[] {}; |
73 | |
} |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
public XemblyParser(TokenStream input) { |
79 | 29 | this(input, new RecognizerSharedState()); |
80 | 29 | } |
81 | |
public XemblyParser(TokenStream input, RecognizerSharedState state) { |
82 | 29 | super(input, state); |
83 | 29 | } |
84 | |
|
85 | 0 | @Override public String[] getTokenNames() { return XemblyParser.tokenNames; } |
86 | 0 | @Override public String getGrammarFileName() { return "org/xembly/Xembly.g"; } |
87 | |
|
88 | |
|
89 | |
@Override |
90 | |
public void emitErrorMessage(String msg) { |
91 | 0 | throw new ParsingException(msg); |
92 | |
} |
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public final Collection<Directive> directives() throws RecognitionException { |
99 | 29 | Collection<Directive> ret = null; |
100 | |
|
101 | |
|
102 | 29 | Directive directive1 =null; |
103 | |
|
104 | 29 | ret = new LinkedList<Directive>(); |
105 | |
try { |
106 | |
|
107 | |
|
108 | |
{ |
109 | |
|
110 | |
loop2: |
111 | |
while (true) { |
112 | 164 | int alt2=2; |
113 | 164 | int LA2_0 = input.LA(1); |
114 | 163 | if ( (LA2_0==DIGIT||(LA2_0 >= 10 && LA2_0 <= 22)) ) { |
115 | 138 | alt2=1; |
116 | |
} |
117 | |
|
118 | 163 | switch (alt2) { |
119 | |
case 1 : |
120 | |
|
121 | |
{ |
122 | |
|
123 | 138 | int alt1=2; |
124 | 138 | int LA1_0 = input.LA(1); |
125 | 138 | if ( (LA1_0==DIGIT) ) { |
126 | 3 | alt1=1; |
127 | |
} |
128 | 138 | switch (alt1) { |
129 | |
case 1 : |
130 | |
|
131 | |
{ |
132 | 3 | pushFollow(FOLLOW_label_in_directives77); |
133 | 3 | label(); |
134 | 3 | state._fsp--; |
135 | |
|
136 | 3 | match(input,COLON,FOLLOW_COLON_in_directives79); |
137 | |
} |
138 | |
break; |
139 | |
|
140 | |
} |
141 | |
|
142 | 138 | pushFollow(FOLLOW_directive_in_directives91); |
143 | 138 | directive1=directive(); |
144 | 135 | state._fsp--; |
145 | |
|
146 | 135 | match(input,SEMICOLON,FOLLOW_SEMICOLON_in_directives101); |
147 | 135 | ret.add(directive1); |
148 | |
} |
149 | 135 | break; |
150 | |
|
151 | |
default : |
152 | 25 | break loop2; |
153 | |
} |
154 | 135 | } |
155 | |
|
156 | 25 | match(input,EOF,FOLLOW_EOF_in_directives124); |
157 | |
} |
158 | |
|
159 | |
} |
160 | 0 | catch (RecognitionException re) { |
161 | 0 | reportError(re); |
162 | 0 | recover(input,re); |
163 | |
} |
164 | 4 | finally { |
165 | |
|
166 | 29 | } |
167 | 25 | return ret; |
168 | |
} |
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
public final Directive directive() throws RecognitionException { |
176 | 138 | Directive ret = null; |
177 | |
|
178 | |
|
179 | 138 | Object name =null; |
180 | 138 | Object value =null; |
181 | 138 | Object target =null; |
182 | 138 | Object data =null; |
183 | 138 | Object argument2 =null; |
184 | 138 | Object argument3 =null; |
185 | 138 | Object argument4 =null; |
186 | 138 | Object argument5 =null; |
187 | 138 | Object argument6 =null; |
188 | 138 | Object argument7 =null; |
189 | 138 | Object argument8 =null; |
190 | |
|
191 | |
try { |
192 | |
|
193 | 138 | int alt3=13; |
194 | 138 | switch ( input.LA(1) ) { |
195 | |
case 21: |
196 | |
{ |
197 | 15 | alt3=1; |
198 | |
} |
199 | 15 | break; |
200 | |
case 18: |
201 | |
{ |
202 | 10 | alt3=2; |
203 | |
} |
204 | 10 | break; |
205 | |
case 22: |
206 | |
{ |
207 | 2 | alt3=3; |
208 | |
} |
209 | 2 | break; |
210 | |
case 12: |
211 | |
{ |
212 | 5 | alt3=4; |
213 | |
} |
214 | 5 | break; |
215 | |
case 10: |
216 | |
{ |
217 | 67 | alt3=5; |
218 | |
} |
219 | 67 | break; |
220 | |
case 11: |
221 | |
{ |
222 | 3 | alt3=6; |
223 | |
} |
224 | 3 | break; |
225 | |
case 17: |
226 | |
{ |
227 | 2 | alt3=7; |
228 | |
} |
229 | 2 | break; |
230 | |
case 19: |
231 | |
{ |
232 | 10 | alt3=8; |
233 | |
} |
234 | 10 | break; |
235 | |
case 20: |
236 | |
{ |
237 | 20 | alt3=9; |
238 | |
} |
239 | 20 | break; |
240 | |
case 14: |
241 | |
{ |
242 | 4 | alt3=10; |
243 | |
} |
244 | 4 | break; |
245 | |
case 16: |
246 | |
{ |
247 | 0 | alt3=11; |
248 | |
} |
249 | 0 | break; |
250 | |
case 15: |
251 | |
{ |
252 | 0 | alt3=12; |
253 | |
} |
254 | 0 | break; |
255 | |
case 13: |
256 | |
{ |
257 | 0 | alt3=13; |
258 | |
} |
259 | 0 | break; |
260 | |
default: |
261 | 0 | NoViableAltException nvae = |
262 | |
new NoViableAltException("", 3, 0, input); |
263 | 0 | throw nvae; |
264 | |
} |
265 | 138 | switch (alt3) { |
266 | |
case 1 : |
267 | |
|
268 | |
{ |
269 | 15 | match(input,21,FOLLOW_21_in_directive149); |
270 | 15 | pushFollow(FOLLOW_argument_in_directive151); |
271 | 15 | argument2=argument(); |
272 | 15 | state._fsp--; |
273 | |
|
274 | |
|
275 | |
try { |
276 | 15 | ret = new XpathDirective(argument2.toString()); |
277 | 0 | } catch (final XmlContentException ex) { |
278 | 0 | throw new ParsingException(ex); |
279 | 15 | } |
280 | |
|
281 | |
} |
282 | |
break; |
283 | |
case 2 : |
284 | |
|
285 | |
{ |
286 | 10 | match(input,18,FOLLOW_18_in_directive169); |
287 | 9 | pushFollow(FOLLOW_argument_in_directive171); |
288 | 9 | argument3=argument(); |
289 | 9 | state._fsp--; |
290 | |
|
291 | |
|
292 | |
try { |
293 | 9 | ret = new SetDirective(argument3.toString()); |
294 | 0 | } catch (final XmlContentException ex) { |
295 | 0 | throw new ParsingException(ex); |
296 | 9 | } |
297 | |
|
298 | |
} |
299 | |
break; |
300 | |
case 3 : |
301 | |
|
302 | |
{ |
303 | 2 | match(input,22,FOLLOW_22_in_directive189); |
304 | 2 | pushFollow(FOLLOW_argument_in_directive191); |
305 | 2 | argument4=argument(); |
306 | 2 | state._fsp--; |
307 | |
|
308 | |
|
309 | |
try { |
310 | 2 | ret = new XsetDirective(argument4.toString()); |
311 | 0 | } catch (final XmlContentException ex) { |
312 | 0 | throw new ParsingException(ex); |
313 | 2 | } |
314 | |
|
315 | |
} |
316 | |
break; |
317 | |
case 4 : |
318 | |
|
319 | |
{ |
320 | 5 | match(input,12,FOLLOW_12_in_directive209); |
321 | 5 | pushFollow(FOLLOW_argument_in_directive213); |
322 | 5 | name=argument(); |
323 | 5 | state._fsp--; |
324 | |
|
325 | 5 | match(input,COMMA,FOLLOW_COMMA_in_directive215); |
326 | 5 | pushFollow(FOLLOW_argument_in_directive219); |
327 | 5 | value=argument(); |
328 | 5 | state._fsp--; |
329 | |
|
330 | |
|
331 | |
try { |
332 | 5 | ret = new AttrDirective(name.toString(), value.toString()); |
333 | 0 | } catch (final XmlContentException ex) { |
334 | 0 | throw new ParsingException(ex); |
335 | 5 | } |
336 | |
|
337 | |
} |
338 | |
break; |
339 | |
case 5 : |
340 | |
|
341 | |
{ |
342 | 67 | match(input,10,FOLLOW_10_in_directive237); |
343 | 66 | pushFollow(FOLLOW_argument_in_directive239); |
344 | 66 | argument5=argument(); |
345 | 66 | state._fsp--; |
346 | |
|
347 | |
|
348 | |
try { |
349 | 66 | ret = new AddDirective(argument5.toString()); |
350 | 1 | } catch (final XmlContentException ex) { |
351 | 1 | throw new ParsingException(ex); |
352 | 65 | } |
353 | |
|
354 | |
} |
355 | |
break; |
356 | |
case 6 : |
357 | |
|
358 | |
{ |
359 | 3 | match(input,11,FOLLOW_11_in_directive257); |
360 | 3 | pushFollow(FOLLOW_argument_in_directive259); |
361 | 3 | argument6=argument(); |
362 | 3 | state._fsp--; |
363 | |
|
364 | |
|
365 | |
try { |
366 | 3 | ret = new AddIfDirective(argument6.toString()); |
367 | 0 | } catch (final XmlContentException ex) { |
368 | 0 | throw new ParsingException(ex); |
369 | 3 | } |
370 | |
|
371 | |
} |
372 | |
break; |
373 | |
case 7 : |
374 | |
|
375 | |
{ |
376 | 2 | match(input,17,FOLLOW_17_in_directive277); |
377 | |
|
378 | 2 | ret = new RemoveDirective(); |
379 | |
|
380 | |
} |
381 | 2 | break; |
382 | |
case 8 : |
383 | |
|
384 | |
{ |
385 | 10 | match(input,19,FOLLOW_19_in_directive295); |
386 | 10 | pushFollow(FOLLOW_argument_in_directive297); |
387 | 10 | argument7=argument(); |
388 | 10 | state._fsp--; |
389 | |
|
390 | |
|
391 | 10 | ret = new StrictDirective(Integer.parseInt(argument7.toString())); |
392 | |
|
393 | |
} |
394 | 10 | break; |
395 | |
case 9 : |
396 | |
|
397 | |
{ |
398 | 20 | match(input,20,FOLLOW_20_in_directive315); |
399 | |
|
400 | 20 | ret = new UpDirective(); |
401 | |
|
402 | |
} |
403 | 20 | break; |
404 | |
case 10 : |
405 | |
|
406 | |
{ |
407 | 4 | match(input,14,FOLLOW_14_in_directive333); |
408 | 4 | pushFollow(FOLLOW_argument_in_directive337); |
409 | 4 | target=argument(); |
410 | 4 | state._fsp--; |
411 | |
|
412 | 4 | pushFollow(FOLLOW_argument_in_directive341); |
413 | 4 | data=argument(); |
414 | 4 | state._fsp--; |
415 | |
|
416 | |
|
417 | |
try { |
418 | 4 | ret = new PiDirective(target.toString(), data.toString()); |
419 | 0 | } catch (final XmlContentException ex) { |
420 | 0 | throw new ParsingException(ex); |
421 | 4 | } |
422 | |
|
423 | |
} |
424 | |
break; |
425 | |
case 11 : |
426 | |
|
427 | |
{ |
428 | 0 | match(input,16,FOLLOW_16_in_directive359); |
429 | |
|
430 | 0 | ret = new PushDirective(); |
431 | |
|
432 | |
} |
433 | 0 | break; |
434 | |
case 12 : |
435 | |
|
436 | |
{ |
437 | 0 | match(input,15,FOLLOW_15_in_directive377); |
438 | |
|
439 | 0 | ret = new PopDirective(); |
440 | |
|
441 | |
} |
442 | 0 | break; |
443 | |
case 13 : |
444 | |
|
445 | |
{ |
446 | 0 | match(input,13,FOLLOW_13_in_directive395); |
447 | 0 | pushFollow(FOLLOW_argument_in_directive397); |
448 | 0 | argument8=argument(); |
449 | 0 | state._fsp--; |
450 | |
|
451 | |
|
452 | |
try { |
453 | 0 | ret = new CdataDirective(argument8.toString()); |
454 | 0 | } catch (final XmlContentException ex) { |
455 | 0 | throw new ParsingException(ex); |
456 | 0 | } |
457 | |
|
458 | |
} |
459 | |
break; |
460 | |
|
461 | |
} |
462 | |
} |
463 | 0 | catch (RecognitionException re) { |
464 | 0 | reportError(re); |
465 | 0 | recover(input,re); |
466 | |
} |
467 | 3 | finally { |
468 | |
|
469 | 138 | } |
470 | 135 | return ret; |
471 | |
} |
472 | |
|
473 | |
|
474 | |
|
475 | |
|
476 | |
|
477 | |
|
478 | |
public final Object argument() throws RecognitionException { |
479 | 123 | Object ret = null; |
480 | |
|
481 | |
|
482 | 123 | Token TEXT9=null; |
483 | |
|
484 | |
try { |
485 | |
|
486 | |
|
487 | |
{ |
488 | 123 | TEXT9=(Token)match(input,TEXT,FOLLOW_TEXT_in_argument428); |
489 | 123 | ret = (TEXT9!=null?TEXT9.getText():null); |
490 | |
} |
491 | |
|
492 | |
} |
493 | 0 | catch (RecognitionException re) { |
494 | 0 | reportError(re); |
495 | 0 | recover(input,re); |
496 | |
} |
497 | 0 | finally { |
498 | |
|
499 | 123 | } |
500 | 123 | return ret; |
501 | |
} |
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
public final void label() throws RecognitionException { |
509 | |
try { |
510 | |
|
511 | |
|
512 | |
{ |
513 | |
|
514 | 3 | int cnt4=0; |
515 | |
loop4: |
516 | |
while (true) { |
517 | 7 | int alt4=2; |
518 | 7 | int LA4_0 = input.LA(1); |
519 | 7 | if ( (LA4_0==DIGIT) ) { |
520 | 4 | alt4=1; |
521 | |
} |
522 | |
|
523 | 7 | switch (alt4) { |
524 | |
case 1 : |
525 | |
|
526 | |
{ |
527 | 4 | match(input,DIGIT,FOLLOW_DIGIT_in_label455); |
528 | |
} |
529 | 4 | break; |
530 | |
|
531 | |
default : |
532 | 3 | if ( cnt4 >= 1 ) break loop4; |
533 | 0 | EarlyExitException eee = new EarlyExitException(4, input); |
534 | 0 | throw eee; |
535 | |
} |
536 | 4 | cnt4++; |
537 | 4 | } |
538 | |
|
539 | |
} |
540 | |
|
541 | |
} |
542 | 0 | catch (RecognitionException re) { |
543 | 0 | reportError(re); |
544 | 0 | recover(input,re); |
545 | |
} |
546 | 0 | finally { |
547 | |
|
548 | 3 | } |
549 | 3 | } |
550 | |
|
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
|
556 | 1 | public static final BitSet FOLLOW_label_in_directives77 = new BitSet(new long[]{0x0000000000000010L}); |
557 | 1 | public static final BitSet FOLLOW_COLON_in_directives79 = new BitSet(new long[]{0x00000000007FFC00L}); |
558 | 1 | public static final BitSet FOLLOW_directive_in_directives91 = new BitSet(new long[]{0x0000000000000080L}); |
559 | 1 | public static final BitSet FOLLOW_SEMICOLON_in_directives101 = new BitSet(new long[]{0x00000000007FFC40L}); |
560 | 1 | public static final BitSet FOLLOW_EOF_in_directives124 = new BitSet(new long[]{0x0000000000000002L}); |
561 | 1 | public static final BitSet FOLLOW_21_in_directive149 = new BitSet(new long[]{0x0000000000000200L}); |
562 | 1 | public static final BitSet FOLLOW_argument_in_directive151 = new BitSet(new long[]{0x0000000000000002L}); |
563 | 1 | public static final BitSet FOLLOW_18_in_directive169 = new BitSet(new long[]{0x0000000000000200L}); |
564 | 1 | public static final BitSet FOLLOW_argument_in_directive171 = new BitSet(new long[]{0x0000000000000002L}); |
565 | 1 | public static final BitSet FOLLOW_22_in_directive189 = new BitSet(new long[]{0x0000000000000200L}); |
566 | 1 | public static final BitSet FOLLOW_argument_in_directive191 = new BitSet(new long[]{0x0000000000000002L}); |
567 | 1 | public static final BitSet FOLLOW_12_in_directive209 = new BitSet(new long[]{0x0000000000000200L}); |
568 | 1 | public static final BitSet FOLLOW_argument_in_directive213 = new BitSet(new long[]{0x0000000000000020L}); |
569 | 1 | public static final BitSet FOLLOW_COMMA_in_directive215 = new BitSet(new long[]{0x0000000000000200L}); |
570 | 1 | public static final BitSet FOLLOW_argument_in_directive219 = new BitSet(new long[]{0x0000000000000002L}); |
571 | 1 | public static final BitSet FOLLOW_10_in_directive237 = new BitSet(new long[]{0x0000000000000200L}); |
572 | 1 | public static final BitSet FOLLOW_argument_in_directive239 = new BitSet(new long[]{0x0000000000000002L}); |
573 | 1 | public static final BitSet FOLLOW_11_in_directive257 = new BitSet(new long[]{0x0000000000000200L}); |
574 | 1 | public static final BitSet FOLLOW_argument_in_directive259 = new BitSet(new long[]{0x0000000000000002L}); |
575 | 1 | public static final BitSet FOLLOW_17_in_directive277 = new BitSet(new long[]{0x0000000000000002L}); |
576 | 1 | public static final BitSet FOLLOW_19_in_directive295 = new BitSet(new long[]{0x0000000000000200L}); |
577 | 1 | public static final BitSet FOLLOW_argument_in_directive297 = new BitSet(new long[]{0x0000000000000002L}); |
578 | 1 | public static final BitSet FOLLOW_20_in_directive315 = new BitSet(new long[]{0x0000000000000002L}); |
579 | 1 | public static final BitSet FOLLOW_14_in_directive333 = new BitSet(new long[]{0x0000000000000200L}); |
580 | 1 | public static final BitSet FOLLOW_argument_in_directive337 = new BitSet(new long[]{0x0000000000000200L}); |
581 | 1 | public static final BitSet FOLLOW_argument_in_directive341 = new BitSet(new long[]{0x0000000000000002L}); |
582 | 1 | public static final BitSet FOLLOW_16_in_directive359 = new BitSet(new long[]{0x0000000000000002L}); |
583 | 1 | public static final BitSet FOLLOW_15_in_directive377 = new BitSet(new long[]{0x0000000000000002L}); |
584 | 1 | public static final BitSet FOLLOW_13_in_directive395 = new BitSet(new long[]{0x0000000000000200L}); |
585 | 1 | public static final BitSet FOLLOW_argument_in_directive397 = new BitSet(new long[]{0x0000000000000002L}); |
586 | 1 | public static final BitSet FOLLOW_TEXT_in_argument428 = new BitSet(new long[]{0x0000000000000002L}); |
587 | 1 | public static final BitSet FOLLOW_DIGIT_in_label455 = new BitSet(new long[]{0x0000000000000042L}); |
588 | |
} |