KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejen > util > arl > ArlParserTokenManager


1 /* Generated By:JJTree&JavaCC: Do not edit this line. ArlParserTokenManager.java */
2 package org.ejen.util.arl;
3
4 public class ArlParserTokenManager implements ArlParserConstants {
5     public static java.io.PrintStream JavaDoc debugStream = System.out;
6     public static void setDebugStream(java.io.PrintStream JavaDoc ds) {
7         debugStream = ds;
8     }
9
10     private static final int jjStopStringLiteralDfa_0(int pos, long active0) {
11         switch (pos) {
12         default:
13             return -1;
14         }
15     }
16
17     private static final int jjStartNfa_0(int pos, long active0) {
18         return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
19     }
20
21     static private final int jjStopAtPos(int pos, int kind) {
22         jjmatchedKind = kind;
23         jjmatchedPos = pos;
24         return pos + 1;
25     }
26
27     static private final int jjStartNfaWithStates_0(int pos, int kind, int state) {
28         jjmatchedKind = kind;
29         jjmatchedPos = pos;
30         try {
31             curChar = input_stream.readChar();
32         } catch (java.io.IOException JavaDoc e) {
33             return pos + 1;
34         }
35         return jjMoveNfa_0(state, pos + 1);
36     }
37
38     static private final int jjMoveStringLiteralDfa0_0() {
39         switch (curChar) {
40         case 43:
41             return jjStopAtPos(0, 6);
42
43         case 44:
44             return jjStopAtPos(0, 12);
45
46         case 45:
47             return jjStopAtPos(0, 7);
48
49         case 59:
50             return jjStopAtPos(0, 10);
51
52         case 91:
53             return jjStopAtPos(0, 11);
54
55         case 93:
56             return jjStopAtPos(0, 13);
57
58         case 126:
59             return jjStopAtPos(0, 8);
60
61         default:
62             return jjMoveNfa_0(0, 0);
63         }
64     }
65
66     static private final void jjCheckNAdd(int state) {
67         if (jjrounds[state] != jjround) {
68             jjstateSet[jjnewStateCnt++] = state;
69             jjrounds[state] = jjround;
70         }
71     }
72
73     static private final void jjAddStates(int start, int end) {
74         do {
75             jjstateSet[jjnewStateCnt++] = jjnextStates[start];
76         } while (start++ != end);
77     }
78
79     static private final void jjCheckNAddTwoStates(int state1, int state2) {
80         jjCheckNAdd(state1);
81         jjCheckNAdd(state2);
82     }
83
84     static private final void jjCheckNAddStates(int start, int end) {
85         do {
86             jjCheckNAdd(jjnextStates[start]);
87         } while (start++ != end);
88     }
89
90     static private final void jjCheckNAddStates(int start) {
91         jjCheckNAdd(jjnextStates[start]);
92         jjCheckNAdd(jjnextStates[start + 1]);
93     }
94
95     static private final int jjMoveNfa_0(int startState, int curPos) {
96         int[] nextStates;
97         int startsAt = 0;
98
99         jjnewStateCnt = 1;
100         int i = 1;
101
102         jjstateSet[0] = startState;
103         int j, kind = 0x7fffffff;
104
105         for (;;) {
106             if (++jjround == 0x7fffffff) {
107                 ReInitRounds();
108             }
109             if (curChar < 64) {
110                 long l = 1L << curChar;
111
112                 MatchLoop:
113                 do {
114                     switch (jjstateSet[--i]) {
115                     case 0:
116                         if ((0x3ff000000000000L & l) == 0L) {
117                             break;
118                         }
119                         kind = 9;
120                         jjstateSet[jjnewStateCnt++] = 0;
121                         break;
122
123                     default:
124                         break;
125                     }
126                 } while (i != startsAt);
127             } else if (curChar < 128) {
128                 long l = 1L << (curChar & 077);
129
130                 MatchLoop:
131                 do {
132                     switch (jjstateSet[--i]) {
133                     default:
134                         break;
135                     }
136                 } while (i != startsAt);
137             } else {
138                 int i2 = (curChar & 0xff) >> 6;
139                 long l2 = 1L << (curChar & 077);
140
141                 MatchLoop:
142                 do {
143                     switch (jjstateSet[--i]) {
144                     default:
145                         break;
146                     }
147                 } while (i != startsAt);
148             }
149             if (kind != 0x7fffffff) {
150                 jjmatchedKind = kind;
151                 jjmatchedPos = curPos;
152                 kind = 0x7fffffff;
153             }
154             ++curPos;
155             if ((i = jjnewStateCnt)
156                     == (startsAt = 1 - (jjnewStateCnt = startsAt))) {
157                 return curPos;
158             }
159             try {
160                 curChar = input_stream.readChar();
161             } catch (java.io.IOException JavaDoc e) {
162                 return curPos;
163             }
164         }
165     }
166     static final int[] jjnextStates = {};
167     public static final String JavaDoc[] jjstrLiteralImages = {
168         "", null, null, null, null, null, "\53", "\55", "\176", null, "\73",
169         "\133", "\54", "\135", };
170     public static final String JavaDoc[] lexStateNames = {
171         "DEFAULT",
172     };
173     static final long[] jjtoToken = {
174         0x3fc1L,
175     };
176     static final long[] jjtoSkip = {
177         0x3eL,
178     };
179     static private SimpleCharStream input_stream;
180     static private final int[] jjrounds = new int[1];
181     static private final int[] jjstateSet = new int[2];
182     static protected char curChar;
183     public ArlParserTokenManager(SimpleCharStream stream) {
184         if (input_stream != null) {
185             throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.",
186                     TokenMgrError.STATIC_LEXER_ERROR);
187         }
188         input_stream = stream;
189     }
190
191     public ArlParserTokenManager(SimpleCharStream stream, int lexState) {
192         this(stream);
193         SwitchTo(lexState);
194     }
195
196     static public void ReInit(SimpleCharStream stream) {
197         jjmatchedPos = jjnewStateCnt = 0;
198         curLexState = defaultLexState;
199         input_stream = stream;
200         ReInitRounds();
201     }
202
203     static private final void ReInitRounds() {
204         int i;
205
206         jjround = 0x80000001;
207         for (i = 1; i-- > 0;) {
208             jjrounds[i] = 0x80000000;
209         }
210     }
211
212     static public void ReInit(SimpleCharStream stream, int lexState) {
213         ReInit(stream);
214         SwitchTo(lexState);
215     }
216
217     static public void SwitchTo(int lexState) {
218         if (lexState >= 1 || lexState < 0) {
219             throw new TokenMgrError("Error: Ignoring invalid lexical state : "
220                     + lexState + ". State unchanged.",
221                     TokenMgrError.INVALID_LEXICAL_STATE);
222         } else {
223             curLexState = lexState;
224         }
225     }
226
227     static private final Token jjFillToken() {
228         Token t = Token.newToken(jjmatchedKind);
229
230         t.kind = jjmatchedKind;
231         String JavaDoc im = jjstrLiteralImages[jjmatchedKind];
232
233         t.image = (im == null) ? input_stream.GetImage() : im;
234         t.beginLine = input_stream.getBeginLine();
235         t.beginColumn = input_stream.getBeginColumn();
236         t.endLine = input_stream.getEndLine();
237         t.endColumn = input_stream.getEndColumn();
238         return t;
239     }
240     static int curLexState = 0;
241     static int defaultLexState = 0;
242     static int jjnewStateCnt;
243     static int jjround;
244     static int jjmatchedPos;
245     static int jjmatchedKind;
246     public static final Token getNextToken() {
247         int kind;
248         Token specialToken = null;
249         Token matchedToken;
250         int curPos = 0;
251
252         EOFLoop:
253         for (;;) {
254             try {
255                 curChar = input_stream.BeginToken();
256             } catch (java.io.IOException JavaDoc e) {
257                 jjmatchedKind = 0;
258                 matchedToken = jjFillToken();
259                 return matchedToken;
260             }
261             try {
262                 input_stream.backup(0);
263                 while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L) {
264                     curChar = input_stream.BeginToken();
265                 }
266             } catch (java.io.IOException JavaDoc e1) {
267                 continue EOFLoop;
268             }
269             jjmatchedKind = 0x7fffffff;
270             jjmatchedPos = 0;
271             curPos = jjMoveStringLiteralDfa0_0();
272             if (jjmatchedKind != 0x7fffffff) {
273                 if (jjmatchedPos + 1 < curPos) {
274                     input_stream.backup(curPos - jjmatchedPos - 1);
275                 }
276                 if ((jjtoToken[jjmatchedKind >> 6]
277                                 & (1L << (jjmatchedKind & 077)))
278                         != 0L) {
279                     matchedToken = jjFillToken();
280                     return matchedToken;
281                 } else {
282                     continue EOFLoop;
283                 }
284             }
285             int error_line = input_stream.getEndLine();
286             int error_column = input_stream.getEndColumn();
287             String JavaDoc error_after = null;
288             boolean EOFSeen = false;
289
290             try {
291                 input_stream.readChar();
292                 input_stream.backup(1);
293             } catch (java.io.IOException JavaDoc e1) {
294                 EOFSeen = true;
295                 error_after = curPos <= 1 ? "" : input_stream.GetImage();
296                 if (curChar == '\n' || curChar == '\r') {
297                     error_line++;
298                     error_column = 0;
299                 } else {
300                     error_column++;
301                 }
302             }
303             if (!EOFSeen) {
304                 input_stream.backup(1);
305                 error_after = curPos <= 1 ? "" : input_stream.GetImage();
306             }
307             throw new TokenMgrError(EOFSeen, curLexState, error_line,
308                     error_column, error_after, curChar,
309                     TokenMgrError.LEXICAL_ERROR);
310         }
311     }
312 }
313
Popular Tags