001: /* Generated By:JavaCC: Do not edit this line. SCDParser.java */
002: package com.sun.xml.xsom.impl.scd;
003:
004: import java.util.*;
005: import java.io.*;
006: import com.sun.xml.xsom.impl.UName;
007: import javax.xml.namespace.*;
008:
009: public class SCDParser implements SCDParserConstants {
010: private NamespaceContext nsc;
011:
012: public SCDParser(String text, NamespaceContext nsc) {
013: this (new StringReader(text));
014: this .nsc = nsc;
015: }
016:
017: private String trim(String s) {
018: return s.substring(1, s.length() - 1);
019: }
020:
021: private String resolvePrefix(String prefix) throws ParseException {
022: try {
023: String r = nsc.getNamespaceURI(prefix);
024: // grrr!!
025: if (prefix.equals(""))
026: return r;
027: if (!r.equals(""))
028: return r;
029: } catch (IllegalArgumentException e) {
030: ; // report an error
031: }
032: throw new ParseException("Unbound prefix: " + prefix);
033: }
034:
035: // "[^:]+"
036: final public UName QName() throws ParseException {
037: Token p, l = null;
038: p = jj_consume_token(NCNAME);
039: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
040: case 15:
041: jj_consume_token(15);
042: l = jj_consume_token(NCNAME);
043: break;
044: default:
045: jj_la1[0] = jj_gen;
046: ;
047: }
048: if (l == null) {
049: if (true)
050: return new UName(resolvePrefix(""), p.image);
051: } else {
052: if (true)
053: return new UName(resolvePrefix(p.image), l.image);
054: }
055: throw new Error("Missing return statement in function");
056: }
057:
058: final public String Prefix() throws ParseException {
059: Token p;
060: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
061: case NCNAME:
062: p = jj_consume_token(NCNAME);
063: {
064: if (true)
065: return resolvePrefix(p.image);
066: }
067: break;
068: default:
069: jj_la1[1] = jj_gen;
070: {
071: if (true)
072: return resolvePrefix("");
073: }
074: }
075: throw new Error("Missing return statement in function");
076: }
077:
078: final public List RelativeSchemaComponentPath()
079: throws ParseException {
080: List steps = new ArrayList();
081: Step s;
082: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
083: case 16:
084: case 17:
085: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
086: case 16:
087: jj_consume_token(16);
088: steps.add(new Step.Any(Axis.ROOT));
089: break;
090: case 17:
091: jj_consume_token(17);
092: steps.add(new Step.Any(Axis.DESCENDANTS));
093: break;
094: default:
095: jj_la1[2] = jj_gen;
096: jj_consume_token(-1);
097: throw new ParseException();
098: }
099: break;
100: default:
101: jj_la1[3] = jj_gen;
102: ;
103: }
104: s = Step();
105: steps.add(s);
106: label_1: while (true) {
107: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
108: case 16:
109: case 17:
110: ;
111: break;
112: default:
113: jj_la1[4] = jj_gen;
114: break label_1;
115: }
116: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
117: case 16:
118: jj_consume_token(16);
119: break;
120: case 17:
121: jj_consume_token(17);
122: steps.add(new Step.Any(Axis.DESCENDANTS));
123: break;
124: default:
125: jj_la1[5] = jj_gen;
126: jj_consume_token(-1);
127: throw new ParseException();
128: }
129: s = Step();
130: steps.add(s);
131: }
132: {
133: if (true)
134: return steps;
135: }
136: throw new Error("Missing return statement in function");
137: }
138:
139: final public Step Step() throws ParseException {
140: Step s;
141: String p;
142: Token n;
143: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
144: case 18:
145: case 19:
146: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
147: case 18:
148: jj_consume_token(18);
149: break;
150: case 19:
151: jj_consume_token(19);
152: break;
153: default:
154: jj_la1[6] = jj_gen;
155: jj_consume_token(-1);
156: throw new ParseException();
157: }
158: s = NameOrWildcard(Axis.ATTRIBUTE);
159: break;
160: case NCNAME:
161: case 20:
162: case 45:
163: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
164: case 20:
165: jj_consume_token(20);
166: break;
167: default:
168: jj_la1[7] = jj_gen;
169: ;
170: }
171: s = NameOrWildcard(Axis.ELEMENT);
172: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
173: case NUMBER:
174: Predicate(s);
175: break;
176: default:
177: jj_la1[8] = jj_gen;
178: ;
179: }
180: break;
181: case 21:
182: jj_consume_token(21);
183: s = NameOrWildcard(Axis.SUBSTITUTION_GROUP);
184: break;
185: case 22:
186: case 23:
187: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
188: case 22:
189: jj_consume_token(22);
190: break;
191: case 23:
192: jj_consume_token(23);
193: break;
194: default:
195: jj_la1[9] = jj_gen;
196: jj_consume_token(-1);
197: throw new ParseException();
198: }
199: s = NameOrWildcardOrAnonymous(Axis.TYPE_DEFINITION);
200: break;
201: case 24:
202: jj_consume_token(24);
203: s = NameOrWildcard(Axis.BASETYPE);
204: break;
205: case 25:
206: jj_consume_token(25);
207: s = NameOrWildcard(Axis.PRIMITIVE_TYPE);
208: break;
209: case 26:
210: jj_consume_token(26);
211: s = NameOrWildcardOrAnonymous(Axis.ITEM_TYPE);
212: break;
213: case 27:
214: jj_consume_token(27);
215: s = NameOrWildcardOrAnonymous(Axis.MEMBER_TYPE);
216: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
217: case NUMBER:
218: Predicate(s);
219: break;
220: default:
221: jj_la1[10] = jj_gen;
222: ;
223: }
224: break;
225: case 28:
226: jj_consume_token(28);
227: s = NameOrWildcardOrAnonymous(Axis.SCOPE);
228: break;
229: case 29:
230: jj_consume_token(29);
231: s = NameOrWildcard(Axis.ATTRIBUTE_GROUP);
232: break;
233: case 30:
234: jj_consume_token(30);
235: s = NameOrWildcard(Axis.MODEL_GROUP_DECL);
236: break;
237: case 31:
238: jj_consume_token(31);
239: s = NameOrWildcard(Axis.IDENTITY_CONSTRAINT);
240: break;
241: case 32:
242: jj_consume_token(32);
243: s = NameOrWildcard(Axis.REFERENCED_KEY);
244: break;
245: case 33:
246: jj_consume_token(33);
247: s = NameOrWildcard(Axis.NOTATION);
248: break;
249: case 34:
250: jj_consume_token(34);
251: s = new Step.Any(Axis.MODELGROUP_SEQUENCE);
252: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
253: case NUMBER:
254: Predicate(s);
255: break;
256: default:
257: jj_la1[11] = jj_gen;
258: ;
259: }
260: break;
261: case 35:
262: jj_consume_token(35);
263: s = new Step.Any(Axis.MODELGROUP_CHOICE);
264: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
265: case NUMBER:
266: Predicate(s);
267: break;
268: default:
269: jj_la1[12] = jj_gen;
270: ;
271: }
272: break;
273: case 36:
274: jj_consume_token(36);
275: s = new Step.Any(Axis.MODELGROUP_ALL);
276: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
277: case NUMBER:
278: Predicate(s);
279: break;
280: default:
281: jj_la1[13] = jj_gen;
282: ;
283: }
284: break;
285: case 37:
286: jj_consume_token(37);
287: s = new Step.Any(Axis.MODELGROUP_ANY);
288: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
289: case NUMBER:
290: Predicate(s);
291: break;
292: default:
293: jj_la1[14] = jj_gen;
294: ;
295: }
296: break;
297: case 38:
298: jj_consume_token(38);
299: s = new Step.Any(Axis.WILDCARD);
300: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
301: case NUMBER:
302: Predicate(s);
303: break;
304: default:
305: jj_la1[15] = jj_gen;
306: ;
307: }
308: break;
309: case 39:
310: jj_consume_token(39);
311: s = new Step.Any(Axis.ATTRIBUTE_WILDCARD);
312: break;
313: case 40:
314: jj_consume_token(40);
315: s = new Step.Any(Axis.FACET);
316: break;
317: case 41:
318: jj_consume_token(41);
319: n = jj_consume_token(FACETNAME);
320: s = new Step.Facet(Axis.FACET, n.image);
321: break;
322: case 42:
323: jj_consume_token(42);
324: s = new Step.Any(Axis.DESCENDANTS);
325: break;
326: case 43:
327: jj_consume_token(43);
328: p = Prefix();
329: s = new Step.Schema(Axis.X_SCHEMA, p);
330: break;
331: case 44:
332: jj_consume_token(44);
333: s = new Step.Any(Axis.X_SCHEMA);
334: break;
335: default:
336: jj_la1[16] = jj_gen;
337: jj_consume_token(-1);
338: throw new ParseException();
339: }
340: {
341: if (true)
342: return s;
343: }
344: throw new Error("Missing return statement in function");
345: }
346:
347: final public Step NameOrWildcard(Axis a) throws ParseException {
348: UName un;
349: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
350: case NCNAME:
351: un = QName();
352: {
353: if (true)
354: return new Step.Named(a, un);
355: }
356: break;
357: case 45:
358: jj_consume_token(45);
359: {
360: if (true)
361: return new Step.Any(a);
362: }
363: break;
364: default:
365: jj_la1[17] = jj_gen;
366: jj_consume_token(-1);
367: throw new ParseException();
368: }
369: throw new Error("Missing return statement in function");
370: }
371:
372: final public Step NameOrWildcardOrAnonymous(Axis a)
373: throws ParseException {
374: UName un;
375: switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
376: case NCNAME:
377: un = QName();
378: {
379: if (true)
380: return new Step.Named(a, un);
381: }
382: break;
383: case 45:
384: jj_consume_token(45);
385: {
386: if (true)
387: return new Step.Any(a);
388: }
389: break;
390: case 46:
391: jj_consume_token(46);
392: {
393: if (true)
394: return new Step.AnonymousType(a);
395: }
396: break;
397: default:
398: jj_la1[18] = jj_gen;
399: jj_consume_token(-1);
400: throw new ParseException();
401: }
402: throw new Error("Missing return statement in function");
403: }
404:
405: final public int Predicate(Step s) throws ParseException {
406: Token t;
407: t = jj_consume_token(NUMBER);
408: {
409: if (true)
410: return s.predicate = Integer.parseInt(trim(t.image));
411: }
412: throw new Error("Missing return statement in function");
413: }
414:
415: public SCDParserTokenManager token_source;
416: SimpleCharStream jj_input_stream;
417: public Token token, jj_nt;
418: private int jj_ntk;
419: private int jj_gen;
420: final private int[] jj_la1 = new int[19];
421: static private int[] jj_la1_0;
422: static private int[] jj_la1_1;
423: static {
424: jj_la1_0();
425: jj_la1_1();
426: }
427:
428: private static void jj_la1_0() {
429: jj_la1_0 = new int[] { 0x8000, 0x1000, 0x30000, 0x30000,
430: 0x30000, 0x30000, 0xc0000, 0x100000, 0x2000, 0xc00000,
431: 0x2000, 0x2000, 0x2000, 0x2000, 0x2000, 0x2000,
432: 0xfffc1000, 0x1000, 0x1000, };
433: }
434:
435: private static void jj_la1_1() {
436: jj_la1_1 = new int[] { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
437: 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3fff, 0x2000,
438: 0x6000, };
439: }
440:
441: public SCDParser(java.io.InputStream stream) {
442: this (stream, null);
443: }
444:
445: public SCDParser(java.io.InputStream stream, String encoding) {
446: try {
447: jj_input_stream = new SimpleCharStream(stream, encoding, 1,
448: 1);
449: } catch (java.io.UnsupportedEncodingException e) {
450: throw new RuntimeException(e);
451: }
452: token_source = new SCDParserTokenManager(jj_input_stream);
453: token = new Token();
454: jj_ntk = -1;
455: jj_gen = 0;
456: for (int i = 0; i < 19; i++)
457: jj_la1[i] = -1;
458: }
459:
460: public void ReInit(java.io.InputStream stream) {
461: ReInit(stream, null);
462: }
463:
464: public void ReInit(java.io.InputStream stream, String encoding) {
465: try {
466: jj_input_stream.ReInit(stream, encoding, 1, 1);
467: } catch (java.io.UnsupportedEncodingException e) {
468: throw new RuntimeException(e);
469: }
470: token_source.ReInit(jj_input_stream);
471: token = new Token();
472: jj_ntk = -1;
473: jj_gen = 0;
474: for (int i = 0; i < 19; i++)
475: jj_la1[i] = -1;
476: }
477:
478: public SCDParser(java.io.Reader stream) {
479: jj_input_stream = new SimpleCharStream(stream, 1, 1);
480: token_source = new SCDParserTokenManager(jj_input_stream);
481: token = new Token();
482: jj_ntk = -1;
483: jj_gen = 0;
484: for (int i = 0; i < 19; i++)
485: jj_la1[i] = -1;
486: }
487:
488: public void ReInit(java.io.Reader stream) {
489: jj_input_stream.ReInit(stream, 1, 1);
490: token_source.ReInit(jj_input_stream);
491: token = new Token();
492: jj_ntk = -1;
493: jj_gen = 0;
494: for (int i = 0; i < 19; i++)
495: jj_la1[i] = -1;
496: }
497:
498: public SCDParser(SCDParserTokenManager tm) {
499: token_source = tm;
500: token = new Token();
501: jj_ntk = -1;
502: jj_gen = 0;
503: for (int i = 0; i < 19; i++)
504: jj_la1[i] = -1;
505: }
506:
507: public void ReInit(SCDParserTokenManager tm) {
508: token_source = tm;
509: token = new Token();
510: jj_ntk = -1;
511: jj_gen = 0;
512: for (int i = 0; i < 19; i++)
513: jj_la1[i] = -1;
514: }
515:
516: final private Token jj_consume_token(int kind)
517: throws ParseException {
518: Token oldToken;
519: if ((oldToken = token).next != null)
520: token = token.next;
521: else
522: token = token.next = token_source.getNextToken();
523: jj_ntk = -1;
524: if (token.kind == kind) {
525: jj_gen++;
526: return token;
527: }
528: token = oldToken;
529: jj_kind = kind;
530: throw generateParseException();
531: }
532:
533: final public Token getNextToken() {
534: if (token.next != null)
535: token = token.next;
536: else
537: token = token.next = token_source.getNextToken();
538: jj_ntk = -1;
539: jj_gen++;
540: return token;
541: }
542:
543: final public Token getToken(int index) {
544: Token t = token;
545: for (int i = 0; i < index; i++) {
546: if (t.next != null)
547: t = t.next;
548: else
549: t = t.next = token_source.getNextToken();
550: }
551: return t;
552: }
553:
554: final private int jj_ntk() {
555: if ((jj_nt = token.next) == null)
556: return (jj_ntk = (token.next = token_source.getNextToken()).kind);
557: else
558: return (jj_ntk = jj_nt.kind);
559: }
560:
561: private java.util.Vector jj_expentries = new java.util.Vector();
562: private int[] jj_expentry;
563: private int jj_kind = -1;
564:
565: public ParseException generateParseException() {
566: jj_expentries.removeAllElements();
567: boolean[] la1tokens = new boolean[47];
568: for (int i = 0; i < 47; i++) {
569: la1tokens[i] = false;
570: }
571: if (jj_kind >= 0) {
572: la1tokens[jj_kind] = true;
573: jj_kind = -1;
574: }
575: for (int i = 0; i < 19; i++) {
576: if (jj_la1[i] == jj_gen) {
577: for (int j = 0; j < 32; j++) {
578: if ((jj_la1_0[i] & (1 << j)) != 0) {
579: la1tokens[j] = true;
580: }
581: if ((jj_la1_1[i] & (1 << j)) != 0) {
582: la1tokens[32 + j] = true;
583: }
584: }
585: }
586: }
587: for (int i = 0; i < 47; i++) {
588: if (la1tokens[i]) {
589: jj_expentry = new int[1];
590: jj_expentry[0] = i;
591: jj_expentries.addElement(jj_expentry);
592: }
593: }
594: int[][] exptokseq = new int[jj_expentries.size()][];
595: for (int i = 0; i < jj_expentries.size(); i++) {
596: exptokseq[i] = (int[]) jj_expentries.elementAt(i);
597: }
598: return new ParseException(token, exptokseq, tokenImage);
599: }
600:
601: final public void enable_tracing() {
602: }
603:
604: final public void disable_tracing() {
605: }
606:
607: }
|