001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019:
020: /* Generated By:JavaCC: Do not edit this line. XMLFragmentParserTokenManager.java */
021: package org.openharmonise.commons.xml.parser;
022:
023: public class XMLFragmentParserTokenManager implements
024: XMLFragmentParserConstants {
025: public java.io.PrintStream debugStream = System.err;
026:
027: public void setDebugStream(java.io.PrintStream ds) {
028: debugStream = ds;
029: }
030:
031: private final int jjStopStringLiteralDfa_0(int pos, long active0) {
032: switch (pos) {
033: case 0:
034: if ((active0 & 0x10L) != 0L) {
035: jjmatchedKind = 13;
036: return 12;
037: }
038: return -1;
039: default:
040: return -1;
041: }
042: }
043:
044: private final int jjStartNfa_0(int pos, long active0) {
045: return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0),
046: pos + 1);
047: }
048:
049: private final int jjStopAtPos(int pos, int kind) {
050: jjmatchedKind = kind;
051: jjmatchedPos = pos;
052: return pos + 1;
053: }
054:
055: private final int jjStartNfaWithStates_0(int pos, int kind,
056: int state) {
057: jjmatchedKind = kind;
058: jjmatchedPos = pos;
059: try {
060: curChar = input_stream.readChar();
061: } catch (java.io.IOException e) {
062: return pos + 1;
063: }
064: return jjMoveNfa_0(state, pos + 1);
065: }
066:
067: private final int jjMoveStringLiteralDfa0_0() {
068: switch (curChar) {
069: case 47:
070: return jjMoveStringLiteralDfa1_0(0x10L);
071: case 60:
072: jjmatchedKind = 1;
073: return jjMoveStringLiteralDfa1_0(0x8L);
074: case 61:
075: return jjStopAtPos(0, 5);
076: case 62:
077: return jjStopAtPos(0, 2);
078: default:
079: return jjMoveNfa_0(0, 0);
080: }
081: }
082:
083: private final int jjMoveStringLiteralDfa1_0(long active0) {
084: try {
085: curChar = input_stream.readChar();
086: } catch (java.io.IOException e) {
087: jjStopStringLiteralDfa_0(0, active0);
088: return 1;
089: }
090: switch (curChar) {
091: case 47:
092: if ((active0 & 0x8L) != 0L)
093: return jjStopAtPos(1, 3);
094: break;
095: case 62:
096: if ((active0 & 0x10L) != 0L)
097: return jjStopAtPos(1, 4);
098: break;
099: default:
100: break;
101: }
102: return jjStartNfa_0(0, active0);
103: }
104:
105: private final void jjCheckNAdd(int state) {
106: if (jjrounds[state] != jjround) {
107: jjstateSet[jjnewStateCnt++] = state;
108: jjrounds[state] = jjround;
109: }
110: }
111:
112: private final void jjAddStates(int start, int end) {
113: do {
114: jjstateSet[jjnewStateCnt++] = jjnextStates[start];
115: } while (start++ != end);
116: }
117:
118: private final void jjCheckNAddTwoStates(int state1, int state2) {
119: jjCheckNAdd(state1);
120: jjCheckNAdd(state2);
121: }
122:
123: private final void jjCheckNAddStates(int start, int end) {
124: do {
125: jjCheckNAdd(jjnextStates[start]);
126: } while (start++ != end);
127: }
128:
129: private final void jjCheckNAddStates(int start) {
130: jjCheckNAdd(jjnextStates[start]);
131: jjCheckNAdd(jjnextStates[start + 1]);
132: }
133:
134: static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL,
135: 0xffffffffffffffffL };
136:
137: private final int jjMoveNfa_0(int startState, int curPos) {
138: int[] nextStates;
139: int startsAt = 0;
140: jjnewStateCnt = 13;
141: int i = 1;
142: jjstateSet[0] = startState;
143: int j, kind = 0x7fffffff;
144: for (;;) {
145: if (++jjround == 0x7fffffff)
146: ReInitRounds();
147: if (curChar < 64) {
148: long l = 1L << curChar;
149: MatchLoop: do {
150: switch (jjstateSet[--i]) {
151: case 0:
152: if ((0x8ffffffaffffd9ffL & l) != 0L) {
153: if (kind > 13)
154: kind = 13;
155: jjCheckNAdd(12);
156: } else if ((0x100002600L & l) != 0L) {
157: if (kind > 7)
158: kind = 7;
159: jjCheckNAdd(6);
160: } else if (curChar == 34)
161: jjCheckNAddTwoStates(1, 2);
162: if (curChar == 39)
163: jjCheckNAddTwoStates(4, 5);
164: break;
165: case 1:
166: if ((0xfffffffbffffffffL & l) != 0L)
167: jjCheckNAddTwoStates(1, 2);
168: break;
169: case 2:
170: if (curChar == 34 && kind > 6)
171: kind = 6;
172: break;
173: case 3:
174: if (curChar == 39)
175: jjCheckNAddTwoStates(4, 5);
176: break;
177: case 4:
178: if ((0xffffff7fffffffffL & l) != 0L)
179: jjCheckNAddTwoStates(4, 5);
180: break;
181: case 5:
182: if (curChar == 39 && kind > 6)
183: kind = 6;
184: break;
185: case 6:
186: if ((0x100002600L & l) == 0L)
187: break;
188: if (kind > 7)
189: kind = 7;
190: jjCheckNAdd(6);
191: break;
192: case 8:
193: if ((0x3ff600000000000L & l) == 0L)
194: break;
195: if (kind > 12)
196: kind = 12;
197: jjAddStates(0, 1);
198: break;
199: case 9:
200: if (curChar == 58)
201: jjstateSet[jjnewStateCnt++] = 10;
202: break;
203: case 11:
204: if ((0x3ff600000000000L & l) == 0L)
205: break;
206: if (kind > 12)
207: kind = 12;
208: jjstateSet[jjnewStateCnt++] = 11;
209: break;
210: case 12:
211: if ((0x8ffffffaffffd9ffL & l) == 0L)
212: break;
213: if (kind > 13)
214: kind = 13;
215: jjCheckNAdd(12);
216: break;
217: default:
218: break;
219: }
220: } while (i != startsAt);
221: } else if (curChar < 128) {
222: long l = 1L << (curChar & 077);
223: MatchLoop: do {
224: switch (jjstateSet[--i]) {
225: case 0:
226: if (kind > 13)
227: kind = 13;
228: jjCheckNAdd(12);
229: if ((0x7fffffe87fffffeL & l) != 0L) {
230: if (kind > 12)
231: kind = 12;
232: jjCheckNAddTwoStates(8, 9);
233: }
234: break;
235: case 1:
236: jjAddStates(2, 3);
237: break;
238: case 4:
239: jjAddStates(4, 5);
240: break;
241: case 7:
242: case 8:
243: if ((0x7fffffe87fffffeL & l) == 0L)
244: break;
245: if (kind > 12)
246: kind = 12;
247: jjCheckNAddTwoStates(8, 9);
248: break;
249: case 10:
250: case 11:
251: if ((0x7fffffe87fffffeL & l) == 0L)
252: break;
253: if (kind > 12)
254: kind = 12;
255: jjCheckNAdd(11);
256: break;
257: case 12:
258: if (kind > 13)
259: kind = 13;
260: jjCheckNAdd(12);
261: break;
262: default:
263: break;
264: }
265: } while (i != startsAt);
266: } else {
267: int i2 = (curChar & 0xff) >> 6;
268: long l2 = 1L << (curChar & 077);
269: MatchLoop: do {
270: switch (jjstateSet[--i]) {
271: case 0:
272: case 12:
273: if ((jjbitVec0[i2] & l2) == 0L)
274: break;
275: if (kind > 13)
276: kind = 13;
277: jjCheckNAdd(12);
278: break;
279: case 1:
280: if ((jjbitVec0[i2] & l2) != 0L)
281: jjAddStates(2, 3);
282: break;
283: case 4:
284: if ((jjbitVec0[i2] & l2) != 0L)
285: jjAddStates(4, 5);
286: break;
287: default:
288: break;
289: }
290: } while (i != startsAt);
291: }
292: if (kind != 0x7fffffff) {
293: jjmatchedKind = kind;
294: jjmatchedPos = curPos;
295: kind = 0x7fffffff;
296: }
297: ++curPos;
298: if ((i = jjnewStateCnt) == (startsAt = 13 - (jjnewStateCnt = startsAt)))
299: return curPos;
300: try {
301: curChar = input_stream.readChar();
302: } catch (java.io.IOException e) {
303: return curPos;
304: }
305: }
306: }
307:
308: static final int[] jjnextStates = { 8, 9, 1, 2, 4, 5, };
309: public static final String[] jjstrLiteralImages = { "", "\74",
310: "\76", "\74\57", "\57\76", "\75", null, null, null, null,
311: null, null, null, null, };
312: public static final String[] lexStateNames = { "DEFAULT", };
313: private SimpleCharStream input_stream;
314: private final int[] jjrounds = new int[13];
315: private final int[] jjstateSet = new int[26];
316: protected char curChar;
317:
318: public XMLFragmentParserTokenManager(SimpleCharStream stream) {
319: if (SimpleCharStream.staticFlag)
320: throw new Error(
321: "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
322: input_stream = stream;
323: }
324:
325: public XMLFragmentParserTokenManager(SimpleCharStream stream,
326: int lexState) {
327: this (stream);
328: SwitchTo(lexState);
329: }
330:
331: public void ReInit(SimpleCharStream stream) {
332: jjmatchedPos = jjnewStateCnt = 0;
333: curLexState = defaultLexState;
334: input_stream = stream;
335: ReInitRounds();
336: }
337:
338: private final void ReInitRounds() {
339: int i;
340: jjround = 0x80000001;
341: for (i = 13; i-- > 0;)
342: jjrounds[i] = 0x80000000;
343: }
344:
345: public void ReInit(SimpleCharStream stream, int lexState) {
346: ReInit(stream);
347: SwitchTo(lexState);
348: }
349:
350: public void SwitchTo(int lexState) {
351: if (lexState >= 1 || lexState < 0)
352: throw new TokenMgrError(
353: "Error: Ignoring invalid lexical state : "
354: + lexState + ". State unchanged.",
355: TokenMgrError.INVALID_LEXICAL_STATE);
356: else
357: curLexState = lexState;
358: }
359:
360: private final Token jjFillToken() {
361: Token t = Token.newToken(jjmatchedKind);
362: t.kind = jjmatchedKind;
363: String im = jjstrLiteralImages[jjmatchedKind];
364: t.image = (im == null) ? input_stream.GetImage() : im;
365: t.beginLine = input_stream.getBeginLine();
366: t.beginColumn = input_stream.getBeginColumn();
367: t.endLine = input_stream.getEndLine();
368: t.endColumn = input_stream.getEndColumn();
369: return t;
370: }
371:
372: int curLexState = 0;
373: int defaultLexState = 0;
374: int jjnewStateCnt;
375: int jjround;
376: int jjmatchedPos;
377: int jjmatchedKind;
378:
379: public final Token getNextToken() {
380: int kind;
381: Token specialToken = null;
382: Token matchedToken;
383: int curPos = 0;
384:
385: EOFLoop: for (;;) {
386: try {
387: curChar = input_stream.BeginToken();
388: } catch (java.io.IOException e) {
389: jjmatchedKind = 0;
390: matchedToken = jjFillToken();
391: return matchedToken;
392: }
393:
394: jjmatchedKind = 0x7fffffff;
395: jjmatchedPos = 0;
396: curPos = jjMoveStringLiteralDfa0_0();
397: if (jjmatchedKind != 0x7fffffff) {
398: if (jjmatchedPos + 1 < curPos)
399: input_stream.backup(curPos - jjmatchedPos - 1);
400: matchedToken = jjFillToken();
401: return matchedToken;
402: }
403: int error_line = input_stream.getEndLine();
404: int error_column = input_stream.getEndColumn();
405: String error_after = null;
406: boolean EOFSeen = false;
407: try {
408: input_stream.readChar();
409: input_stream.backup(1);
410: } catch (java.io.IOException e1) {
411: EOFSeen = true;
412: error_after = curPos <= 1 ? "" : input_stream
413: .GetImage();
414: if (curChar == '\n' || curChar == '\r') {
415: error_line++;
416: error_column = 0;
417: } else
418: error_column++;
419: }
420: if (!EOFSeen) {
421: input_stream.backup(1);
422: error_after = curPos <= 1 ? "" : input_stream
423: .GetImage();
424: }
425: throw new TokenMgrError(EOFSeen, curLexState, error_line,
426: error_column, error_after, curChar,
427: TokenMgrError.LEXICAL_ERROR);
428: }
429: }
430:
431: }
|