001: /* Generated By:JavaCC: Do not edit this line. ExpressionParserTokenManager.java */
002: package org.concern.model.parser;
003:
004: import java.io.*;
005: import org.concern.model.parser.ast.*;
006: import java.util.*;
007:
008: public class ExpressionParserTokenManager implements
009: ExpressionParserConstants {
010: public java.io.PrintStream debugStream = System.out;
011:
012: public void setDebugStream(java.io.PrintStream ds) {
013: debugStream = ds;
014: }
015:
016: private final int jjMoveStringLiteralDfa0_0() {
017: return jjMoveNfa_0(0, 0);
018: }
019:
020: private final void jjCheckNAdd(int state) {
021: if (jjrounds[state] != jjround) {
022: jjstateSet[jjnewStateCnt++] = state;
023: jjrounds[state] = jjround;
024: }
025: }
026:
027: private final void jjAddStates(int start, int end) {
028: do {
029: jjstateSet[jjnewStateCnt++] = jjnextStates[start];
030: } while (start++ != end);
031: }
032:
033: private final void jjCheckNAddTwoStates(int state1, int state2) {
034: jjCheckNAdd(state1);
035: jjCheckNAdd(state2);
036: }
037:
038: private final void jjCheckNAddStates(int start, int end) {
039: do {
040: jjCheckNAdd(jjnextStates[start]);
041: } while (start++ != end);
042: }
043:
044: private final void jjCheckNAddStates(int start) {
045: jjCheckNAdd(jjnextStates[start]);
046: jjCheckNAdd(jjnextStates[start + 1]);
047: }
048:
049: static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL,
050: 0xffffffffffffffffL };
051:
052: private final int jjMoveNfa_0(int startState, int curPos) {
053: int[] nextStates;
054: int startsAt = 0;
055: jjnewStateCnt = 20;
056: int i = 1;
057: jjstateSet[0] = startState;
058: int j, kind = 0x7fffffff;
059: for (;;) {
060: if (++jjround == 0x7fffffff)
061: ReInitRounds();
062: if (curChar < 64) {
063: long l = 1L << curChar;
064: MatchLoop: do {
065: switch (jjstateSet[--i]) {
066: case 0:
067: if ((0xfffffcbdffffffffL & l) != 0L) {
068: if (kind > 1)
069: kind = 1;
070: } else if (curChar == 41) {
071: if (kind > 7)
072: kind = 7;
073: jjCheckNAdd(12);
074: } else if (curChar == 40) {
075: if (kind > 6)
076: kind = 6;
077: jjCheckNAdd(10);
078: } else if (curChar == 33) {
079: if (kind > 5)
080: kind = 5;
081: jjCheckNAdd(8);
082: } else if (curChar == 38)
083: jjstateSet[jjnewStateCnt++] = 1;
084: if ((0x100002400L & l) != 0L) {
085: if (kind > 2)
086: kind = 2;
087: jjCheckNAddStates(0, 10);
088: }
089: break;
090: case 1:
091: if (curChar != 38)
092: break;
093: if (kind > 3)
094: kind = 3;
095: jjCheckNAdd(2);
096: break;
097: case 2:
098: if ((0x100002400L & l) == 0L)
099: break;
100: if (kind > 3)
101: kind = 3;
102: jjCheckNAdd(2);
103: break;
104: case 3:
105: if (curChar == 38)
106: jjstateSet[jjnewStateCnt++] = 1;
107: break;
108: case 5:
109: if ((0x100002400L & l) == 0L)
110: break;
111: if (kind > 4)
112: kind = 4;
113: jjstateSet[jjnewStateCnt++] = 5;
114: break;
115: case 7:
116: if (curChar != 33)
117: break;
118: kind = 5;
119: jjCheckNAdd(8);
120: break;
121: case 8:
122: if ((0x100002400L & l) == 0L)
123: break;
124: if (kind > 5)
125: kind = 5;
126: jjCheckNAdd(8);
127: break;
128: case 9:
129: if (curChar != 40)
130: break;
131: kind = 6;
132: jjCheckNAdd(10);
133: break;
134: case 10:
135: if ((0x100002400L & l) == 0L)
136: break;
137: if (kind > 6)
138: kind = 6;
139: jjCheckNAdd(10);
140: break;
141: case 11:
142: if (curChar != 41)
143: break;
144: kind = 7;
145: jjCheckNAdd(12);
146: break;
147: case 12:
148: if ((0x100002400L & l) == 0L)
149: break;
150: if (kind > 7)
151: kind = 7;
152: jjCheckNAdd(12);
153: break;
154: case 13:
155: if ((0x100002400L & l) == 0L)
156: break;
157: if (kind > 2)
158: kind = 2;
159: jjCheckNAddStates(0, 10);
160: break;
161: case 14:
162: if ((0x100002400L & l) == 0L)
163: break;
164: if (kind > 2)
165: kind = 2;
166: jjCheckNAdd(14);
167: break;
168: case 15:
169: if ((0x100002400L & l) != 0L)
170: jjCheckNAddTwoStates(15, 3);
171: break;
172: case 16:
173: if ((0x100002400L & l) != 0L)
174: jjCheckNAddTwoStates(16, 6);
175: break;
176: case 17:
177: if ((0x100002400L & l) != 0L)
178: jjCheckNAddTwoStates(17, 7);
179: break;
180: case 18:
181: if ((0x100002400L & l) != 0L)
182: jjCheckNAddTwoStates(18, 9);
183: break;
184: case 19:
185: if ((0x100002400L & l) != 0L)
186: jjCheckNAddTwoStates(19, 11);
187: break;
188: default:
189: break;
190: }
191: } while (i != startsAt);
192: } else if (curChar < 128) {
193: long l = 1L << (curChar & 077);
194: MatchLoop: do {
195: switch (jjstateSet[--i]) {
196: case 0:
197: if ((0xefffffffffffffffL & l) != 0L) {
198: if (kind > 1)
199: kind = 1;
200: } else if (curChar == 124)
201: jjstateSet[jjnewStateCnt++] = 4;
202: break;
203: case 4:
204: if (curChar != 124)
205: break;
206: if (kind > 4)
207: kind = 4;
208: jjstateSet[jjnewStateCnt++] = 5;
209: break;
210: case 6:
211: if (curChar == 124)
212: jjstateSet[jjnewStateCnt++] = 4;
213: break;
214: default:
215: break;
216: }
217: } while (i != startsAt);
218: } else {
219: int i2 = (curChar & 0xff) >> 6;
220: long l2 = 1L << (curChar & 077);
221: MatchLoop: do {
222: switch (jjstateSet[--i]) {
223: case 0:
224: if ((jjbitVec0[i2] & l2) != 0L && kind > 1)
225: kind = 1;
226: break;
227: default:
228: break;
229: }
230: } while (i != startsAt);
231: }
232: if (kind != 0x7fffffff) {
233: jjmatchedKind = kind;
234: jjmatchedPos = curPos;
235: kind = 0x7fffffff;
236: }
237: ++curPos;
238: if ((i = jjnewStateCnt) == (startsAt = 20 - (jjnewStateCnt = startsAt)))
239: return curPos;
240: try {
241: curChar = input_stream.readChar();
242: } catch (java.io.IOException e) {
243: return curPos;
244: }
245: }
246: }
247:
248: static final int[] jjnextStates = { 14, 15, 3, 16, 6, 17, 7, 18, 9,
249: 19, 11, };
250: public static final String[] jjstrLiteralImages = { "", null, null,
251: null, null, null, null, null, };
252: public static final String[] lexStateNames = { "DEFAULT", };
253: protected SimpleCharStream input_stream;
254: private final int[] jjrounds = new int[20];
255: private final int[] jjstateSet = new int[40];
256: protected char curChar;
257:
258: public ExpressionParserTokenManager(SimpleCharStream stream) {
259: if (SimpleCharStream.staticFlag)
260: throw new Error(
261: "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
262: input_stream = stream;
263: }
264:
265: public ExpressionParserTokenManager(SimpleCharStream stream,
266: int lexState) {
267: this (stream);
268: SwitchTo(lexState);
269: }
270:
271: public void ReInit(SimpleCharStream stream) {
272: jjmatchedPos = jjnewStateCnt = 0;
273: curLexState = defaultLexState;
274: input_stream = stream;
275: ReInitRounds();
276: }
277:
278: private final void ReInitRounds() {
279: int i;
280: jjround = 0x80000001;
281: for (i = 20; i-- > 0;)
282: jjrounds[i] = 0x80000000;
283: }
284:
285: public void ReInit(SimpleCharStream stream, int lexState) {
286: ReInit(stream);
287: SwitchTo(lexState);
288: }
289:
290: public void SwitchTo(int lexState) {
291: if (lexState >= 1 || lexState < 0)
292: throw new TokenMgrError(
293: "Error: Ignoring invalid lexical state : "
294: + lexState + ". State unchanged.",
295: TokenMgrError.INVALID_LEXICAL_STATE);
296: else
297: curLexState = lexState;
298: }
299:
300: protected Token jjFillToken() {
301: Token t = Token.newToken(jjmatchedKind);
302: t.kind = jjmatchedKind;
303: String im = jjstrLiteralImages[jjmatchedKind];
304: t.image = (im == null) ? input_stream.GetImage() : im;
305: t.beginLine = input_stream.getBeginLine();
306: t.beginColumn = input_stream.getBeginColumn();
307: t.endLine = input_stream.getEndLine();
308: t.endColumn = input_stream.getEndColumn();
309: return t;
310: }
311:
312: int curLexState = 0;
313: int defaultLexState = 0;
314: int jjnewStateCnt;
315: int jjround;
316: int jjmatchedPos;
317: int jjmatchedKind;
318:
319: public Token getNextToken() {
320: int kind;
321: Token specialToken = null;
322: Token matchedToken;
323: int curPos = 0;
324:
325: EOFLoop: for (;;) {
326: try {
327: curChar = input_stream.BeginToken();
328: } catch (java.io.IOException e) {
329: jjmatchedKind = 0;
330: matchedToken = jjFillToken();
331: return matchedToken;
332: }
333:
334: jjmatchedKind = 0x7fffffff;
335: jjmatchedPos = 0;
336: curPos = jjMoveStringLiteralDfa0_0();
337: if (jjmatchedKind != 0x7fffffff) {
338: if (jjmatchedPos + 1 < curPos)
339: input_stream.backup(curPos - jjmatchedPos - 1);
340: matchedToken = jjFillToken();
341: return matchedToken;
342: }
343: int error_line = input_stream.getEndLine();
344: int error_column = input_stream.getEndColumn();
345: String error_after = null;
346: boolean EOFSeen = false;
347: try {
348: input_stream.readChar();
349: input_stream.backup(1);
350: } catch (java.io.IOException e1) {
351: EOFSeen = true;
352: error_after = curPos <= 1 ? "" : input_stream
353: .GetImage();
354: if (curChar == '\n' || curChar == '\r') {
355: error_line++;
356: error_column = 0;
357: } else
358: error_column++;
359: }
360: if (!EOFSeen) {
361: input_stream.backup(1);
362: error_after = curPos <= 1 ? "" : input_stream
363: .GetImage();
364: }
365: throw new TokenMgrError(EOFSeen, curLexState, error_line,
366: error_column, error_after, curChar,
367: TokenMgrError.LEXICAL_ERROR);
368: }
369: }
370:
371: }
|