1 /* Generated By:JJTree&JavaCC: Do not edit this line. AddressListParserTokenManager.java */
3 * Copyright 2004 the mime4j project
\r
5 * Licensed under the Apache License, Version 2.0 (the "License");
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 package org.apache.james.mime4j.field.address.parser;
19 public class AddressListParserTokenManager implements AddressListParserConstants
21 // Keeps track of how many levels of comment nesting
\r
22 // we've encountered. This is only used when the 2nd
\r
23 // level is reached, for example ((this)), not (this).
\r
24 // This is because the outermost level must be treated
\r
25 // specially anyway, because the outermost ")" has a
\r
26 // different token type than inner ")" instances.
\r
27 static int commentNest;
28 public java.io.PrintStream debugStream = System.out;
29 public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
30 private final int jjStopStringLiteralDfa_0(int pos, long active0)
38 private final int jjStartNfa_0(int pos, long active0)
40 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
42 private final int jjStopAtPos(int pos, int kind)
48 private final int jjStartNfaWithStates_0(int pos, int kind, int state)
52 try { curChar = input_stream.readChar(); }
53 catch(java.io.IOException e) { return pos + 1; }
54 return jjMoveNfa_0(state, pos + 1);
56 private final int jjMoveStringLiteralDfa0_0()
61 return jjStopAtPos(0, 2);
63 return jjStopAtPos(0, 1);
65 return jjStopAtPos(0, 28);
67 return jjStopAtPos(0, 19);
69 return jjStopAtPos(0, 3);
71 return jjStopAtPos(0, 9);
73 return jjStopAtPos(0, 4);
75 return jjStopAtPos(0, 5);
77 return jjStopAtPos(0, 6);
79 return jjStopAtPos(0, 7);
81 return jjStopAtPos(0, 8);
83 return jjStopAtPos(0, 15);
85 return jjMoveNfa_0(1, 0);
88 private final void jjCheckNAdd(int state)
90 if (jjrounds[state] != jjround)
92 jjstateSet[jjnewStateCnt++] = state;
93 jjrounds[state] = jjround;
96 private final void jjAddStates(int start, int end)
99 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
100 } while (start++ != end);
102 private final void jjCheckNAddTwoStates(int state1, int state2)
107 private final void jjCheckNAddStates(int start, int end)
110 jjCheckNAdd(jjnextStates[start]);
111 } while (start++ != end);
113 private final void jjCheckNAddStates(int start)
115 jjCheckNAdd(jjnextStates[start]);
116 jjCheckNAdd(jjnextStates[start + 1]);
118 private final int jjMoveNfa_0(int startState, int curPos)
124 jjstateSet[0] = startState;
125 int j, kind = 0x7fffffff;
128 if (++jjround == 0x7fffffff)
132 long l = 1L << curChar;
135 switch(jjstateSet[--i])
138 if ((0xa3ffacfa00000000L & l) != 0L)
144 else if ((0x100000200L & l) != 0L)
152 if ((0x100000200L & l) == 0L)
158 if ((0xa3ffecfa00000000L & l) == 0L)
166 } while(i != startsAt);
168 else if (curChar < 128)
170 long l = 1L << (curChar & 077);
173 switch(jjstateSet[--i])
177 if ((0x7fffffffc7fffffeL & l) == 0L)
185 } while(i != startsAt);
189 int i2 = (curChar & 0xff) >> 6;
190 long l2 = 1L << (curChar & 077);
193 switch(jjstateSet[--i])
197 } while(i != startsAt);
199 if (kind != 0x7fffffff)
201 jjmatchedKind = kind;
202 jjmatchedPos = curPos;
206 if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
208 try { curChar = input_stream.readChar(); }
209 catch(java.io.IOException e) { return curPos; }
212 private final int jjStopStringLiteralDfa_2(int pos, long active0)
220 private final int jjStartNfa_2(int pos, long active0)
222 return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
224 private final int jjStartNfaWithStates_2(int pos, int kind, int state)
226 jjmatchedKind = kind;
228 try { curChar = input_stream.readChar(); }
229 catch(java.io.IOException e) { return pos + 1; }
230 return jjMoveNfa_2(state, pos + 1);
232 private final int jjMoveStringLiteralDfa0_2()
237 return jjStopAtPos(0, 22);
239 return jjStopAtPos(0, 20);
241 return jjMoveNfa_2(0, 0);
244 static final long[] jjbitVec0 = {
245 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
247 private final int jjMoveNfa_2(int startState, int curPos)
253 jjstateSet[0] = startState;
254 int j, kind = 0x7fffffff;
257 if (++jjround == 0x7fffffff)
261 long l = 1L << curChar;
264 switch(jjstateSet[--i])
276 } while(i != startsAt);
278 else if (curChar < 128)
280 long l = 1L << (curChar & 077);
283 switch(jjstateSet[--i])
289 jjstateSet[jjnewStateCnt++] = 1;
301 } while(i != startsAt);
305 int i2 = (curChar & 0xff) >> 6;
306 long l2 = 1L << (curChar & 077);
309 switch(jjstateSet[--i])
312 if ((jjbitVec0[i2] & l2) != 0L && kind > 23)
316 if ((jjbitVec0[i2] & l2) != 0L && kind > 21)
321 } while(i != startsAt);
323 if (kind != 0x7fffffff)
325 jjmatchedKind = kind;
326 jjmatchedPos = curPos;
330 if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
332 try { curChar = input_stream.readChar(); }
333 catch(java.io.IOException e) { return curPos; }
336 private final int jjStopStringLiteralDfa_4(int pos, long active0)
344 private final int jjStartNfa_4(int pos, long active0)
346 return jjMoveNfa_4(jjStopStringLiteralDfa_4(pos, active0), pos + 1);
348 private final int jjStartNfaWithStates_4(int pos, int kind, int state)
350 jjmatchedKind = kind;
352 try { curChar = input_stream.readChar(); }
353 catch(java.io.IOException e) { return pos + 1; }
354 return jjMoveNfa_4(state, pos + 1);
356 private final int jjMoveStringLiteralDfa0_4()
361 return jjStopAtPos(0, 31);
363 return jjMoveNfa_4(0, 0);
366 private final int jjMoveNfa_4(int startState, int curPos)
372 jjstateSet[0] = startState;
373 int j, kind = 0x7fffffff;
376 if (++jjround == 0x7fffffff)
380 long l = 1L << curChar;
383 switch(jjstateSet[--i])
387 if ((0xfffffffbffffffffL & l) == 0L)
399 } while(i != startsAt);
401 else if (curChar < 128)
403 long l = 1L << (curChar & 077);
406 switch(jjstateSet[--i])
409 if ((0xffffffffefffffffL & l) != 0L)
415 else if (curChar == 92)
416 jjstateSet[jjnewStateCnt++] = 1;
423 if ((0xffffffffefffffffL & l) == 0L)
431 } while(i != startsAt);
435 int i2 = (curChar & 0xff) >> 6;
436 long l2 = 1L << (curChar & 077);
439 switch(jjstateSet[--i])
443 if ((jjbitVec0[i2] & l2) == 0L)
450 if ((jjbitVec0[i2] & l2) != 0L && kind > 29)
455 } while(i != startsAt);
457 if (kind != 0x7fffffff)
459 jjmatchedKind = kind;
460 jjmatchedPos = curPos;
464 if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
466 try { curChar = input_stream.readChar(); }
467 catch(java.io.IOException e) { return curPos; }
470 private final int jjStopStringLiteralDfa_3(int pos, long active0)
478 private final int jjStartNfa_3(int pos, long active0)
480 return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1);
482 private final int jjStartNfaWithStates_3(int pos, int kind, int state)
484 jjmatchedKind = kind;
486 try { curChar = input_stream.readChar(); }
487 catch(java.io.IOException e) { return pos + 1; }
488 return jjMoveNfa_3(state, pos + 1);
490 private final int jjMoveStringLiteralDfa0_3()
495 return jjStopAtPos(0, 25);
497 return jjStopAtPos(0, 26);
499 return jjMoveNfa_3(0, 0);
502 private final int jjMoveNfa_3(int startState, int curPos)
508 jjstateSet[0] = startState;
509 int j, kind = 0x7fffffff;
512 if (++jjround == 0x7fffffff)
516 long l = 1L << curChar;
519 switch(jjstateSet[--i])
531 } while(i != startsAt);
533 else if (curChar < 128)
535 long l = 1L << (curChar & 077);
538 switch(jjstateSet[--i])
544 jjstateSet[jjnewStateCnt++] = 1;
556 } while(i != startsAt);
560 int i2 = (curChar & 0xff) >> 6;
561 long l2 = 1L << (curChar & 077);
564 switch(jjstateSet[--i])
567 if ((jjbitVec0[i2] & l2) != 0L && kind > 27)
571 if ((jjbitVec0[i2] & l2) != 0L && kind > 24)
576 } while(i != startsAt);
578 if (kind != 0x7fffffff)
580 jjmatchedKind = kind;
581 jjmatchedPos = curPos;
585 if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
587 try { curChar = input_stream.readChar(); }
588 catch(java.io.IOException e) { return curPos; }
591 private final int jjStopStringLiteralDfa_1(int pos, long active0)
599 private final int jjStartNfa_1(int pos, long active0)
601 return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
603 private final int jjStartNfaWithStates_1(int pos, int kind, int state)
605 jjmatchedKind = kind;
607 try { curChar = input_stream.readChar(); }
608 catch(java.io.IOException e) { return pos + 1; }
609 return jjMoveNfa_1(state, pos + 1);
611 private final int jjMoveStringLiteralDfa0_1()
616 return jjStopAtPos(0, 18);
618 return jjMoveNfa_1(0, 0);
621 private final int jjMoveNfa_1(int startState, int curPos)
627 jjstateSet[0] = startState;
628 int j, kind = 0x7fffffff;
631 if (++jjround == 0x7fffffff)
635 long l = 1L << curChar;
638 switch(jjstateSet[--i])
650 } while(i != startsAt);
652 else if (curChar < 128)
654 long l = 1L << (curChar & 077);
657 switch(jjstateSet[--i])
660 if ((0xffffffffc7ffffffL & l) != 0L)
665 else if (curChar == 92)
666 jjstateSet[jjnewStateCnt++] = 1;
673 if ((0xffffffffc7ffffffL & l) != 0L && kind > 17)
678 } while(i != startsAt);
682 int i2 = (curChar & 0xff) >> 6;
683 long l2 = 1L << (curChar & 077);
686 switch(jjstateSet[--i])
689 if ((jjbitVec0[i2] & l2) != 0L && kind > 17)
693 if ((jjbitVec0[i2] & l2) != 0L && kind > 16)
698 } while(i != startsAt);
700 if (kind != 0x7fffffff)
702 jjmatchedKind = kind;
703 jjmatchedPos = curPos;
707 if ((i = jjnewStateCnt) == (startsAt = 3 - (jjnewStateCnt = startsAt)))
709 try { curChar = input_stream.readChar(); }
710 catch(java.io.IOException e) { return curPos; }
713 static final int[] jjnextStates = {
715 public static final String[] jjstrLiteralImages = {
716 "", "\15", "\12", "\54", "\72", "\73", "\74", "\76", "\100", "\56", null, null,
717 null, null, null, null, null, null, null, null, null, null, null, null, null, null,
718 null, null, null, null, null, null, null, null, };
719 public static final String[] lexStateNames = {
726 public static final int[] jjnewLexState = {
727 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 0, 2, 0, -1, 3, -1, -1,
728 -1, -1, -1, 4, -1, -1, 0, -1, -1,
730 static final long[] jjtoToken = {
733 static final long[] jjtoSkip = {
736 static final long[] jjtoSpecial = {
739 static final long[] jjtoMore = {
742 protected SimpleCharStream input_stream;
743 private final int[] jjrounds = new int[3];
744 private final int[] jjstateSet = new int[6];
748 protected char curChar;
749 public AddressListParserTokenManager(SimpleCharStream stream){
750 if (SimpleCharStream.staticFlag)
751 throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
752 input_stream = stream;
754 public AddressListParserTokenManager(SimpleCharStream stream, int lexState){
758 public void ReInit(SimpleCharStream stream)
760 jjmatchedPos = jjnewStateCnt = 0;
761 curLexState = defaultLexState;
762 input_stream = stream;
765 private final void ReInitRounds()
768 jjround = 0x80000001;
769 for (i = 3; i-- > 0;)
770 jjrounds[i] = 0x80000000;
772 public void ReInit(SimpleCharStream stream, int lexState)
777 public void SwitchTo(int lexState)
779 if (lexState >= 5 || lexState < 0)
780 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
782 curLexState = lexState;
785 protected Token jjFillToken()
787 Token t = Token.newToken(jjmatchedKind);
788 t.kind = jjmatchedKind;
789 String im = jjstrLiteralImages[jjmatchedKind];
790 t.image = (im == null) ? input_stream.GetImage() : im;
791 t.beginLine = input_stream.getBeginLine();
792 t.beginColumn = input_stream.getBeginColumn();
793 t.endLine = input_stream.getEndLine();
794 t.endColumn = input_stream.getEndColumn();
799 int defaultLexState = 0;
805 public Token getNextToken()
808 Token specialToken = null;
817 curChar = input_stream.BeginToken();
819 catch(java.io.IOException e)
822 matchedToken = jjFillToken();
823 matchedToken.specialToken = specialToken;
834 jjmatchedKind = 0x7fffffff;
836 curPos = jjMoveStringLiteralDfa0_0();
839 jjmatchedKind = 0x7fffffff;
841 curPos = jjMoveStringLiteralDfa0_1();
844 jjmatchedKind = 0x7fffffff;
846 curPos = jjMoveStringLiteralDfa0_2();
849 jjmatchedKind = 0x7fffffff;
851 curPos = jjMoveStringLiteralDfa0_3();
854 jjmatchedKind = 0x7fffffff;
856 curPos = jjMoveStringLiteralDfa0_4();
859 if (jjmatchedKind != 0x7fffffff)
861 if (jjmatchedPos + 1 < curPos)
862 input_stream.backup(curPos - jjmatchedPos - 1);
863 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
865 matchedToken = jjFillToken();
866 matchedToken.specialToken = specialToken;
867 TokenLexicalActions(matchedToken);
868 if (jjnewLexState[jjmatchedKind] != -1)
869 curLexState = jjnewLexState[jjmatchedKind];
872 else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
874 if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
876 matchedToken = jjFillToken();
877 if (specialToken == null)
878 specialToken = matchedToken;
881 matchedToken.specialToken = specialToken;
882 specialToken = (specialToken.next = matchedToken);
885 if (jjnewLexState[jjmatchedKind] != -1)
886 curLexState = jjnewLexState[jjmatchedKind];
889 MoreLexicalActions();
890 if (jjnewLexState[jjmatchedKind] != -1)
891 curLexState = jjnewLexState[jjmatchedKind];
893 jjmatchedKind = 0x7fffffff;
895 curChar = input_stream.readChar();
898 catch (java.io.IOException e1) { }
900 int error_line = input_stream.getEndLine();
901 int error_column = input_stream.getEndColumn();
902 String error_after = null;
903 boolean EOFSeen = false;
904 try { input_stream.readChar(); input_stream.backup(1); }
905 catch (java.io.IOException e1) {
907 error_after = curPos <= 1 ? "" : input_stream.GetImage();
908 if (curChar == '\n' || curChar == '\r') {
916 input_stream.backup(1);
917 error_after = curPos <= 1 ? "" : input_stream.GetImage();
919 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
924 void MoreLexicalActions()
926 jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
927 switch(jjmatchedKind)
931 image = new StringBuffer();
932 image.append(input_stream.GetSuffix(jjimageLen));
934 image.deleteCharAt(image.length() - 2);
938 image = new StringBuffer();
939 image.append(input_stream.GetSuffix(jjimageLen));
941 image.deleteCharAt(image.length() - 2);
945 image = new StringBuffer();
946 image.append(input_stream.GetSuffix(jjimageLen));
952 image = new StringBuffer();
953 image.append(input_stream.GetSuffix(jjimageLen));
955 image.deleteCharAt(image.length() - 2);
959 image = new StringBuffer();
960 image.append(input_stream.GetSuffix(jjimageLen));
966 image = new StringBuffer();
967 image.append(input_stream.GetSuffix(jjimageLen));
969 --commentNest; if (commentNest == 0) SwitchTo(INCOMMENT);
973 image = new StringBuffer();
974 image.append(input_stream.GetSuffix(jjimageLen));
976 image.deleteCharAt(image.length() - 1);
980 image = new StringBuffer();
981 image.append(input_stream.GetSuffix(jjimageLen));
983 image.deleteCharAt(image.length() - 2);
989 void TokenLexicalActions(Token matchedToken)
991 switch(jjmatchedKind)
995 image = new StringBuffer();
996 image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));
997 matchedToken.image = image.toString();
1001 image = new StringBuffer();
1002 image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));
1003 matchedToken.image = image.substring(0, image.length() - 1);