001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /* Generated By:JavaCC: Do not edit this line. LdapUrlParserTokenManager.java */
018:
019: package org.apache.harmony.jndi.provider.ldap.parser;
020:
021: import java.io.FileInputStream;
022: import java.io.FileNotFoundException;
023: import java.util.ArrayList;
024: import java.util.List;
025: import java.io.StringReader;
026: import javax.naming.directory.SearchControls;
027: import org.apache.harmony.jndi.provider.ldap.Filter;
028: import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
029:
030: public class LdapUrlParserTokenManager implements
031: LdapUrlParserConstants {
032: public java.io.PrintStream debugStream = System.out;
033:
034: public void setDebugStream(java.io.PrintStream ds) {
035: debugStream = ds;
036: }
037:
038: private final int jjStopStringLiteralDfa_0(int pos, long active0) {
039: switch (pos) {
040: default:
041: return -1;
042: }
043: }
044:
045: private final int jjStartNfa_0(int pos, long active0) {
046: return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0),
047: pos + 1);
048: }
049:
050: private final int jjStopAtPos(int pos, int kind) {
051: jjmatchedKind = kind;
052: jjmatchedPos = pos;
053: return pos + 1;
054: }
055:
056: private final int jjStartNfaWithStates_0(int pos, int kind,
057: int state) {
058: jjmatchedKind = kind;
059: jjmatchedPos = pos;
060: try {
061: curChar = input_stream.readChar();
062: } catch (java.io.IOException e) {
063: return pos + 1;
064: }
065: return jjMoveNfa_0(state, pos + 1);
066: }
067:
068: private final int jjMoveStringLiteralDfa0_0() {
069: switch (curChar) {
070: case 10:
071: return jjStopAtPos(0, 17);
072: case 33:
073: return jjStopAtPos(0, 10);
074: case 37:
075: return jjStopAtPos(0, 7);
076: case 44:
077: return jjStopAtPos(0, 4);
078: case 46:
079: return jjStopAtPos(0, 9);
080: case 47:
081: return jjStopAtPos(0, 6);
082: case 48:
083: return jjStopAtPos(0, 15);
084: case 58:
085: return jjStopAtPos(0, 8);
086: case 61:
087: return jjStopAtPos(0, 11);
088: case 63:
089: return jjStopAtPos(0, 5);
090: default:
091: return jjMoveNfa_0(1, 0);
092: }
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 = { 0x0L, 0x0L, 0xffffffffffffffffL,
125: 0xffffffffffffffffL };
126:
127: private final int jjMoveNfa_0(int startState, int curPos) {
128: int[] nextStates;
129: int startsAt = 0;
130: jjnewStateCnt = 29;
131: int i = 1;
132: jjstateSet[0] = startState;
133: int j, kind = 0x7fffffff;
134: for (;;) {
135: if (++jjround == 0x7fffffff)
136: ReInitRounds();
137: if (curChar < 64) {
138: long l = 1L << curChar;
139: MatchLoop: do {
140: switch (jjstateSet[--i]) {
141: case 1:
142: if ((0x7fff7ffffffffbffL & l) != 0L) {
143: if (kind > 16)
144: kind = 16;
145: }
146: if ((0x3fe000000000000L & l) != 0L) {
147: if (kind > 14)
148: kind = 14;
149: }
150: break;
151: case 0:
152: if (curChar == 45 && kind > 2)
153: kind = 2;
154: break;
155: case 14:
156: if ((0x3fe000000000000L & l) != 0L && kind > 14)
157: kind = 14;
158: break;
159: case 15:
160: if ((0x7fff7ffffffffbffL & l) != 0L
161: && kind > 16)
162: kind = 16;
163: break;
164: case 17:
165: if (curChar == 47 && kind > 1)
166: kind = 1;
167: break;
168: case 18:
169: case 23:
170: if (curChar == 47)
171: jjCheckNAdd(17);
172: break;
173: case 19:
174: if (curChar == 58)
175: jjstateSet[jjnewStateCnt++] = 18;
176: break;
177: case 24:
178: if (curChar == 58)
179: jjstateSet[jjnewStateCnt++] = 23;
180: break;
181: default:
182: break;
183: }
184: } while (i != startsAt);
185: } else if (curChar < 128) {
186: long l = 1L << (curChar & 077);
187: MatchLoop: do {
188: switch (jjstateSet[--i]) {
189: case 1:
190: if (kind > 16)
191: kind = 16;
192: if ((0x7ffff8007ffff80L & l) != 0L) {
193: if (kind > 13)
194: kind = 13;
195: } else if ((0x7e0000007eL & l) != 0L) {
196: if (kind > 12)
197: kind = 12;
198: }
199: if (curChar == 108)
200: jjAddStates(0, 1);
201: else if (curChar == 115)
202: jjstateSet[jjnewStateCnt++] = 10;
203: else if (curChar == 111)
204: jjstateSet[jjnewStateCnt++] = 7;
205: else if (curChar == 98)
206: jjstateSet[jjnewStateCnt++] = 5;
207: else if (curChar == 120)
208: jjCheckNAdd(0);
209: else if (curChar == 88)
210: jjCheckNAdd(0);
211: break;
212: case 2:
213: if (curChar == 120)
214: jjCheckNAdd(0);
215: break;
216: case 3:
217: if (curChar == 101 && kind > 3)
218: kind = 3;
219: break;
220: case 4:
221: if (curChar == 115)
222: jjCheckNAdd(3);
223: break;
224: case 5:
225: if (curChar == 97)
226: jjstateSet[jjnewStateCnt++] = 4;
227: break;
228: case 6:
229: if (curChar == 98)
230: jjstateSet[jjnewStateCnt++] = 5;
231: break;
232: case 7:
233: if (curChar == 110)
234: jjCheckNAdd(3);
235: break;
236: case 8:
237: if (curChar == 111)
238: jjstateSet[jjnewStateCnt++] = 7;
239: break;
240: case 9:
241: if (curChar == 98 && kind > 3)
242: kind = 3;
243: break;
244: case 10:
245: if (curChar == 117)
246: jjstateSet[jjnewStateCnt++] = 9;
247: break;
248: case 11:
249: if (curChar == 115)
250: jjstateSet[jjnewStateCnt++] = 10;
251: break;
252: case 12:
253: if ((0x7e0000007eL & l) != 0L && kind > 12)
254: kind = 12;
255: break;
256: case 13:
257: if ((0x7ffff8007ffff80L & l) != 0L && kind > 13)
258: kind = 13;
259: break;
260: case 15:
261: if (kind > 16)
262: kind = 16;
263: break;
264: case 16:
265: if (curChar == 108)
266: jjAddStates(0, 1);
267: break;
268: case 20:
269: if (curChar == 112)
270: jjstateSet[jjnewStateCnt++] = 19;
271: break;
272: case 21:
273: if (curChar == 97)
274: jjstateSet[jjnewStateCnt++] = 20;
275: break;
276: case 22:
277: if (curChar == 100)
278: jjstateSet[jjnewStateCnt++] = 21;
279: break;
280: case 25:
281: if (curChar == 115)
282: jjstateSet[jjnewStateCnt++] = 24;
283: break;
284: case 26:
285: if (curChar == 112)
286: jjstateSet[jjnewStateCnt++] = 25;
287: break;
288: case 27:
289: if (curChar == 97)
290: jjstateSet[jjnewStateCnt++] = 26;
291: break;
292: case 28:
293: if (curChar == 100)
294: jjstateSet[jjnewStateCnt++] = 27;
295: break;
296: default:
297: break;
298: }
299: } while (i != startsAt);
300: } else {
301: int i2 = (curChar & 0xff) >> 6;
302: long l2 = 1L << (curChar & 077);
303: MatchLoop: do {
304: switch (jjstateSet[--i]) {
305: case 1:
306: if ((jjbitVec0[i2] & l2) != 0L && kind > 16)
307: kind = 16;
308: break;
309: default:
310: break;
311: }
312: } while (i != startsAt);
313: }
314: if (kind != 0x7fffffff) {
315: jjmatchedKind = kind;
316: jjmatchedPos = curPos;
317: kind = 0x7fffffff;
318: }
319: ++curPos;
320: if ((i = jjnewStateCnt) == (startsAt = 29 - (jjnewStateCnt = startsAt)))
321: return curPos;
322: try {
323: curChar = input_stream.readChar();
324: } catch (java.io.IOException e) {
325: return curPos;
326: }
327: }
328: }
329:
330: static final int[] jjnextStates = { 22, 28, };
331: public static final String[] jjstrLiteralImages = { "", null, null,
332: null, "\54", "\77", "\57", "\45", "\72", "\56", "\41",
333: "\75", null, null, null, "\60", null, "\12", };
334: public static final String[] lexStateNames = { "DEFAULT", };
335: protected SimpleCharStream input_stream;
336: private final int[] jjrounds = new int[29];
337: private final int[] jjstateSet = new int[58];
338: protected char curChar;
339:
340: public LdapUrlParserTokenManager(SimpleCharStream stream) {
341: if (SimpleCharStream.staticFlag)
342: throw new Error(
343: "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
344: input_stream = stream;
345: }
346:
347: public LdapUrlParserTokenManager(SimpleCharStream stream,
348: int lexState) {
349: this (stream);
350: SwitchTo(lexState);
351: }
352:
353: public void ReInit(SimpleCharStream stream) {
354: jjmatchedPos = jjnewStateCnt = 0;
355: curLexState = defaultLexState;
356: input_stream = stream;
357: ReInitRounds();
358: }
359:
360: private final void ReInitRounds() {
361: int i;
362: jjround = 0x80000001;
363: for (i = 29; i-- > 0;)
364: jjrounds[i] = 0x80000000;
365: }
366:
367: public void ReInit(SimpleCharStream stream, int lexState) {
368: ReInit(stream);
369: SwitchTo(lexState);
370: }
371:
372: public void SwitchTo(int lexState) {
373: if (lexState >= 1 || lexState < 0)
374: throw new TokenMgrError(
375: "Error: Ignoring invalid lexical state : "
376: + lexState + ". State unchanged.",
377: TokenMgrError.INVALID_LEXICAL_STATE);
378: else
379: curLexState = lexState;
380: }
381:
382: protected Token jjFillToken() {
383: Token t = Token.newToken(jjmatchedKind);
384: t.kind = jjmatchedKind;
385: String im = jjstrLiteralImages[jjmatchedKind];
386: t.image = (im == null) ? input_stream.GetImage() : im;
387: t.beginLine = input_stream.getBeginLine();
388: t.beginColumn = input_stream.getBeginColumn();
389: t.endLine = input_stream.getEndLine();
390: t.endColumn = input_stream.getEndColumn();
391: return t;
392: }
393:
394: int curLexState = 0;
395: int defaultLexState = 0;
396: int jjnewStateCnt;
397: int jjround;
398: int jjmatchedPos;
399: int jjmatchedKind;
400:
401: public Token getNextToken() {
402: int kind;
403: Token specialToken = null;
404: Token matchedToken;
405: int curPos = 0;
406:
407: EOFLoop: for (;;) {
408: try {
409: curChar = input_stream.BeginToken();
410: } catch (java.io.IOException e) {
411: jjmatchedKind = 0;
412: matchedToken = jjFillToken();
413: return matchedToken;
414: }
415:
416: jjmatchedKind = 0x7fffffff;
417: jjmatchedPos = 0;
418: curPos = jjMoveStringLiteralDfa0_0();
419: if (jjmatchedKind != 0x7fffffff) {
420: if (jjmatchedPos + 1 < curPos)
421: input_stream.backup(curPos - jjmatchedPos - 1);
422: matchedToken = jjFillToken();
423: return matchedToken;
424: }
425: int error_line = input_stream.getEndLine();
426: int error_column = input_stream.getEndColumn();
427: String error_after = null;
428: boolean EOFSeen = false;
429: try {
430: input_stream.readChar();
431: input_stream.backup(1);
432: } catch (java.io.IOException e1) {
433: EOFSeen = true;
434: error_after = curPos <= 1 ? "" : input_stream
435: .GetImage();
436: if (curChar == '\n' || curChar == '\r') {
437: error_line++;
438: error_column = 0;
439: } else
440: error_column++;
441: }
442: if (!EOFSeen) {
443: input_stream.backup(1);
444: error_after = curPos <= 1 ? "" : input_stream
445: .GetImage();
446: }
447: throw new TokenMgrError(EOFSeen, curLexState, error_line,
448: error_column, error_after, curChar,
449: TokenMgrError.LEXICAL_ERROR);
450: }
451: }
452:
453: }
|