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. FilterParserTokenManager.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 org.apache.harmony.jndi.provider.ldap.Filter;
027: import org.apache.harmony.jndi.internal.parser.AttributeTypeAndValuePair;
028: import org.apache.harmony.jndi.provider.ldap.Filter.MatchingRuleAssertion;
029: import org.apache.harmony.jndi.provider.ldap.Filter.SubstringFilter;
030: import org.apache.harmony.jndi.provider.ldap.asn1.Utils;
031:
032: public class FilterParserTokenManager implements FilterParserConstants {
033: public java.io.PrintStream debugStream = System.out;
034:
035: public void setDebugStream(java.io.PrintStream ds) {
036: debugStream = ds;
037: }
038:
039: private final int jjStopStringLiteralDfa_0(int pos, long active0) {
040: switch (pos) {
041: default:
042: return -1;
043: }
044: }
045:
046: private final int jjStartNfa_0(int pos, long active0) {
047: return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0),
048: pos + 1);
049: }
050:
051: private final int jjStopAtPos(int pos, int kind) {
052: jjmatchedKind = kind;
053: jjmatchedPos = pos;
054: return pos + 1;
055: }
056:
057: private final int jjStartNfaWithStates_0(int pos, int kind,
058: int state) {
059: jjmatchedKind = kind;
060: jjmatchedPos = pos;
061: try {
062: curChar = input_stream.readChar();
063: } catch (java.io.IOException e) {
064: return pos + 1;
065: }
066: return jjMoveNfa_0(state, pos + 1);
067: }
068:
069: private final int jjMoveStringLiteralDfa0_0() {
070: switch (curChar) {
071: case 10:
072: return jjStopAtPos(0, 24);
073: case 33:
074: return jjStopAtPos(0, 10);
075: case 38:
076: return jjStopAtPos(0, 8);
077: case 40:
078: return jjStopAtPos(0, 4);
079: case 41:
080: return jjStopAtPos(0, 5);
081: case 42:
082: return jjStopAtPos(0, 17);
083: case 45:
084: return jjStopAtPos(0, 19);
085: case 46:
086: return jjStopAtPos(0, 20);
087: case 48:
088: return jjStopAtPos(0, 11);
089: case 58:
090: jjmatchedKind = 12;
091: return jjMoveStringLiteralDfa1_0(0x2L);
092: case 59:
093: return jjStopAtPos(0, 22);
094: case 60:
095: return jjStopAtPos(0, 14);
096: case 61:
097: return jjStopAtPos(0, 13);
098: case 62:
099: return jjStopAtPos(0, 15);
100: case 92:
101: return jjStopAtPos(0, 21);
102: case 123:
103: return jjStopAtPos(0, 6);
104: case 124:
105: return jjStopAtPos(0, 9);
106: case 125:
107: return jjStopAtPos(0, 7);
108: case 126:
109: return jjStopAtPos(0, 16);
110: default:
111: return jjMoveNfa_0(0, 0);
112: }
113: }
114:
115: private final int jjMoveStringLiteralDfa1_0(long active0) {
116: try {
117: curChar = input_stream.readChar();
118: } catch (java.io.IOException e) {
119: jjStopStringLiteralDfa_0(0, active0);
120: return 1;
121: }
122: switch (curChar) {
123: case 100:
124: return jjMoveStringLiteralDfa2_0(active0, 0x2L);
125: default:
126: break;
127: }
128: return jjStartNfa_0(0, active0);
129: }
130:
131: private final int jjMoveStringLiteralDfa2_0(long old0, long active0) {
132: if (((active0 &= old0)) == 0L)
133: return jjStartNfa_0(0, old0);
134: try {
135: curChar = input_stream.readChar();
136: } catch (java.io.IOException e) {
137: jjStopStringLiteralDfa_0(1, active0);
138: return 2;
139: }
140: switch (curChar) {
141: case 110:
142: if ((active0 & 0x2L) != 0L)
143: return jjStopAtPos(2, 1);
144: break;
145: default:
146: break;
147: }
148: return jjStartNfa_0(1, active0);
149: }
150:
151: private final void jjCheckNAdd(int state) {
152: if (jjrounds[state] != jjround) {
153: jjstateSet[jjnewStateCnt++] = state;
154: jjrounds[state] = jjround;
155: }
156: }
157:
158: private final void jjAddStates(int start, int end) {
159: do {
160: jjstateSet[jjnewStateCnt++] = jjnextStates[start];
161: } while (start++ != end);
162: }
163:
164: private final void jjCheckNAddTwoStates(int state1, int state2) {
165: jjCheckNAdd(state1);
166: jjCheckNAdd(state2);
167: }
168:
169: private final void jjCheckNAddStates(int start, int end) {
170: do {
171: jjCheckNAdd(jjnextStates[start]);
172: } while (start++ != end);
173: }
174:
175: private final void jjCheckNAddStates(int start) {
176: jjCheckNAdd(jjnextStates[start]);
177: jjCheckNAdd(jjnextStates[start + 1]);
178: }
179:
180: static final long[] jjbitVec0 = { 0x0L, 0x0L, 0xffffffffffffffffL,
181: 0xffffffffffffffffL };
182:
183: private final int jjMoveNfa_0(int startState, int curPos) {
184: int[] nextStates;
185: int startsAt = 0;
186: jjnewStateCnt = 4;
187: int i = 1;
188: jjstateSet[0] = startState;
189: int j, kind = 0x7fffffff;
190: for (;;) {
191: if (++jjround == 0x7fffffff)
192: ReInitRounds();
193: if (curChar < 64) {
194: long l = 1L << curChar;
195: MatchLoop: do {
196: switch (jjstateSet[--i]) {
197: case 0:
198: if ((0xfffff8fffffffbffL & l) != 0L) {
199: if (kind > 23)
200: kind = 23;
201: }
202: if ((0x3fe000000000000L & l) != 0L) {
203: if (kind > 18)
204: kind = 18;
205: }
206: break;
207: case 2:
208: if ((0x3fe000000000000L & l) != 0L && kind > 18)
209: kind = 18;
210: break;
211: case 3:
212: if ((0xfffff8fffffffbffL & l) != 0L
213: && kind > 23)
214: kind = 23;
215: break;
216: default:
217: break;
218: }
219: } while (i != startsAt);
220: } else if (curChar < 128) {
221: long l = 1L << (curChar & 077);
222: MatchLoop: do {
223: switch (jjstateSet[--i]) {
224: case 0:
225: if ((0xffffffffefffffffL & l) != 0L) {
226: if (kind > 23)
227: kind = 23;
228: }
229: if ((0x7ffff8007ffff80L & l) != 0L) {
230: if (kind > 3)
231: kind = 3;
232: } else if ((0x7e0000007eL & l) != 0L) {
233: if (kind > 2)
234: kind = 2;
235: }
236: break;
237: case 1:
238: if ((0x7ffff8007ffff80L & l) != 0L && kind > 3)
239: kind = 3;
240: break;
241: case 3:
242: if ((0xffffffffefffffffL & l) != 0L
243: && kind > 23)
244: kind = 23;
245: break;
246: default:
247: break;
248: }
249: } while (i != startsAt);
250: } else {
251: int i2 = (curChar & 0xff) >> 6;
252: long l2 = 1L << (curChar & 077);
253: MatchLoop: do {
254: switch (jjstateSet[--i]) {
255: case 0:
256: if ((jjbitVec0[i2] & l2) != 0L && kind > 23)
257: kind = 23;
258: break;
259: default:
260: break;
261: }
262: } while (i != startsAt);
263: }
264: if (kind != 0x7fffffff) {
265: jjmatchedKind = kind;
266: jjmatchedPos = curPos;
267: kind = 0x7fffffff;
268: }
269: ++curPos;
270: if ((i = jjnewStateCnt) == (startsAt = 4 - (jjnewStateCnt = startsAt)))
271: return curPos;
272: try {
273: curChar = input_stream.readChar();
274: } catch (java.io.IOException e) {
275: return curPos;
276: }
277: }
278: }
279:
280: static final int[] jjnextStates = {};
281: public static final String[] jjstrLiteralImages = { "",
282: "\72\144\156", null, null, "\50", "\51", "\173", "\175",
283: "\46", "\174", "\41", "\60", "\72", "\75", "\74", "\76",
284: "\176", "\52", null, "\55", "\56", "\134", "\73", null,
285: "\12", };
286: public static final String[] lexStateNames = { "DEFAULT", };
287: protected SimpleCharStream input_stream;
288: private final int[] jjrounds = new int[4];
289: private final int[] jjstateSet = new int[8];
290: protected char curChar;
291:
292: public FilterParserTokenManager(SimpleCharStream stream) {
293: if (SimpleCharStream.staticFlag)
294: throw new Error(
295: "ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
296: input_stream = stream;
297: }
298:
299: public FilterParserTokenManager(SimpleCharStream stream,
300: int lexState) {
301: this (stream);
302: SwitchTo(lexState);
303: }
304:
305: public void ReInit(SimpleCharStream stream) {
306: jjmatchedPos = jjnewStateCnt = 0;
307: curLexState = defaultLexState;
308: input_stream = stream;
309: ReInitRounds();
310: }
311:
312: private final void ReInitRounds() {
313: int i;
314: jjround = 0x80000001;
315: for (i = 4; i-- > 0;)
316: jjrounds[i] = 0x80000000;
317: }
318:
319: public void ReInit(SimpleCharStream stream, int lexState) {
320: ReInit(stream);
321: SwitchTo(lexState);
322: }
323:
324: public void SwitchTo(int lexState) {
325: if (lexState >= 1 || lexState < 0)
326: throw new TokenMgrError(
327: "Error: Ignoring invalid lexical state : "
328: + lexState + ". State unchanged.",
329: TokenMgrError.INVALID_LEXICAL_STATE);
330: else
331: curLexState = lexState;
332: }
333:
334: protected Token jjFillToken() {
335: Token t = Token.newToken(jjmatchedKind);
336: t.kind = jjmatchedKind;
337: String im = jjstrLiteralImages[jjmatchedKind];
338: t.image = (im == null) ? input_stream.GetImage() : im;
339: t.beginLine = input_stream.getBeginLine();
340: t.beginColumn = input_stream.getBeginColumn();
341: t.endLine = input_stream.getEndLine();
342: t.endColumn = input_stream.getEndColumn();
343: return t;
344: }
345:
346: int curLexState = 0;
347: int defaultLexState = 0;
348: int jjnewStateCnt;
349: int jjround;
350: int jjmatchedPos;
351: int jjmatchedKind;
352:
353: public Token getNextToken() {
354: int kind;
355: Token specialToken = null;
356: Token matchedToken;
357: int curPos = 0;
358:
359: EOFLoop: for (;;) {
360: try {
361: curChar = input_stream.BeginToken();
362: } catch (java.io.IOException e) {
363: jjmatchedKind = 0;
364: matchedToken = jjFillToken();
365: return matchedToken;
366: }
367:
368: jjmatchedKind = 0x7fffffff;
369: jjmatchedPos = 0;
370: curPos = jjMoveStringLiteralDfa0_0();
371: if (jjmatchedKind != 0x7fffffff) {
372: if (jjmatchedPos + 1 < curPos)
373: input_stream.backup(curPos - jjmatchedPos - 1);
374: matchedToken = jjFillToken();
375: return matchedToken;
376: }
377: int error_line = input_stream.getEndLine();
378: int error_column = input_stream.getEndColumn();
379: String error_after = null;
380: boolean EOFSeen = false;
381: try {
382: input_stream.readChar();
383: input_stream.backup(1);
384: } catch (java.io.IOException e1) {
385: EOFSeen = true;
386: error_after = curPos <= 1 ? "" : input_stream
387: .GetImage();
388: if (curChar == '\n' || curChar == '\r') {
389: error_line++;
390: error_column = 0;
391: } else
392: error_column++;
393: }
394: if (!EOFSeen) {
395: input_stream.backup(1);
396: error_after = curPos <= 1 ? "" : input_stream
397: .GetImage();
398: }
399: throw new TokenMgrError(EOFSeen, curLexState, error_line,
400: error_column, error_after, curChar,
401: TokenMgrError.LEXICAL_ERROR);
402: }
403: }
404:
405: }
|