001: /* Generated By:JavaCC: Do not edit this line. TurtleParser.java */
002: /*
003: * (c) Copyright 2006 Hewlett-Packard Development Company, LP
004: * All rights reserved.
005: */
006:
007: package com.hp.hpl.jena.n3.turtle.parser;
008:
009: import com.hp.hpl.jena.n3.turtle.ParserBase;
010: import com.hp.hpl.jena.graph.*;
011:
012: public class TurtleParser extends ParserBase implements
013: TurtleParserConstants {
014:
015: // --- Entry point
016: final public void parse() throws ParseException {
017: label_1: while (true) {
018: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
019: case PREFIX:
020: case BASE:
021: case INTEGER:
022: case DECIMAL:
023: case DOUBLE:
024: case STRING_LITERAL1:
025: case STRING_LITERAL2:
026: case STRING_LITERAL_LONG1:
027: case STRING_LITERAL_LONG2:
028: case IRIref:
029: case PNAME_NS:
030: case PNAME_LN:
031: case BLANK_NODE_LABEL:
032: case VAR:
033: case LPAREN:
034: case NIL:
035: case LBRACE:
036: case LBRACKET:
037: case ANON:
038: ;
039: break;
040: default:
041: jj_la1[0] = jj_gen;
042: break label_1;
043: }
044: Statement();
045: }
046: jj_consume_token(0);
047: }
048:
049: final public void Statement() throws ParseException {
050: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
051: case PREFIX:
052: case BASE:
053: Directive();
054: break;
055: case INTEGER:
056: case DECIMAL:
057: case DOUBLE:
058: case STRING_LITERAL1:
059: case STRING_LITERAL2:
060: case STRING_LITERAL_LONG1:
061: case STRING_LITERAL_LONG2:
062: case IRIref:
063: case PNAME_NS:
064: case PNAME_LN:
065: case BLANK_NODE_LABEL:
066: case VAR:
067: case LPAREN:
068: case NIL:
069: case LBRACE:
070: case LBRACKET:
071: case ANON:
072: TriplesSameSubject();
073: break;
074: default:
075: jj_la1[1] = jj_gen;
076: jj_consume_token(-1);
077: throw new ParseException();
078: }
079: jj_consume_token(DOT);
080: }
081:
082: final public void Directive() throws ParseException {
083: Token t;
084: String iri;
085: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
086: case PREFIX:
087: jj_consume_token(PREFIX);
088: t = jj_consume_token(PNAME_NS);
089: iri = IRI_REF();
090: String s = fixupPrefix(t.image, t.beginLine, t.beginColumn);
091: setPrefix(t.beginLine, t.beginColumn, s, iri);
092: break;
093: case BASE:
094: t = jj_consume_token(BASE);
095: iri = IRI_REF();
096: setBase(iri, t.beginLine, t.beginColumn);
097: break;
098: default:
099: jj_la1[2] = jj_gen;
100: jj_consume_token(-1);
101: throw new ParseException();
102: }
103: }
104:
105: // N3
106:
107: // ---- TRIPLES
108: // <<<<< SPARQL extract
109: final public void TriplesSameSubject() throws ParseException {
110: Node s;
111: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
112: case INTEGER:
113: case DECIMAL:
114: case DOUBLE:
115: case STRING_LITERAL1:
116: case STRING_LITERAL2:
117: case STRING_LITERAL_LONG1:
118: case STRING_LITERAL_LONG2:
119: case IRIref:
120: case PNAME_NS:
121: case PNAME_LN:
122: case BLANK_NODE_LABEL:
123: case VAR:
124: case NIL:
125: case LBRACE:
126: case ANON:
127: s = VarOrTerm();
128: PropertyListNotEmpty(s);
129: break;
130: case LPAREN:
131: case LBRACKET:
132: // Any of the triple generating syntax elements
133: s = TriplesNode();
134: PropertyList(s);
135: break;
136: default:
137: jj_la1[3] = jj_gen;
138: jj_consume_token(-1);
139: throw new ParseException();
140: }
141: }
142:
143: final public void PropertyList(Node s) throws ParseException {
144: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
145: case KW_A:
146: case IRIref:
147: case PNAME_NS:
148: case PNAME_LN:
149: case ARROW:
150: PropertyListNotEmpty(s);
151: break;
152: default:
153: jj_la1[4] = jj_gen;
154: ;
155: }
156: }
157:
158: // >>>>> SPARQL extract
159:
160: // Non-recursive for Turtle long PropertyList tests
161: final public void PropertyListNotEmpty(Node s)
162: throws ParseException {
163: Node p;
164: p = Verb();
165: ObjectList(s, p);
166: label_2: while (true) {
167: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
168: case SEMICOLON:
169: ;
170: break;
171: default:
172: jj_la1[5] = jj_gen;
173: break label_2;
174: }
175: jj_consume_token(SEMICOLON);
176: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
177: case KW_A:
178: case IRIref:
179: case PNAME_NS:
180: case PNAME_LN:
181: case ARROW:
182: p = Verb();
183: ObjectList(s, p);
184: break;
185: default:
186: jj_la1[6] = jj_gen;
187: ;
188: }
189: }
190: }
191:
192: // Non-recursive for Turtle long PropertyList tests
193: final public void ObjectList(Node s, Node p) throws ParseException {
194: Node o;
195: Object(s, p);
196: label_3: while (true) {
197: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
198: case COMMA:
199: ;
200: break;
201: default:
202: jj_la1[7] = jj_gen;
203: break label_3;
204: }
205: jj_consume_token(COMMA);
206: Object(s, p);
207: }
208: }
209:
210: final public void Object(Node s, Node p) throws ParseException {
211: Node o;
212: o = GraphNode();
213: Triple t = new Triple(s, p, o);
214: emitTriple(token.beginLine, token.beginColumn, t);
215: }
216:
217: // <<<<< SPARQL extract
218: final public Node Verb() throws ParseException {
219: Node p;
220: String iri;
221: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
222: case IRIref:
223: case PNAME_NS:
224: case PNAME_LN:
225: iri = IRIref();
226: p = createNode(iri);
227: break;
228: case KW_A:
229: jj_consume_token(KW_A);
230: p = nRDFtype;
231: break;
232: case ARROW:
233: jj_consume_token(ARROW);
234: p = nLogImplies;
235: if (strictTurtle)
236: throwParseException(
237: "=> (log:implies) not legal in Turtle",
238: token.beginLine, token.beginColumn);
239: break;
240: default:
241: jj_la1[8] = jj_gen;
242: jj_consume_token(-1);
243: throw new ParseException();
244: }
245: {
246: if (true)
247: return p;
248: }
249: throw new Error("Missing return statement in function");
250: }
251:
252: // -------- Triple expansions
253:
254: // Anything that can stand in a node slot and which is
255: // a number of triples
256: final public Node TriplesNode() throws ParseException {
257: Node n;
258: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
259: case LPAREN:
260: n = Collection();
261: {
262: if (true)
263: return n;
264: }
265: break;
266: case LBRACKET:
267: n = BlankNodePropertyList();
268: {
269: if (true)
270: return n;
271: }
272: break;
273: default:
274: jj_la1[9] = jj_gen;
275: jj_consume_token(-1);
276: throw new ParseException();
277: }
278: throw new Error("Missing return statement in function");
279: }
280:
281: final public Node BlankNodePropertyList() throws ParseException {
282: jj_consume_token(LBRACKET);
283: Node n = createBNode();
284: PropertyListNotEmpty(n);
285: jj_consume_token(RBRACKET);
286: {
287: if (true)
288: return n;
289: }
290: throw new Error("Missing return statement in function");
291: }
292:
293: // ------- RDF collections
294:
295: // Code not as SPARQL/ARQ because of output ordering.
296: final public Node Collection() throws ParseException {
297: Node listHead = nRDFnil;
298: Node lastCell = null;
299: Node n;
300: jj_consume_token(LPAREN);
301: label_4: while (true) {
302: Node cell = createBNode();
303: if (listHead == nRDFnil)
304: listHead = cell;
305: if (lastCell != null)
306: emitTriple(token.beginLine, token.beginColumn,
307: new Triple(lastCell, nRDFrest, cell));
308: n = GraphNode();
309: emitTriple(token.beginLine, token.beginColumn, new Triple(
310: cell, nRDFfirst, n));
311: lastCell = cell;
312: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
313: case INTEGER:
314: case DECIMAL:
315: case DOUBLE:
316: case STRING_LITERAL1:
317: case STRING_LITERAL2:
318: case STRING_LITERAL_LONG1:
319: case STRING_LITERAL_LONG2:
320: case IRIref:
321: case PNAME_NS:
322: case PNAME_LN:
323: case BLANK_NODE_LABEL:
324: case VAR:
325: case LPAREN:
326: case NIL:
327: case LBRACE:
328: case LBRACKET:
329: case ANON:
330: ;
331: break;
332: default:
333: jj_la1[10] = jj_gen;
334: break label_4;
335: }
336: }
337: jj_consume_token(RPAREN);
338: if (lastCell != null)
339: emitTriple(token.beginLine, token.beginColumn, new Triple(
340: lastCell, nRDFrest, nRDFnil));
341: {
342: if (true)
343: return listHead;
344: }
345: throw new Error("Missing return statement in function");
346: }
347:
348: // -------- Nodes in a graph pattern or template
349: final public Node GraphNode() throws ParseException {
350: Node n;
351: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
352: case INTEGER:
353: case DECIMAL:
354: case DOUBLE:
355: case STRING_LITERAL1:
356: case STRING_LITERAL2:
357: case STRING_LITERAL_LONG1:
358: case STRING_LITERAL_LONG2:
359: case IRIref:
360: case PNAME_NS:
361: case PNAME_LN:
362: case BLANK_NODE_LABEL:
363: case VAR:
364: case NIL:
365: case LBRACE:
366: case ANON:
367: n = VarOrTerm();
368: {
369: if (true)
370: return n;
371: }
372: break;
373: case LPAREN:
374: case LBRACKET:
375: n = TriplesNode();
376: {
377: if (true)
378: return n;
379: }
380: break;
381: default:
382: jj_la1[11] = jj_gen;
383: jj_consume_token(-1);
384: throw new ParseException();
385: }
386: throw new Error("Missing return statement in function");
387: }
388:
389: final public Node VarOrTerm() throws ParseException {
390: Node n = null;
391: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
392: case VAR:
393: n = Var();
394: break;
395: case INTEGER:
396: case DECIMAL:
397: case DOUBLE:
398: case STRING_LITERAL1:
399: case STRING_LITERAL2:
400: case STRING_LITERAL_LONG1:
401: case STRING_LITERAL_LONG2:
402: case IRIref:
403: case PNAME_NS:
404: case PNAME_LN:
405: case BLANK_NODE_LABEL:
406: case NIL:
407: case ANON:
408: n = GraphTerm();
409: break;
410: case LBRACE:
411: n = Formula();
412: break;
413: default:
414: jj_la1[12] = jj_gen;
415: jj_consume_token(-1);
416: throw new ParseException();
417: }
418: {
419: if (true)
420: return n;
421: }
422: throw new Error("Missing return statement in function");
423: }
424:
425: final public Node Formula() throws ParseException {
426: Token t;
427: t = jj_consume_token(LBRACE);
428: startFormula(t.beginLine, t.beginColumn);
429: TriplesSameSubject();
430: label_5: while (true) {
431: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
432: case DOT:
433: ;
434: break;
435: default:
436: jj_la1[13] = jj_gen;
437: break label_5;
438: }
439: jj_consume_token(DOT);
440: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
441: case INTEGER:
442: case DECIMAL:
443: case DOUBLE:
444: case STRING_LITERAL1:
445: case STRING_LITERAL2:
446: case STRING_LITERAL_LONG1:
447: case STRING_LITERAL_LONG2:
448: case IRIref:
449: case PNAME_NS:
450: case PNAME_LN:
451: case BLANK_NODE_LABEL:
452: case VAR:
453: case LPAREN:
454: case NIL:
455: case LBRACE:
456: case LBRACKET:
457: case ANON:
458: TriplesSameSubject();
459: break;
460: default:
461: jj_la1[14] = jj_gen;
462: ;
463: }
464: }
465: t = jj_consume_token(RBRACE);
466: endFormula(t.beginLine, t.beginColumn);
467: {
468: if (true)
469: return null;
470: }
471: throw new Error("Missing return statement in function");
472: }
473:
474: // >>>>> SPARQL extract
475: final public Node Var() throws ParseException {
476: Token t;
477: t = jj_consume_token(VAR);
478: {
479: if (true)
480: return createVariable(t.image, t.beginLine,
481: t.beginColumn);
482: }
483: throw new Error("Missing return statement in function");
484: }
485:
486: final public Node GraphTerm() throws ParseException {
487: Node n;
488: String iri;
489: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
490: case IRIref:
491: case PNAME_NS:
492: case PNAME_LN:
493: iri = IRIref();
494: {
495: if (true)
496: return createNode(iri);
497: }
498: break;
499: case STRING_LITERAL1:
500: case STRING_LITERAL2:
501: case STRING_LITERAL_LONG1:
502: case STRING_LITERAL_LONG2:
503: n = RDFLiteral();
504: {
505: if (true)
506: return n;
507: }
508: break;
509: case INTEGER:
510: case DECIMAL:
511: case DOUBLE:
512: // Cleaner sign handling in Turtle.
513: n = NumericLiteral();
514: {
515: if (true)
516: return n;
517: }
518: break;
519: case BLANK_NODE_LABEL:
520: case ANON:
521: n = BlankNode();
522: {
523: if (true)
524: return n;
525: }
526: break;
527: case NIL:
528: jj_consume_token(NIL);
529: {
530: if (true)
531: return nRDFnil;
532: }
533: break;
534: default:
535: jj_la1[15] = jj_gen;
536: jj_consume_token(-1);
537: throw new ParseException();
538: }
539: throw new Error("Missing return statement in function");
540: }
541:
542: // ---- Basic terms
543: final public Node NumericLiteral() throws ParseException {
544: Token t;
545: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
546: case INTEGER:
547: t = jj_consume_token(INTEGER);
548: {
549: if (true)
550: return createLiteralInteger(t.image);
551: }
552: break;
553: case DECIMAL:
554: t = jj_consume_token(DECIMAL);
555: {
556: if (true)
557: return createLiteralDecimal(t.image);
558: }
559: break;
560: case DOUBLE:
561: t = jj_consume_token(DOUBLE);
562: {
563: if (true)
564: return createLiteralDouble(t.image);
565: }
566: break;
567: default:
568: jj_la1[16] = jj_gen;
569: jj_consume_token(-1);
570: throw new ParseException();
571: }
572: throw new Error("Missing return statement in function");
573: }
574:
575: // >>>>> SPARQL extract
576: // Langtag oddity.
577: final public Node RDFLiteral() throws ParseException {
578: Token t;
579: String lex = null;
580: lex = String();
581: String lang = null;
582: String dt = null;
583: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
584: case PREFIX:
585: case LANGTAG:
586: case DATATYPE:
587: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
588: case PREFIX:
589: case LANGTAG:
590: lang = Langtag();
591: break;
592: case DATATYPE:
593: jj_consume_token(DATATYPE);
594: dt = IRIref();
595: break;
596: default:
597: jj_la1[17] = jj_gen;
598: jj_consume_token(-1);
599: throw new ParseException();
600: }
601: break;
602: default:
603: jj_la1[18] = jj_gen;
604: ;
605: }
606: {
607: if (true)
608: return createLiteral(lex, lang, dt);
609: }
610: throw new Error("Missing return statement in function");
611: }
612:
613: final public String Langtag() throws ParseException {
614: Token t;
615: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
616: case LANGTAG:
617: t = jj_consume_token(LANGTAG);
618: break;
619: case PREFIX:
620: t = jj_consume_token(PREFIX);
621: break;
622: default:
623: jj_la1[19] = jj_gen;
624: jj_consume_token(-1);
625: throw new ParseException();
626: }
627: String lang = stripChars(t.image, 1);
628: {
629: if (true)
630: return lang;
631: }
632: throw new Error("Missing return statement in function");
633: }
634:
635: // >>>>> SPARQL extract
636: // Node BooleanLiteral() : {}
637: // {
638: // <TRUE> { return XSD_TRUE ; }
639: // |
640: // <FALSE> { return XSD_FALSE ; }
641: // }
642:
643: // <<<<< SPARQL extract
644: final public String String() throws ParseException {
645: Token t;
646: String lex;
647: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
648: case STRING_LITERAL1:
649: t = jj_consume_token(STRING_LITERAL1);
650: lex = stripQuotes(t.image);
651: break;
652: case STRING_LITERAL2:
653: t = jj_consume_token(STRING_LITERAL2);
654: lex = stripQuotes(t.image);
655: break;
656: case STRING_LITERAL_LONG1:
657: t = jj_consume_token(STRING_LITERAL_LONG1);
658: lex = stripQuotes3(t.image);
659: break;
660: case STRING_LITERAL_LONG2:
661: t = jj_consume_token(STRING_LITERAL_LONG2);
662: lex = stripQuotes3(t.image);
663: break;
664: default:
665: jj_la1[20] = jj_gen;
666: jj_consume_token(-1);
667: throw new ParseException();
668: }
669: lex = unescapeStr(lex, t.beginLine, t.beginColumn);
670: {
671: if (true)
672: return lex;
673: }
674: throw new Error("Missing return statement in function");
675: }
676:
677: final public String IRIref() throws ParseException {
678: String iri;
679: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
680: case IRIref:
681: iri = IRI_REF();
682: {
683: if (true)
684: return iri;
685: }
686: break;
687: case PNAME_NS:
688: case PNAME_LN:
689: iri = PrefixedName();
690: {
691: if (true)
692: return iri;
693: }
694: break;
695: default:
696: jj_la1[21] = jj_gen;
697: jj_consume_token(-1);
698: throw new ParseException();
699: }
700: throw new Error("Missing return statement in function");
701: }
702:
703: final public String PrefixedName() throws ParseException {
704: Token t;
705: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
706: case PNAME_LN:
707: t = jj_consume_token(PNAME_LN);
708: {
709: if (true)
710: return resolvePName(t.image, t.beginLine,
711: t.beginColumn);
712: }
713: break;
714: case PNAME_NS:
715: t = jj_consume_token(PNAME_NS);
716: {
717: if (true)
718: return resolvePName(t.image, t.beginLine,
719: t.beginColumn);
720: }
721: break;
722: default:
723: jj_la1[22] = jj_gen;
724: jj_consume_token(-1);
725: throw new ParseException();
726: }
727: throw new Error("Missing return statement in function");
728: }
729:
730: final public Node BlankNode() throws ParseException {
731: Token t = null;
732: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
733: case BLANK_NODE_LABEL:
734: t = jj_consume_token(BLANK_NODE_LABEL);
735: {
736: if (true)
737: return createBNode(t.image, t.beginLine,
738: t.beginColumn);
739: }
740: break;
741: case ANON:
742: jj_consume_token(ANON);
743: {
744: if (true)
745: return createBNode();
746: }
747: break;
748: default:
749: jj_la1[23] = jj_gen;
750: jj_consume_token(-1);
751: throw new ParseException();
752: }
753: throw new Error("Missing return statement in function");
754: }
755:
756: final public String IRI_REF() throws ParseException {
757: Token t;
758: t = jj_consume_token(IRIref);
759: {
760: if (true)
761: return resolveQuotedIRI(t.image, t.beginLine,
762: t.beginColumn);
763: }
764: throw new Error("Missing return statement in function");
765: }
766:
767: public TurtleParserTokenManager token_source;
768: JavaCharStream jj_input_stream;
769: public Token token, jj_nt;
770: private int jj_ntk;
771: private int jj_gen;
772: final private int[] jj_la1 = new int[24];
773: static private int[] jj_la1_0;
774: static private int[] jj_la1_1;
775: static private int[] jj_la1_2;
776: static {
777: jj_la1_0();
778: jj_la1_1();
779: jj_la1_2();
780: }
781:
782: private static void jj_la1_0() {
783: jj_la1_0 = new int[] { 0xe787c000, 0xe787c000, 0xc000,
784: 0xe7870000, 0xe0002000, 0x0, 0xe0002000, 0x0,
785: 0xe0002000, 0x0, 0xe7870000, 0xe7870000, 0xe7870000,
786: 0x0, 0xe7870000, 0xe7870000, 0x70000, 0x4000, 0x4000,
787: 0x4000, 0x7800000, 0xe0000000, 0xc0000000, 0x0, };
788: }
789:
790: private static void jj_la1_1() {
791: jj_la1_1 = new int[] { 0x15a3, 0x15a3, 0x0, 0x15a3, 0x20000,
792: 0x2000, 0x20000, 0x4000, 0x20000, 0x420, 0x15a3,
793: 0x15a3, 0x1183, 0x8000, 0x15a3, 0x1081, 0x0, 0x2000004,
794: 0x2000004, 0x4, 0x0, 0x0, 0x0, 0x1001, };
795: }
796:
797: private static void jj_la1_2() {
798: jj_la1_2 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
799: 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
800: 0x0, 0x0, 0x0, 0x0, 0x0, };
801: }
802:
803: public TurtleParser(java.io.InputStream stream) {
804: this (stream, null);
805: }
806:
807: public TurtleParser(java.io.InputStream stream, String encoding) {
808: try {
809: jj_input_stream = new JavaCharStream(stream, encoding, 1, 1);
810: } catch (java.io.UnsupportedEncodingException e) {
811: throw new RuntimeException(e);
812: }
813: token_source = new TurtleParserTokenManager(jj_input_stream);
814: token = new Token();
815: jj_ntk = -1;
816: jj_gen = 0;
817: for (int i = 0; i < 24; i++)
818: jj_la1[i] = -1;
819: }
820:
821: public void ReInit(java.io.InputStream stream) {
822: ReInit(stream, null);
823: }
824:
825: public void ReInit(java.io.InputStream stream, String encoding) {
826: try {
827: jj_input_stream.ReInit(stream, encoding, 1, 1);
828: } catch (java.io.UnsupportedEncodingException e) {
829: throw new RuntimeException(e);
830: }
831: token_source.ReInit(jj_input_stream);
832: token = new Token();
833: jj_ntk = -1;
834: jj_gen = 0;
835: for (int i = 0; i < 24; i++)
836: jj_la1[i] = -1;
837: }
838:
839: public TurtleParser(java.io.Reader stream) {
840: jj_input_stream = new JavaCharStream(stream, 1, 1);
841: token_source = new TurtleParserTokenManager(jj_input_stream);
842: token = new Token();
843: jj_ntk = -1;
844: jj_gen = 0;
845: for (int i = 0; i < 24; i++)
846: jj_la1[i] = -1;
847: }
848:
849: public void ReInit(java.io.Reader stream) {
850: jj_input_stream.ReInit(stream, 1, 1);
851: token_source.ReInit(jj_input_stream);
852: token = new Token();
853: jj_ntk = -1;
854: jj_gen = 0;
855: for (int i = 0; i < 24; i++)
856: jj_la1[i] = -1;
857: }
858:
859: public TurtleParser(TurtleParserTokenManager tm) {
860: token_source = tm;
861: token = new Token();
862: jj_ntk = -1;
863: jj_gen = 0;
864: for (int i = 0; i < 24; i++)
865: jj_la1[i] = -1;
866: }
867:
868: public void ReInit(TurtleParserTokenManager tm) {
869: token_source = tm;
870: token = new Token();
871: jj_ntk = -1;
872: jj_gen = 0;
873: for (int i = 0; i < 24; i++)
874: jj_la1[i] = -1;
875: }
876:
877: final private Token jj_consume_token(int kind)
878: throws ParseException {
879: Token oldToken;
880: if ((oldToken = token).next != null)
881: token = token.next;
882: else
883: token = token.next = token_source.getNextToken();
884: jj_ntk = -1;
885: if (token.kind == kind) {
886: jj_gen++;
887: return token;
888: }
889: token = oldToken;
890: jj_kind = kind;
891: throw generateParseException();
892: }
893:
894: final public Token getNextToken() {
895: if (token.next != null)
896: token = token.next;
897: else
898: token = token.next = token_source.getNextToken();
899: jj_ntk = -1;
900: jj_gen++;
901: return token;
902: }
903:
904: final public Token getToken(int index) {
905: Token t = token;
906: for (int i = 0; i < index; i++) {
907: if (t.next != null)
908: t = t.next;
909: else
910: t = t.next = token_source.getNextToken();
911: }
912: return t;
913: }
914:
915: final private int jj_ntk() {
916: if ((jj_nt = token.next) == null)
917: return (jj_ntk = (token.next = token_source.getNextToken()).kind);
918: else
919: return (jj_ntk = jj_nt.kind);
920: }
921:
922: private java.util.Vector jj_expentries = new java.util.Vector();
923: private int[] jj_expentry;
924: private int jj_kind = -1;
925:
926: public ParseException generateParseException() {
927: jj_expentries.removeAllElements();
928: boolean[] la1tokens = new boolean[66];
929: for (int i = 0; i < 66; i++) {
930: la1tokens[i] = false;
931: }
932: if (jj_kind >= 0) {
933: la1tokens[jj_kind] = true;
934: jj_kind = -1;
935: }
936: for (int i = 0; i < 24; i++) {
937: if (jj_la1[i] == jj_gen) {
938: for (int j = 0; j < 32; j++) {
939: if ((jj_la1_0[i] & (1 << j)) != 0) {
940: la1tokens[j] = true;
941: }
942: if ((jj_la1_1[i] & (1 << j)) != 0) {
943: la1tokens[32 + j] = true;
944: }
945: if ((jj_la1_2[i] & (1 << j)) != 0) {
946: la1tokens[64 + j] = true;
947: }
948: }
949: }
950: }
951: for (int i = 0; i < 66; i++) {
952: if (la1tokens[i]) {
953: jj_expentry = new int[1];
954: jj_expentry[0] = i;
955: jj_expentries.addElement(jj_expentry);
956: }
957: }
958: int[][] exptokseq = new int[jj_expentries.size()][];
959: for (int i = 0; i < jj_expentries.size(); i++) {
960: exptokseq[i] = (int[]) jj_expentries.elementAt(i);
961: }
962: return new ParseException(token, exptokseq, tokenImage);
963: }
964:
965: final public void enable_tracing() {
966: }
967:
968: final public void disable_tracing() {
969: }
970:
971: }
|