1
2 package JADE_SL.lang.sl;
3
4 import JADE_SL.abs.*;
5 import JADE_SL.onto.Ontology;
6 import JADE_SL.CaseInsensitiveString;
7 import JADE_SL.lang.Codec;
8 import JADE_SL.*;
9
10 import java.io.ByteArrayInputStream;
11 import java.io.StringReader;
12 import java.util.Date;
13
14
15
16 /***
17 * SLParser. This same parser embeds also lower profiles of SL, namely SL-0, SL-1 and SL-2.
18 * @author Fabio Bellifemine, TILab S.p.A. (formerly CSELT S.p.A.)
19 * @version $Date: 2003/10/09 13:00:36 $ $Revision: 1.1.1.1 $
20 **/
21 class SLParser implements SLParserConstants {
22
23
24
25
26
27
28
29
30
31 private String unescape(String s) {
32 StringBuffer result = new StringBuffer(s.length());
33 for( int i=1; i<s.length()-1; i++)
34 if( s.charAt(i) == '//' && s.charAt(i+1) == '\"' ) {
35 result.append("\"");
36 i++;
37 } else
38 result.append(s.charAt(i));
39 return result.toString();
40 }
41
42
43 /***
44 * When an ActionExpression is parsed, if it is an AbsConcept then
45 * it must be casted upto an AbsAgentAction.
46 **/
47 private AbsTerm toAbsAgentAction(AbsTerm t) {
48 if ((t instanceof AbsConcept) && (!(t instanceof AbsAgentAction))) {
49 AbsAgentAction act = new AbsAgentAction(t.getTypeName());
50 String[] slotNames = t.getNames();
51 if (slotNames != null) {
52 for (int i=0; i<slotNames.length; i++)
53 act.set(slotNames[i], (AbsTerm) t.getAbsObject(slotNames[i]));
54 }
55 return act;
56 } else
57 return t;
58 }
59
60 /***
61 * By default an object of this type implements a Full SLParser.
62 * This method allows to change this default.
63 * @param slType (0 for FIPa-SL0, 1 for SL1, 2 for SL2, >2 for full SL)
64 **/
65 void setSLType(int slType) {
66 this.slType = slType;
67 }
68
69
70 Ontology curOntology = null;
71 /***
72 * @param content the content to be parsed
73 * @param o the ontology, null if no ontology (this parameter is used to get the names of the slots
74 * when they are encoded as unnamed slots.
75 */
76 AbsContentElement parse(Ontology o, String content) throws ParseException, TokenMgrError{
77 curOntology = o;
78 ReInit(new StringReader(content));
79 AbsContentElementList tuple = Content();
80 if (tuple.size() > 1)
81 return tuple;
82 else
83 return tuple.get(0);
84 }
85
86 /*** (0 for FIPa-SL0, 1 for SL1, 2 for SL2, >2 for full SL) **/
87 int slType=3;
88
89 public static void main(String[] args) {
90
91 SLParser theParser = null;
92 try {
93 theParser = new SLParser(System.in);
94 theParser.setSLType(Integer.parseInt(args[0]));
95 } catch (Exception e) {
96 System.out.println("usage: SLParser SLLevel\n where SLLevel can be 0 for SL0, 1 for SL1, 2 for SL2, 3 or more for full SL");
97 System.exit(0);
98 }
99 if (theParser.slType < 3)
100 System.out.println("SL-"+theParser.slType+" Parser Started ...");
101 else
102 System.out.println("Full-SL"+" Parser Started ...");
103
104
105
106
107 while (true) {
108 System.out.println("insert an SL expression to parse: ");
109 try {
110 AbsContentElementList result = theParser.Content();
111 System.out.println("\n\n RESULT=\n"+result.toString());
112 System.out.println("\n\n");
113 result.dump();
114
115 }
116 catch(Exception pe) {
117 pe.printStackTrace();
118 System.exit(0);
119 }
120 }
121 }
122
123
124
125 /***
126 * This production rule represents the more general expression that can
127 * serve as content for an ACL message. Since different communicative
128 * acts have different content (action expressions for
129 * <code>request</code>, predicate for <code>inform</code>, etc.), any
130 * allowed SL content expression can be parsed from here.
131 */
132 final public AbsContentElementList Content() throws ParseException {
133 AbsContentElementList tuple = new AbsContentElementList();
134 AbsContentElement val;
135 LBrace();
136 label_1:
137 while (true) {
138 val = ContentExpression();
139 tuple.add(val);
140 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
141 case LBRACE:
142 case WORD:
143 case STRING_LITERAL:
144 case LBRACE2:
145 case WORD2:
146 case STRING_LITERAL2:
147 ;
148 break;
149 default:
150 jj_la1[0] = jj_gen;
151 break label_1;
152 }
153 }
154 RBrace();
155 {if (true) return tuple;}
156 throw new Error("Missing return statement in function");
157 }
158
159 /*** Left Brace in all of the possible states of the Token Manager **/
160 final public void LBrace() throws ParseException {
161 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
162 case LBRACE:
163 jj_consume_token(LBRACE);
164 break;
165 case LBRACE2:
166 jj_consume_token(LBRACE2);
167 break;
168 default:
169 jj_la1[1] = jj_gen;
170 jj_consume_token(-1);
171 throw new ParseException();
172 }
173 }
174
175
176
177 /*** Right Brace in all of the possible states of the Token Manager **/
178 final public void RBrace() throws ParseException {
179 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
180 case RBRACE:
181 jj_consume_token(RBRACE);
182 break;
183 case RBRACE2:
184 jj_consume_token(RBRACE2);
185 break;
186 default:
187 jj_la1[2] = jj_gen;
188 jj_consume_token(-1);
189 throw new ParseException();
190 }
191 }
192
193
194 final public AbsContentElement ContentExpression() throws ParseException {
195 AbsContentElement val=null; String s;
196 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
197 case WORD:
198 case STRING_LITERAL:
199 case WORD2:
200 case STRING_LITERAL2:
201 s = String();
202 val=new AbsPredicate(s);
203 break;
204 case LBRACE:
205 case LBRACE2:
206 LBrace();
207 val = ContentExpression_NoBrace();
208 RBrace();
209 break;
210 default:
211 jj_la1[3] = jj_gen;
212 jj_consume_token(-1);
213 throw new ParseException();
214 }
215 {if (true) return val;}
216 throw new Error("Missing return statement in function");
217 }
218
219 final public AbsContentElement ContentExpression_NoBrace() throws ParseException {
220 AbsContentElement val=null;
221 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
222 case REFERENTIALOP:
223 val = IdentifyingExpression_NoBrace();
224 break;
225 case ACTION:
226 case ACTIONOPLL:
227 val = ActionExpression_NoBrace();
228 break;
229 case WORD:
230 case STRING_LITERAL:
231 case MODALOP:
232 case ACTIONOP:
233 case UNARYLOGICALOP:
234 case BINARYLOGICALOP:
235 case QUANTIFIER:
236 case WORD2:
237 case STRING_LITERAL2:
238 val = Wff_NoBrace();
239 break;
240 default:
241 jj_la1[4] = jj_gen;
242 jj_consume_token(-1);
243 throw new ParseException();
244 }
245 {if (true) return val;}
246 throw new Error("Missing return statement in function");
247 }
248
249
250 final public AbsIRE IdentifyingExpression_NoBrace() throws ParseException {
251 Token t; AbsIRE ire=null; AbsPredicate prop; AbsTerm term; AbsVariable var;
252 t = jj_consume_token(REFERENTIALOP);
253 if (slType<2) {if (true) throw new ParseException("NotFullSL_IdentifyExpression_NotParsable_UseAtLeastSL2");}
254
255 prop = Wff();
256 ire = new AbsIRE(t.image);
257 ire.setVariable(var); ire.setProposition(prop);
258 {if (true) return ire;}
259 throw new Error("Missing return statement in function");
260 }
261
262 final public AbsVariable Variable() throws ParseException {
263 AbsVariable val=null; Token v;
264 v = jj_consume_token(VARIABLE);
265 val = new AbsVariable(); val.setName(v.image); {if (true) return val;}
266 throw new Error("Missing return statement in function");
267 }
268
269 final public AbsTerm Term() throws ParseException {
270 Token v; AbsTerm val=null;
271 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
272 case VARIABLE:
273 val = Variable();
274 break;
275 case INTEGER:
276 case HEXINTEGER:
277 case FLOATONE:
278 case FLOATTWO:
279 case WORD:
280 case STRING_LITERAL:
281 case DATETIME:
282 case WORD2:
283 case STRING_LITERAL2:
284 val = Constant();
285 break;
286 case LBRACE:
287 case LBRACE2:
288 LBrace();
289 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
290 case WORD:
291 case STRING_LITERAL:
292 case ARITHMETICOP:
293 case WORD2:
294 case STRING_LITERAL2:
295 val = FunctionalTerm_NoBrace();
296 break;
297 case ACTION:
298 case ACTIONOPLL:
299 val = ActionExpression_NoBrace();
300 break;
301 case REFERENTIALOP:
302 val = IdentifyingExpression_NoBrace();
303 break;
304 default:
305 jj_la1[5] = jj_gen;
306 jj_consume_token(-1);
307 throw new ParseException();
308 }
309 RBrace();
310 break;
311 default:
312 jj_la1[6] = jj_gen;
313 jj_consume_token(-1);
314 throw new ParseException();
315 }
316 {if (true) return val;}
317 throw new Error("Missing return statement in function");
318 }
319
320 final public AbsPrimitive Constant() throws ParseException {
321 String s; AbsPrimitive val=null; Token t;
322 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
323 case WORD:
324 case STRING_LITERAL:
325 case WORD2:
326 case STRING_LITERAL2:
327 s = String();
328
329 if (CaseInsensitiveString.equalsIgnoreCase(s, "true") ||
330 CaseInsensitiveString.equalsIgnoreCase(s, "false") )
331 val = AbsPrimitive.wrap(Boolean.getBoolean(s));
332 else
333 val = AbsPrimitive.wrap(s);
334 break;
335 case INTEGER:
336 case HEXINTEGER:
337 case FLOATONE:
338 case FLOATTWO:
339 val = Number();
340 break;
341 case DATETIME:
342 t = jj_consume_token(DATETIME);
343 try {
344 Date d=ISO8601.toDate(t.image);
345 val = AbsPrimitive.wrap(d);
346 } catch (Exception e) {
347 val = AbsPrimitive.wrap(t.image);
348 }
349 break;
350 default:
351 jj_la1[7] = jj_gen;
352 jj_consume_token(-1);
353 throw new ParseException();
354 }
355 {if (true) return val;}
356 throw new Error("Missing return statement in function");
357 }
358
359 final public AbsConcept FunctionalTerm_NoBrace() throws ParseException {
360 Token t; AbsTerm term1, term2; AbsConcept val=null; String s;
361 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
362 case ARITHMETICOP:
363 t = jj_consume_token(ARITHMETICOP);
364 term1 = Term();
365 term2 = Term();
366 val = new AbsConcept(t.image);
367 try {
368 String slotNames[] = curOntology.getSchema(t.image).getNames();
369 val.set(slotNames[0], term1);
370 val.set(slotNames[1], term2);
371 } catch (Exception e) {
372 val.set(Codec.UNNAMEDPREFIX+"0", term1);
373 val.set(Codec.UNNAMEDPREFIX+"1", term2);
374 }
375 break;
376 case WORD:
377 case STRING_LITERAL:
378 case WORD2:
379 case STRING_LITERAL2:
380 s = String();
381 if ( (SLCodec.SET.equalsIgnoreCase(s)) || (SLCodec.SEQUENCE.equalsIgnoreCase(s)))
382 val = new AbsAggregate(s);
383 else
384 val = new AbsConcept(s);
385 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
386 case LBRACE:
387 case VARIABLE:
388 case INTEGER:
389 case HEXINTEGER:
390 case FLOATONE:
391 case FLOATTWO:
392 case WORD:
393 case STRING_LITERAL:
394 case PARAMETERNAME:
395 case DATETIME:
396 case LBRACE2:
397 case WORD2:
398 case STRING_LITERAL2:
399 FunctionalTermParameters(val);
400 break;
401 default:
402 jj_la1[8] = jj_gen;
403 ;
404 }
405 break;
406 default:
407 jj_la1[9] = jj_gen;
408 jj_consume_token(-1);
409 throw new ParseException();
410 }
411 {if (true) return val;}
412 throw new Error("Missing return statement in function");
413 }
414
415
416
417 final public void FunctionalTermParameters(AbsConcept val) throws ParseException {
418 AbsTerm t; int slotNumber=0;
419 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
420 case LBRACE:
421 case VARIABLE:
422 case INTEGER:
423 case HEXINTEGER:
424 case FLOATONE:
425 case FLOATTWO:
426 case WORD:
427 case STRING_LITERAL:
428 case DATETIME:
429 case LBRACE2:
430 case WORD2:
431 case STRING_LITERAL2:
432 String slotNames[] = null;
433 try {
434 slotNames = curOntology.getSchema(val.getTypeName()).getNames();
435 } catch (Exception e) {
436 }
437 label_2:
438 while (true) {
439 t = Term();
440 try {
441 val.set(slotNames[slotNumber], t);
442 } catch (Exception e) {
443 val.set(Codec.UNNAMEDPREFIX+slotNumber,t);
444 }
445 slotNumber++;
446 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
447 case LBRACE:
448 case VARIABLE:
449 case INTEGER:
450 case HEXINTEGER:
451 case FLOATONE:
452 case FLOATTWO:
453 case WORD:
454 case STRING_LITERAL:
455 case DATETIME:
456 case LBRACE2:
457 case WORD2:
458 case STRING_LITERAL2:
459 ;
460 break;
461 default:
462 jj_la1[10] = jj_gen;
463 break label_2;
464 }
465 }
466 break;
467 case PARAMETERNAME:
468 label_3:
469 while (true) {
470 Parameter(val);
471 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
472 case PARAMETERNAME:
473 ;
474 break;
475 default:
476 jj_la1[11] = jj_gen;
477 break label_3;
478 }
479 }
480 break;
481 default:
482 jj_la1[12] = jj_gen;
483 jj_consume_token(-1);
484 throw new ParseException();
485 }
486 }
487
488 final public void Parameter(AbsConcept val) throws ParseException {
489 Token t; AbsTerm term;
490 t = jj_consume_token(PARAMETERNAME);
491 term = Term();
492 val.set(t.image.substring(1),term);
493 }
494
495 final public AbsAgentAction ActionExpression_NoBrace() throws ParseException {
496 AbsAgentAction val=null; AbsTerm term1, term2; Token t;
497 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
498 case ACTION:
499 t = jj_consume_token(ACTION);
500 term1 = Term();
501 term2 = Term();
502 val = new AbsAgentAction(t.image);
503 try {
504 String slotNames[] = curOntology.getSchema(t.image).getNames();
505 val.set(slotNames[0], term1);
506 val.set(slotNames[1], toAbsAgentAction(term2));
507 } catch (Exception e) {
508 val.set(Codec.UNNAMEDPREFIX+"0", term1);
509 val.set(Codec.UNNAMEDPREFIX+"1", toAbsAgentAction(term2));
510 }
511 break;
512 case ACTIONOPLL:
513 t = jj_consume_token(ACTIONOPLL);
514 if (slType<2) {if (true) throw new ParseException("NotFullSL_ActionOperatorExpression_NotParsable");}
515 term1 = ActionExpression();
516 term2 = ActionExpression();
517 val = new AbsAgentAction(t.image);
518 try {
519 String slotNames[] = curOntology.getSchema(t.image).getNames();
520 val.set(slotNames[0], term1);
521 val.set(slotNames[1], toAbsAgentAction(term2));
522 } catch (Exception e) {
523 val.set(Codec.UNNAMEDPREFIX+"0", term1);
524 val.set(Codec.UNNAMEDPREFIX+"1", toAbsAgentAction(term2));
525 }
526 break;
527 default:
528 jj_la1[13] = jj_gen;
529 jj_consume_token(-1);
530 throw new ParseException();
531 }
532 {if (true) return val;}
533 throw new Error("Missing return statement in function");
534 }
535
536 final public AbsAgentAction ActionExpression() throws ParseException {
537 AbsAgentAction val=null;
538 LBrace();
539 val = ActionExpression_NoBrace();
540 RBrace();
541 {if (true) return val;}
542 throw new Error("Missing return statement in function");
543 }
544
545 final public AbsPredicate Wff() throws ParseException {
546 AbsPredicate val=null; String s;
547 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
548 case WORD:
549 case STRING_LITERAL:
550 case WORD2:
551 case STRING_LITERAL2:
552 s = String();
553 val = new AbsPredicate(s);
554 break;
555 case LBRACE:
556 case LBRACE2:
557 LBrace();
558 val = Wff_NoBrace();
559 RBrace();
560 break;
561 default:
562 jj_la1[14] = jj_gen;
563 jj_consume_token(-1);
564 throw new ParseException();
565 }
566 {if (true) return val;}
567 throw new Error("Missing return statement in function");
568 }
569
570 final public AbsPredicate Wff_NoBrace() throws ParseException {
571 AbsPredicate arg1, arg2, val=null; Token t; AbsTerm term; String s;
572 AbsAgentAction act; String slotNames[]=null;
573 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
574 case UNARYLOGICALOP:
575 t = jj_consume_token(UNARYLOGICALOP);
576 if (slType<1) {if (true) throw new ParseException("NotFullSL_NotExpression_NotParsable_UseAtLeastSL1");}
577 arg1 = Wff();
578 val = new AbsPredicate(t.image);
579 try {
580 slotNames = curOntology.getSchema(t.image).getNames();
581 val.set(slotNames[0], arg1);
582 } catch (Exception e) {
583 val.set(Codec.UNNAMEDPREFIX+"0", arg1);
584 }
585 break;
586 case BINARYLOGICALOP:
587 t = jj_consume_token(BINARYLOGICALOP);
588 if (slType<1) {if (true) throw new ParseException("NotFullSL_BinaryLogicalExpression_NotParsable_UseAtLeastSL1");}
589 arg1 = Wff();
590 arg2 = Wff();
591 val = new AbsPredicate(t.image);
592 try {
593 slotNames = curOntology.getSchema(t.image).getNames();
594 val.set(slotNames[0], arg1);
595 val.set(slotNames[1], arg2);
596 } catch (Exception e) {
597 val.set(Codec.UNNAMEDPREFIX+"0", arg1);
598 val.set(Codec.UNNAMEDPREFIX+"1", arg2);
599 }
600 break;
601 case QUANTIFIER:
602 t = jj_consume_token(QUANTIFIER);
603 if (slType<2) {if (true) throw new ParseException("NotFullSL_QuantifierExpression_NotParsable_UseAtLeastSL2");} AbsVariable var;
604 var = Variable();
605 arg1 = Wff();
606 val = new AbsPredicate(t.image);
607 try {
608 slotNames = curOntology.getSchema(t.image).getNames();
609 val.set(slotNames[0], var);
610 val.set(slotNames[1], arg1);
611 } catch (Exception e) {
612 val.set(Codec.UNNAMEDPREFIX+"0", var);
613 val.set(Codec.UNNAMEDPREFIX+"1", arg1);
614 }
615 break;
616 case MODALOP:
617 t = jj_consume_token(MODALOP);
618 if (slType<2) {if (true) throw new ParseException("NotFullSL_ModalOperatorExpression_NotParsable_UseAtLeastSL2");}
619 term = Term();
620 arg1 = Wff();
621 val = new AbsPredicate(t.image);
622 try {
623 slotNames = curOntology.getSchema(t.image).getNames();
624 val.set(slotNames[0], term);
625 val.set(slotNames[1], arg1);
626 } catch (Exception e) {
627 val.set(Codec.UNNAMEDPREFIX+"0", term);
628 val.set(Codec.UNNAMEDPREFIX+"1", arg1);
629 }
630 break;
631 case ACTIONOP:
632 t = jj_consume_token(ACTIONOP);
633 act = ActionExpression();
634 val = new AbsPredicate(t.image);
635 try {
636 slotNames = curOntology.getSchema(t.image).getNames();
637 val.set(slotNames[0], act);
638 } catch (Exception e) {
639 val.set(Codec.UNNAMEDPREFIX+"0", act);
640 }
641 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
642 case LBRACE:
643 case WORD:
644 case STRING_LITERAL:
645 case LBRACE2:
646 case WORD2:
647 case STRING_LITERAL2:
648 arg1 = Wff();
649 try {
650 val.set(slotNames[1], arg1);
651 } catch (Exception e) {
652 val.set(Codec.UNNAMEDPREFIX+"1", arg1);
653 }
654 break;
655 default:
656 jj_la1[15] = jj_gen;
657 ;
658 }
659 break;
660 case WORD:
661 case STRING_LITERAL:
662 case WORD2:
663 case STRING_LITERAL2:
664 s = String();
665 val = new AbsPredicate(s); int slotNumber=0;
666 try {
667 slotNames = curOntology.getSchema(s).getNames();
668 } catch (Exception e) {
669 }
670 label_4:
671 while (true) {
672 term = Term();
673 try {
674 val.set(slotNames[slotNumber], term);
675 } catch (Exception e) {
676 val.set(Codec.UNNAMEDPREFIX+slotNumber, term);
677 }
678 slotNumber++;
679 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
680 case LBRACE:
681 case VARIABLE:
682 case INTEGER:
683 case HEXINTEGER:
684 case FLOATONE:
685 case FLOATTWO:
686 case WORD:
687 case STRING_LITERAL:
688 case DATETIME:
689 case LBRACE2:
690 case WORD2:
691 case STRING_LITERAL2:
692 ;
693 break;
694 default:
695 jj_la1[16] = jj_gen;
696 break label_4;
697 }
698 }
699 break;
700 default:
701 jj_la1[17] = jj_gen;
702 jj_consume_token(-1);
703 throw new ParseException();
704 }
705 {if (true) return val;}
706 throw new Error("Missing return statement in function");
707 }
708
709 final public AbsPrimitive Number() throws ParseException {
710 Token t; AbsPrimitive val = null;
711 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
712 case INTEGER:
713 t = jj_consume_token(INTEGER);
714 long value;
715 try {
716 val = AbsPrimitive.wrap(Long.parseLong(t.image));
717 } catch (NumberFormatException e) {
718 e.printStackTrace();
719 val=AbsPrimitive.wrap(t.image);
720 }
721 break;
722 case HEXINTEGER:
723 t = jj_consume_token(HEXINTEGER);
724 val=AbsPrimitive.wrap(t.image);
725 break;
726 case FLOATONE:
727 t = jj_consume_token(FLOATONE);
728 double d1;
729 try {
730
731 d1=(new Double(t.image)).doubleValue();
732 val=AbsPrimitive.wrap(d1);
733 } catch (NumberFormatException e) {
734 e.printStackTrace();
735 val=AbsPrimitive.wrap(t.image);
736 }
737 break;
738 case FLOATTWO:
739 t = jj_consume_token(FLOATTWO);
740 double d2;
741 try {
742
743 d2=(new Double(t.image)).doubleValue();
744 val=AbsPrimitive.wrap(d2);
745 } catch (NumberFormatException e) {
746 e.printStackTrace();
747 val=AbsPrimitive.wrap(t.image);
748 }
749 break;
750 default:
751 jj_la1[18] = jj_gen;
752 jj_consume_token(-1);
753 throw new ParseException();
754 }
755 {if (true) return val;}
756 throw new Error("Missing return statement in function");
757 }
758
759 /***
760 * <p> <code> String = WORD | STRING_LITERAL </code>
761 */
762 final public String String() throws ParseException {
763 Token t;
764 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
765 case WORD2:
766 t = jj_consume_token(WORD2);
767 {if (true) return t.image;}
768 break;
769 case STRING_LITERAL2:
770 t = jj_consume_token(STRING_LITERAL2);
771 {if (true) return unescape(t.image);}
772 break;
773 case WORD:
774 t = jj_consume_token(WORD);
775 {if (true) return t.image;}
776 break;
777 case STRING_LITERAL:
778 t = jj_consume_token(STRING_LITERAL);
779 {if (true) return unescape(t.image);}
780 break;
781 default:
782 jj_la1[19] = jj_gen;
783 jj_consume_token(-1);
784 throw new ParseException();
785 }
786 throw new Error("Missing return statement in function");
787 }
788
789 public SLParserTokenManager token_source;
790 ASCII_CharStream jj_input_stream;
791 public Token token, jj_nt;
792 private int jj_ntk;
793 private int jj_gen;
794 final private int[] jj_la1 = new int[20];
795 final private int[] jj_la1_0 = {0x80103020,0x100020,0x200040,0x80103020,0xfdc03000,0x8ac03000,0x8010bfa0,0x8000bf00,0x8010ffa0,0x82003000,0x8010bfa0,0x4000,0x8010ffa0,0x8400000,0x80103020,0x80103020,0x8010bfa0,0xf5003000,0xf00,0x80003000,};
796 final private int[] jj_la1_1 = {0x1,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x0,0x1,0x0,0x1,0x1,0x1,0x1,0x0,0x1,};
797
798 public SLParser(java.io.InputStream stream) {
799 jj_input_stream = new ASCII_CharStream(stream, 1, 1);
800 token_source = new SLParserTokenManager(jj_input_stream);
801 token = new Token();
802 jj_ntk = -1;
803 jj_gen = 0;
804 for (int i = 0; i < 20; i++) jj_la1[i] = -1;
805 }
806
807 public void ReInit(java.io.InputStream stream) {
808 jj_input_stream.ReInit(stream, 1, 1);
809 token_source.ReInit(jj_input_stream);
810 token = new Token();
811 jj_ntk = -1;
812 jj_gen = 0;
813 for (int i = 0; i < 20; i++) jj_la1[i] = -1;
814 }
815
816 public SLParser(java.io.Reader stream) {
817 jj_input_stream = new ASCII_CharStream(stream, 1, 1);
818 token_source = new SLParserTokenManager(jj_input_stream);
819 token = new Token();
820 jj_ntk = -1;
821 jj_gen = 0;
822 for (int i = 0; i < 20; i++) jj_la1[i] = -1;
823 }
824
825 public void ReInit(java.io.Reader stream) {
826 jj_input_stream.ReInit(stream, 1, 1);
827 token_source.ReInit(jj_input_stream);
828 token = new Token();
829 jj_ntk = -1;
830 jj_gen = 0;
831 for (int i = 0; i < 20; i++) jj_la1[i] = -1;
832 }
833
834 public SLParser(SLParserTokenManager tm) {
835 token_source = tm;
836 token = new Token();
837 jj_ntk = -1;
838 jj_gen = 0;
839 for (int i = 0; i < 20; i++) jj_la1[i] = -1;
840 }
841
842 public void ReInit(SLParserTokenManager tm) {
843 token_source = tm;
844 token = new Token();
845 jj_ntk = -1;
846 jj_gen = 0;
847 for (int i = 0; i < 20; i++) jj_la1[i] = -1;
848 }
849
850 final private Token jj_consume_token(int kind) throws ParseException {
851 Token oldToken;
852 if ((oldToken = token).next != null) token = token.next;
853 else token = token.next = token_source.getNextToken();
854 jj_ntk = -1;
855 if (token.kind == kind) {
856 jj_gen++;
857 return token;
858 }
859 token = oldToken;
860 jj_kind = kind;
861 throw generateParseException();
862 }
863
864 final public Token getNextToken() {
865 if (token.next != null) token = token.next;
866 else token = token.next = token_source.getNextToken();
867 jj_ntk = -1;
868 jj_gen++;
869 return token;
870 }
871
872 final public Token getToken(int index) {
873 Token t = token;
874 for (int i = 0; i < index; i++) {
875 if (t.next != null) t = t.next;
876 else t = t.next = token_source.getNextToken();
877 }
878 return t;
879 }
880
881 final private int jj_ntk() {
882 if ((jj_nt=token.next) == null)
883 return (jj_ntk = (token.next=token_source.getNextToken()).kind);
884 else
885 return (jj_ntk = jj_nt.kind);
886 }
887
888 private java.util.Vector jj_expentries = new java.util.Vector();
889 private int[] jj_expentry;
890 private int jj_kind = -1;
891
892 final public ParseException generateParseException() {
893 jj_expentries.removeAllElements();
894 boolean[] la1tokens = new boolean[33];
895 for (int i = 0; i < 33; i++) {
896 la1tokens[i] = false;
897 }
898 if (jj_kind >= 0) {
899 la1tokens[jj_kind] = true;
900 jj_kind = -1;
901 }
902 for (int i = 0; i < 20; i++) {
903 if (jj_la1[i] == jj_gen) {
904 for (int j = 0; j < 32; j++) {
905 if ((jj_la1_0[i] & (1<<j)) != 0) {
906 la1tokens[j] = true;
907 }
908 if ((jj_la1_1[i] & (1<<j)) != 0) {
909 la1tokens[32+j] = true;
910 }
911 }
912 }
913 }
914 for (int i = 0; i < 33; i++) {
915 if (la1tokens[i]) {
916 jj_expentry = new int[1];
917 jj_expentry[0] = i;
918 jj_expentries.addElement(jj_expentry);
919 }
920 }
921 int[][] exptokseq = new int[jj_expentries.size()][];
922 for (int i = 0; i < jj_expentries.size(); i++) {
923 exptokseq[i] = (int[])jj_expentries.elementAt(i);
924 }
925 return new ParseException(token, exptokseq, tokenImage);
926 }
927
928 final public void enable_tracing() {
929 }
930
931 final public void disable_tracing() {
932 }
933
934 }