1
2 package fr.in2p3.jsaga.generated.parser;
3 import fr.in2p3.jsaga.engine.session.BaseUrlItem;
4 import fr.in2p3.jsaga.engine.session.item.*;
5 import java.io.ByteArrayInputStream;
6 import java.util.ArrayList;
7 import java.util.List;
8
9
10 public class BaseUrlParserTokenManager implements BaseUrlParserConstants
11 {
12
13
14 public java.io.PrintStream debugStream = System.out;
15
16 public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
17 private final int jjStopStringLiteralDfa_0(int pos, long active0)
18 {
19 switch (pos)
20 {
21 default :
22 return -1;
23 }
24 }
25 private final int jjStartNfa_0(int pos, long active0)
26 {
27 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
28 }
29 private int jjStopAtPos(int pos, int kind)
30 {
31 jjmatchedKind = kind;
32 jjmatchedPos = pos;
33 return pos + 1;
34 }
35 private int jjMoveStringLiteralDfa0_0()
36 {
37 switch(curChar)
38 {
39 case 42:
40 return jjStopAtPos(0, 6);
41 case 45:
42 return jjMoveStringLiteralDfa1_0(0x80L);
43 case 46:
44 return jjStopAtPos(0, 9);
45 case 47:
46 return jjStopAtPos(0, 11);
47 case 58:
48 jjmatchedKind = 10;
49 return jjMoveStringLiteralDfa1_0(0x100L);
50 case 91:
51 return jjStopAtPos(0, 16);
52 case 93:
53 return jjStopAtPos(0, 17);
54 default :
55 return jjMoveNfa_0(1, 0);
56 }
57 }
58 private int jjMoveStringLiteralDfa1_0(long active0)
59 {
60 try { curChar = input_stream.readChar(); }
61 catch(java.io.IOException e) {
62 jjStopStringLiteralDfa_0(0, active0);
63 return 1;
64 }
65 switch(curChar)
66 {
67 case 47:
68 return jjMoveStringLiteralDfa2_0(active0, 0x100L);
69 case 62:
70 if ((active0 & 0x80L) != 0L)
71 return jjStopAtPos(1, 7);
72 break;
73 default :
74 break;
75 }
76 return jjStartNfa_0(0, active0);
77 }
78 private int jjMoveStringLiteralDfa2_0(long old0, long active0)
79 {
80 if (((active0 &= old0)) == 0L)
81 return jjStartNfa_0(0, old0);
82 try { curChar = input_stream.readChar(); }
83 catch(java.io.IOException e) {
84 jjStopStringLiteralDfa_0(1, active0);
85 return 2;
86 }
87 switch(curChar)
88 {
89 case 47:
90 if ((active0 & 0x100L) != 0L)
91 return jjStopAtPos(2, 8);
92 break;
93 default :
94 break;
95 }
96 return jjStartNfa_0(1, active0);
97 }
98 private int jjMoveNfa_0(int startState, int curPos)
99 {
100 int startsAt = 0;
101 jjnewStateCnt = 5;
102 int i = 1;
103 jjstateSet[0] = startState;
104 int kind = 0x7fffffff;
105 for (;;)
106 {
107 if (++jjround == 0x7fffffff)
108 ReInitRounds();
109 if (curChar < 64)
110 {
111 long l = 1L << curChar;
112 do
113 {
114 switch(jjstateSet[--i])
115 {
116 case 1:
117 if ((0x3ff000000000000L & l) != 0L)
118 {
119 if (kind > 12)
120 kind = 12;
121 jjCheckNAdd(0);
122 }
123 else if ((0x580000000000L & l) != 0L)
124 {
125 if (kind > 18)
126 kind = 18;
127 }
128 break;
129 case 0:
130 if ((0x3ff000000000000L & l) == 0L)
131 break;
132 if (kind > 12)
133 kind = 12;
134 jjCheckNAdd(0);
135 break;
136 case 2:
137 if (curChar == 45)
138 jjCheckNAdd(3);
139 break;
140 case 3:
141 if ((0x3ff000000000000L & l) == 0L)
142 break;
143 if (kind > 13)
144 kind = 13;
145 jjCheckNAddTwoStates(2, 3);
146 break;
147 case 4:
148 if ((0x580000000000L & l) != 0L)
149 kind = 18;
150 break;
151 default : break;
152 }
153 } while(i != startsAt);
154 }
155 else if (curChar < 128)
156 {
157 long l = 1L << (curChar & 077);
158 do
159 {
160 switch(jjstateSet[--i])
161 {
162 case 1:
163 if ((0x7fffffe07fffffeL & l) != 0L)
164 {
165 if (kind > 13)
166 kind = 13;
167 jjCheckNAddTwoStates(2, 3);
168 }
169 else if (curChar == 95)
170 {
171 if (kind > 18)
172 kind = 18;
173 }
174 break;
175 case 3:
176 if ((0x7fffffe07fffffeL & l) == 0L)
177 break;
178 if (kind > 13)
179 kind = 13;
180 jjCheckNAddTwoStates(2, 3);
181 break;
182 case 4:
183 if (curChar == 95)
184 kind = 18;
185 break;
186 default : break;
187 }
188 } while(i != startsAt);
189 }
190 else
191 {
192 int hiByte = (int)(curChar >> 8);
193 int i1 = hiByte >> 6;
194 long l1 = 1L << (hiByte & 077);
195 int i2 = (curChar & 0xff) >> 6;
196 long l2 = 1L << (curChar & 077);
197 do
198 {
199 switch(jjstateSet[--i])
200 {
201 default : break;
202 }
203 } while(i != startsAt);
204 }
205 if (kind != 0x7fffffff)
206 {
207 jjmatchedKind = kind;
208 jjmatchedPos = curPos;
209 kind = 0x7fffffff;
210 }
211 ++curPos;
212 if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt)))
213 return curPos;
214 try { curChar = input_stream.readChar(); }
215 catch(java.io.IOException e) { return curPos; }
216 }
217 }
218 static final int[] jjnextStates = {
219 };
220
221
222 public static final String[] jjstrLiteralImages = {
223 "", null, null, null, null, null, "\52", "\55\76", "\72\57\57", "\56", "\72",
224 "\57", null, null, null, null, "\133", "\135", null, };
225
226
227 public static final String[] lexStateNames = {
228 "DEFAULT",
229 };
230 static final long[] jjtoToken = {
231 0x73fc1L,
232 };
233 static final long[] jjtoSkip = {
234 0x3eL,
235 };
236 protected JavaCharStream input_stream;
237 private final int[] jjrounds = new int[5];
238 private final int[] jjstateSet = new int[10];
239 protected char curChar;
240
241 public BaseUrlParserTokenManager(JavaCharStream stream){
242 if (JavaCharStream.staticFlag)
243 throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
244 input_stream = stream;
245 }
246
247
248 public BaseUrlParserTokenManager(JavaCharStream stream, int lexState){
249 this(stream);
250 SwitchTo(lexState);
251 }
252
253
254 public void ReInit(JavaCharStream stream)
255 {
256 jjmatchedPos = jjnewStateCnt = 0;
257 curLexState = defaultLexState;
258 input_stream = stream;
259 ReInitRounds();
260 }
261 private void ReInitRounds()
262 {
263 int i;
264 jjround = 0x80000001;
265 for (i = 5; i-- > 0;)
266 jjrounds[i] = 0x80000000;
267 }
268
269
270 public void ReInit(JavaCharStream stream, int lexState)
271 {
272 ReInit(stream);
273 SwitchTo(lexState);
274 }
275
276
277 public void SwitchTo(int lexState)
278 {
279 if (lexState >= 1 || lexState < 0)
280 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
281 else
282 curLexState = lexState;
283 }
284
285 protected Token jjFillToken()
286 {
287 final Token t;
288 final String curTokenImage;
289 final int beginLine;
290 final int endLine;
291 final int beginColumn;
292 final int endColumn;
293 String im = jjstrLiteralImages[jjmatchedKind];
294 curTokenImage = (im == null) ? input_stream.GetImage() : im;
295 beginLine = input_stream.getBeginLine();
296 beginColumn = input_stream.getBeginColumn();
297 endLine = input_stream.getEndLine();
298 endColumn = input_stream.getEndColumn();
299 t = Token.newToken(jjmatchedKind, curTokenImage);
300
301 t.beginLine = beginLine;
302 t.endLine = endLine;
303 t.beginColumn = beginColumn;
304 t.endColumn = endColumn;
305
306 return t;
307 }
308
309 int curLexState = 0;
310 int defaultLexState = 0;
311 int jjnewStateCnt;
312 int jjround;
313 int jjmatchedPos;
314 int jjmatchedKind;
315
316
317 public Token getNextToken()
318 {
319 Token matchedToken;
320 int curPos = 0;
321
322 EOFLoop :
323 for (;;)
324 {
325 try
326 {
327 curChar = input_stream.BeginToken();
328 }
329 catch(java.io.IOException e)
330 {
331 jjmatchedKind = 0;
332 matchedToken = jjFillToken();
333 return matchedToken;
334 }
335
336 try { input_stream.backup(0);
337 while (curChar <= 32 && (0x100003600L & (1L << curChar)) != 0L)
338 curChar = input_stream.BeginToken();
339 }
340 catch (java.io.IOException e1) { continue EOFLoop; }
341 jjmatchedKind = 0x7fffffff;
342 jjmatchedPos = 0;
343 curPos = jjMoveStringLiteralDfa0_0();
344 if (jjmatchedKind != 0x7fffffff)
345 {
346 if (jjmatchedPos + 1 < curPos)
347 input_stream.backup(curPos - jjmatchedPos - 1);
348 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
349 {
350 matchedToken = jjFillToken();
351 return matchedToken;
352 }
353 else
354 {
355 continue EOFLoop;
356 }
357 }
358 int error_line = input_stream.getEndLine();
359 int error_column = input_stream.getEndColumn();
360 String error_after = null;
361 boolean EOFSeen = false;
362 try { input_stream.readChar(); input_stream.backup(1); }
363 catch (java.io.IOException e1) {
364 EOFSeen = true;
365 error_after = curPos <= 1 ? "" : input_stream.GetImage();
366 if (curChar == '\n' || curChar == '\r') {
367 error_line++;
368 error_column = 0;
369 }
370 else
371 error_column++;
372 }
373 if (!EOFSeen) {
374 input_stream.backup(1);
375 error_after = curPos <= 1 ? "" : input_stream.GetImage();
376 }
377 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
378 }
379 }
380
381 private void jjCheckNAdd(int state)
382 {
383 if (jjrounds[state] != jjround)
384 {
385 jjstateSet[jjnewStateCnt++] = state;
386 jjrounds[state] = jjround;
387 }
388 }
389 private void jjAddStates(int start, int end)
390 {
391 do {
392 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
393 } while (start++ != end);
394 }
395 private void jjCheckNAddTwoStates(int state1, int state2)
396 {
397 jjCheckNAdd(state1);
398 jjCheckNAdd(state2);
399 }
400
401 }