001: /* Generated By:JavaCC: Do not edit this line. UtfParserTokenManager.java */
002: package org.zaval.tools.i18n.translator;
003:
004: import java.io.*;
005: import java.util.*;
006:
007: public class UtfParserTokenManager implements UtfParserConstants {
008: public java.io.PrintStream debugStream = System.out;
009:
010: public void setDebugStream(java.io.PrintStream ds) {
011: debugStream = ds;
012: }
013:
014: private final int jjStopStringLiteralDfa_0(int pos, long active0) {
015: switch (pos) {
016: default:
017: return -1;
018: }
019: }
020:
021: private final int jjStartNfa_0(int pos, long active0) {
022: return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0),
023: pos + 1);
024: }
025:
026: private final int jjStopAtPos(int pos, int kind) {
027: jjmatchedKind = kind;
028: jjmatchedPos = pos;
029: return pos + 1;
030: }
031:
032: private final int jjStartNfaWithStates_0(int pos, int kind,
033: int state) {
034: jjmatchedKind = kind;
035: jjmatchedPos = pos;
036: try {
037: curChar = input_stream.readChar();
038: } catch (java.io.IOException e) {
039: return pos + 1;
040: }
041: return jjMoveNfa_0(state, pos + 1);
042: }
043:
044: private final int jjMoveStringLiteralDfa0_0() {
045: switch (curChar) {
046: case 35:
047: return jjStopAtPos(0, 6);
048: case 58:
049: return jjStopAtPos(0, 11);
050: case 61:
051: return jjStopAtPos(0, 10);
052: case 75:
053: return jjMoveStringLiteralDfa1_0(0x200L);
054: default:
055: return jjMoveNfa_0(0, 0);
056: }
057: }
058:
059: private final int jjMoveStringLiteralDfa1_0(long active0) {
060: try {
061: curChar = input_stream.readChar();
062: } catch (java.io.IOException e) {
063: jjStopStringLiteralDfa_0(0, active0);
064: return 1;
065: }
066: switch (curChar) {
067: case 69:
068: return jjMoveStringLiteralDfa2_0(active0, 0x200L);
069: default:
070: break;
071: }
072: return jjStartNfa_0(0, active0);
073: }
074:
075: private final int jjMoveStringLiteralDfa2_0(long old0, long active0) {
076: if (((active0 &= old0)) == 0L)
077: return jjStartNfa_0(0, old0);
078: try {
079: curChar = input_stream.readChar();
080: } catch (java.io.IOException e) {
081: jjStopStringLiteralDfa_0(1, active0);
082: return 2;
083: }
084: switch (curChar) {
085: case 89:
086: if ((active0 & 0x200L) != 0L)
087: return jjStopAtPos(2, 9);
088: break;
089: default:
090: break;
091: }
092: return jjStartNfa_0(1, active0);
093: }
094:
095: private final void jjCheckNAdd(int state) {
096: if (jjrounds[state] != jjround) {
097: jjstateSet[jjnewStateCnt++] = state;
098: jjrounds[state] = jjround;
099: }
100: }
101:
102: private final void jjAddStates(int start, int end) {
103: do {
104: jjstateSet[jjnewStateCnt++] = jjnextStates[start];
105: } while (start++ != end);
106: }
107:
108: private final void jjCheckNAddTwoStates(int state1, int state2) {
109: jjCheckNAdd(state1);
110: jjCheckNAdd(state2);
111: }
112:
113: private final void jjCheckNAddStates(int start, int end) {
114: do {
115: jjCheckNAdd(jjnextStates[start]);
116: } while (start++ != end);
117: }
118:
119: private final void jjCheckNAddStates(int start) {
120: jjCheckNAdd(jjnextStates[start]);
121: jjCheckNAdd(jjnextStates[start + 1]);
122: }
123:
124: static final long[] jjbitVec0 = { 0xfffffffffffffffeL,
125: 0xffffffffffffffffL, 0xffffffffffffffffL,
126: 0xffffffffffffffffL };
127: static final long[] jjbitVec2 = { 0x0L, 0x0L, 0xffffffffffffffffL,
128: 0xffffffffffffffffL };
129:
130: private final int jjMoveNfa_0(int startState, int curPos) {
131: int[] nextStates;
132: int startsAt = 0;
133: jjnewStateCnt = 10;
134: int i = 1;
135: jjstateSet[0] = startState;
136: int j, kind = 0x7fffffff;
137: for (;;) {
138: if (++jjround == 0x7fffffff)
139: ReInitRounds();
140: if (curChar < 64) {
141: long l = 1L << curChar;
142: MatchLoop: do {
143: switch (jjstateSet[--i]) {
144: case 0:
145: if (curChar == 39)
146: jjCheckNAddStates(0, 2);
147: else if (curChar == 34)
148: jjCheckNAddStates(3, 5);
149: break;
150: case 1:
151: if ((0xfffffffbffffffffL & l) != 0L)
152: jjCheckNAddStates(3, 5);
153: break;
154: case 3:
155: if ((0x8400000000L & l) != 0L)
156: jjCheckNAddStates(3, 5);
157: break;
158: case 4:
159: if (curChar == 34 && kind > 12)
160: kind = 12;
161: break;
162: case 5:
163: if (curChar == 39)
164: jjCheckNAddStates(0, 2);
165: break;
166: case 6:
167: if ((0xfffffffbffffffffL & l) != 0L)
168: jjCheckNAddStates(0, 2);
169: break;
170: case 8:
171: if ((0x8400000000L & l) != 0L)
172: jjCheckNAddStates(0, 2);
173: break;
174: case 9:
175: if (curChar == 39 && kind > 13)
176: kind = 13;
177: break;
178: default:
179: break;
180: }
181: } while (i != startsAt);
182: } else if (curChar < 128) {
183: long l = 1L << (curChar & 077);
184: MatchLoop: do {
185: switch (jjstateSet[--i]) {
186: case 1:
187: if ((0xffffffffefffffffL & l) != 0L)
188: jjCheckNAddStates(3, 5);
189: break;
190: case 2:
191: if (curChar == 92)
192: jjstateSet[jjnewStateCnt++] = 3;
193: break;
194: case 3:
195: if (curChar == 92)
196: jjCheckNAddStates(3, 5);
197: break;
198: case 6:
199: if ((0xffffffffefffffffL & l) != 0L)
200: jjCheckNAddStates(0, 2);
201: break;
202: case 7:
203: if (curChar == 92)
204: jjstateSet[jjnewStateCnt++] = 8;
205: break;
206: case 8:
207: if (curChar == 92)
208: jjCheckNAddStates(0, 2);
209: break;
210: default:
211: break;
212: }
213: } while (i != startsAt);
214: } else {
215: int hiByte = (int) (curChar >> 8);
216: int i1 = hiByte >> 6;
217: long l1 = 1L << (hiByte & 077);
218: int i2 = (curChar & 0xff) >> 6;
219: long l2 = 1L << (curChar & 077);
220: MatchLoop: do {
221: switch (jjstateSet[--i]) {
222: case 1:
223: if (jjCanMove_0(hiByte, i1, i2, l1, l2))
224: jjAddStates(3, 5);
225: break;
226: case 6:
227: if (jjCanMove_0(hiByte, i1, i2, l1, l2))
228: jjAddStates(0, 2);
229: break;
230: default:
231: break;
232: }
233: } while (i != startsAt);
234: }
235: if (kind != 0x7fffffff) {
236: jjmatchedKind = kind;
237: jjmatchedPos = curPos;
238: kind = 0x7fffffff;
239: }
240: ++curPos;
241: if ((i = jjnewStateCnt) == (startsAt = 10 - (jjnewStateCnt = startsAt)))
242: return curPos;
243: try {
244: curChar = input_stream.readChar();
245: } catch (java.io.IOException e) {
246: return curPos;
247: }
248: }
249: }
250:
251: private final int jjMoveStringLiteralDfa0_1() {
252: return jjMoveNfa_1(0, 0);
253: }
254:
255: private final int jjMoveNfa_1(int startState, int curPos) {
256: int[] nextStates;
257: int startsAt = 0;
258: jjnewStateCnt = 3;
259: int i = 1;
260: jjstateSet[0] = startState;
261: int j, kind = 0x7fffffff;
262: for (;;) {
263: if (++jjround == 0x7fffffff)
264: ReInitRounds();
265: if (curChar < 64) {
266: long l = 1L << curChar;
267: MatchLoop: do {
268: switch (jjstateSet[--i]) {
269: case 0:
270: if ((0x2400L & l) != 0L) {
271: if (kind > 7)
272: kind = 7;
273: }
274: if (curChar == 13)
275: jjstateSet[jjnewStateCnt++] = 1;
276: break;
277: case 1:
278: if (curChar == 10 && kind > 7)
279: kind = 7;
280: break;
281: case 2:
282: if (curChar == 13)
283: jjstateSet[jjnewStateCnt++] = 1;
284: break;
285: default:
286: break;
287: }
288: } while (i != startsAt);
289: } else if (curChar < 128) {
290: long l = 1L << (curChar & 077);
291: MatchLoop: do {
292: switch (jjstateSet[--i]) {
293: default:
294: break;
295: }
296: } while (i != startsAt);
297: } else {
298: int hiByte = (int) (curChar >> 8);
299: int i1 = hiByte >> 6;
300: long l1 = 1L << (hiByte & 077);
301: int i2 = (curChar & 0xff) >> 6;
302: long l2 = 1L << (curChar & 077);
303: MatchLoop: do {
304: switch (jjstateSet[--i]) {
305: default:
306: break;
307: }
308: } while (i != startsAt);
309: }
310: if (kind != 0x7fffffff) {
311: jjmatchedKind = kind;
312: jjmatchedPos = curPos;
313: kind = 0x7fffffff;
314: }
315: ++curPos;
316: if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
317: return curPos;
318: try {
319: curChar = input_stream.readChar();
320: } catch (java.io.IOException e) {
321: return curPos;
322: }
323: }
324: }
325:
326: static final int[] jjnextStates = { 6, 7, 9, 1, 2, 4, };
327:
328: private static final boolean jjCanMove_0(int hiByte, int i1,
329: int i2, long l1, long l2) {
330: switch (hiByte) {
331: case 0:
332: return ((jjbitVec2[i2] & l2) != 0L);
333: default:
334: if ((jjbitVec0[i1] & l1) != 0L)
335: return true;
336: return false;
337: }
338: }
339:
340: public static final String[] jjstrLiteralImages = { "", null, null,
341: null, null, null, null, null, null, "\113\105\131", "\75",
342: "\72", null, null, };
343: public static final String[] lexStateNames = { "DEFAULT",
344: "IN_SINGLE_LINE_COMMENT", };
345: public static final int[] jjnewLexState = { -1, -1, -1, -1, -1, -1,
346: 1, 0, -1, -1, -1, -1, -1, -1, };
347: static final long[] jjtoToken = { 0x3e01L, };
348: static final long[] jjtoSkip = { 0xbeL, };
349: static final long[] jjtoSpecial = { 0x80L, };
350: static final long[] jjtoMore = { 0x140L, };
351: protected JavaCharStream input_stream;
352: private final int[] jjrounds = new int[10];
353: private final int[] jjstateSet = new int[20];
354: StringBuffer image;
355: int jjimageLen;
356: int lengthOfMatch;
357: protected char curChar;
358:
359: public UtfParserTokenManager(JavaCharStream stream) {
360: if (JavaCharStream.staticFlag)
361: throw new Error(
362: "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
363: input_stream = stream;
364: }
365:
366: public UtfParserTokenManager(JavaCharStream stream, int lexState) {
367: this (stream);
368: SwitchTo(lexState);
369: }
370:
371: public void ReInit(JavaCharStream stream) {
372: jjmatchedPos = jjnewStateCnt = 0;
373: curLexState = defaultLexState;
374: input_stream = stream;
375: ReInitRounds();
376: }
377:
378: private final void ReInitRounds() {
379: int i;
380: jjround = 0x80000001;
381: for (i = 10; i-- > 0;)
382: jjrounds[i] = 0x80000000;
383: }
384:
385: public void ReInit(JavaCharStream stream, int lexState) {
386: ReInit(stream);
387: SwitchTo(lexState);
388: }
389:
390: public void SwitchTo(int lexState) {
391: if (lexState >= 2 || lexState < 0)
392: throw new TokenMgrError(
393: "Error: Ignoring invalid lexical state : "
394: + lexState + ". State unchanged.",
395: TokenMgrError.INVALID_LEXICAL_STATE);
396: else
397: curLexState = lexState;
398: }
399:
400: protected Token jjFillToken() {
401: Token t = Token.newToken(jjmatchedKind);
402: t.kind = jjmatchedKind;
403: String im = jjstrLiteralImages[jjmatchedKind];
404: t.image = (im == null) ? input_stream.GetImage() : im;
405: t.beginLine = input_stream.getBeginLine();
406: t.beginColumn = input_stream.getBeginColumn();
407: t.endLine = input_stream.getEndLine();
408: t.endColumn = input_stream.getEndColumn();
409: return t;
410: }
411:
412: int curLexState = 0;
413: int defaultLexState = 0;
414: int jjnewStateCnt;
415: int jjround;
416: int jjmatchedPos;
417: int jjmatchedKind;
418:
419: public Token getNextToken() {
420: int kind;
421: Token specialToken = null;
422: Token matchedToken;
423: int curPos = 0;
424:
425: EOFLoop: for (;;) {
426: try {
427: curChar = input_stream.BeginToken();
428: } catch (java.io.IOException e) {
429: jjmatchedKind = 0;
430: matchedToken = jjFillToken();
431: matchedToken.specialToken = specialToken;
432: return matchedToken;
433: }
434: image = null;
435: jjimageLen = 0;
436:
437: for (;;) {
438: switch (curLexState) {
439: case 0:
440: try {
441: input_stream.backup(0);
442: while (curChar <= 32
443: && (0x100003600L & (1L << curChar)) != 0L)
444: curChar = input_stream.BeginToken();
445: } catch (java.io.IOException e1) {
446: continue EOFLoop;
447: }
448: jjmatchedKind = 0x7fffffff;
449: jjmatchedPos = 0;
450: curPos = jjMoveStringLiteralDfa0_0();
451: break;
452: case 1:
453: jjmatchedKind = 0x7fffffff;
454: jjmatchedPos = 0;
455: curPos = jjMoveStringLiteralDfa0_1();
456: if (jjmatchedPos == 0 && jjmatchedKind > 8) {
457: jjmatchedKind = 8;
458: }
459: break;
460: }
461: if (jjmatchedKind != 0x7fffffff) {
462: if (jjmatchedPos + 1 < curPos)
463: input_stream.backup(curPos - jjmatchedPos - 1);
464: if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
465: matchedToken = jjFillToken();
466: matchedToken.specialToken = specialToken;
467: if (jjnewLexState[jjmatchedKind] != -1)
468: curLexState = jjnewLexState[jjmatchedKind];
469: return matchedToken;
470: } else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
471: if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
472: matchedToken = jjFillToken();
473: if (specialToken == null)
474: specialToken = matchedToken;
475: else {
476: matchedToken.specialToken = specialToken;
477: specialToken = (specialToken.next = matchedToken);
478: }
479: SkipLexicalActions(matchedToken);
480: } else
481: SkipLexicalActions(null);
482: if (jjnewLexState[jjmatchedKind] != -1)
483: curLexState = jjnewLexState[jjmatchedKind];
484: continue EOFLoop;
485: }
486: jjimageLen += jjmatchedPos + 1;
487: if (jjnewLexState[jjmatchedKind] != -1)
488: curLexState = jjnewLexState[jjmatchedKind];
489: curPos = 0;
490: jjmatchedKind = 0x7fffffff;
491: try {
492: curChar = input_stream.readChar();
493: continue;
494: } catch (java.io.IOException e1) {
495: }
496: }
497: int error_line = input_stream.getEndLine();
498: int error_column = input_stream.getEndColumn();
499: String error_after = null;
500: boolean EOFSeen = false;
501: try {
502: input_stream.readChar();
503: input_stream.backup(1);
504: } catch (java.io.IOException e1) {
505: EOFSeen = true;
506: error_after = curPos <= 1 ? "" : input_stream
507: .GetImage();
508: if (curChar == '\n' || curChar == '\r') {
509: error_line++;
510: error_column = 0;
511: } else
512: error_column++;
513: }
514: if (!EOFSeen) {
515: input_stream.backup(1);
516: error_after = curPos <= 1 ? "" : input_stream
517: .GetImage();
518: }
519: throw new TokenMgrError(EOFSeen, curLexState,
520: error_line, error_column, error_after, curChar,
521: TokenMgrError.LEXICAL_ERROR);
522: }
523: }
524: }
525:
526: void SkipLexicalActions(Token matchedToken) {
527: switch (jjmatchedKind) {
528: default:
529: break;
530: }
531: }
532: }
|