1 /* DataParserTokenManager.java */
2 /* Generated By:JavaCC: Do not edit this line. DataParserTokenManager.java */
3 package org.simantics.databoard.parser;
4 import org.simantics.databoard.parser.ast.type.*;
5 import org.simantics.databoard.parser.ast.value.*;
6 import java.util.ArrayList;
8 import java.util.Collections;
11 @SuppressWarnings("unused")public class DataParserTokenManager implements DataParserConstants {
14 public java.io.PrintStream debugStream = System.out;
15 /** Set debug output. */
16 public void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
17 private final int jjStopStringLiteralDfa_0(int pos, long active0){
21 if ((active0 & 0x400000000L) != 0L)
23 if ((active0 & 0x80000L) != 0L)
25 if ((active0 & 0x7e00000L) != 0L)
30 if ((active0 & 0x30000L) != 0L)
34 if ((active0 & 0x7e00000L) != 0L)
42 if ((active0 & 0x2000000L) != 0L)
44 if ((active0 & 0x5e00000L) != 0L)
52 if ((active0 & 0x1600000L) != 0L)
54 if ((active0 & 0x4800000L) != 0L)
62 if ((active0 & 0x800000L) != 0L)
64 if ((active0 & 0x4000000L) != 0L)
72 if ((active0 & 0x4000000L) != 0L)
80 if ((active0 & 0x4000000L) != 0L)
88 if ((active0 & 0x4000000L) != 0L)
99 private final int jjStartNfa_0(int pos, long active0){
100 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
102 private int jjStopAtPos(int pos, int kind)
104 jjmatchedKind = kind;
108 private int jjMoveStringLiteralDfa0_0(){
112 return jjStopAtPos(0, 13);
114 return jjStopAtPos(0, 5);
116 return jjStopAtPos(0, 6);
118 return jjStopAtPos(0, 15);
120 return jjStartNfaWithStates_0(0, 34, 34);
123 return jjMoveStringLiteralDfa1_0(0x10000L);
125 return jjStopAtPos(0, 14);
127 return jjStopAtPos(0, 4);
129 return jjStartNfaWithStates_0(0, 19, 60);
131 return jjStopAtPos(0, 18);
133 return jjStopAtPos(0, 20);
135 return jjStopAtPos(0, 7);
137 return jjStopAtPos(0, 8);
139 return jjStopAtPos(0, 9);
141 return jjMoveStringLiteralDfa1_0(0x800000L);
143 return jjMoveStringLiteralDfa1_0(0x2000000L);
145 return jjMoveStringLiteralDfa1_0(0x1000000L);
147 return jjMoveStringLiteralDfa1_0(0x4000000L);
149 return jjMoveStringLiteralDfa1_0(0x600000L);
151 return jjStopAtPos(0, 10);
153 return jjStopAtPos(0, 12);
155 return jjStopAtPos(0, 11);
157 return jjMoveNfa_0(0, 0);
160 private int jjMoveStringLiteralDfa1_0(long active0){
161 try { curChar = input_stream.readChar(); }
162 catch(java.io.IOException e) {
163 jjStopStringLiteralDfa_0(0, active0);
169 if ((active0 & 0x10000L) != 0L)
170 return jjStopAtPos(1, 16);
173 return jjMoveStringLiteralDfa2_0(active0, 0x2800000L);
175 return jjMoveStringLiteralDfa2_0(active0, 0x4000000L);
177 return jjMoveStringLiteralDfa2_0(active0, 0x400000L);
179 return jjMoveStringLiteralDfa2_0(active0, 0x1000000L);
181 return jjMoveStringLiteralDfa2_0(active0, 0x200000L);
185 return jjStartNfa_0(0, active0);
187 private int jjMoveStringLiteralDfa2_0(long old0, long active0){
188 if (((active0 &= old0)) == 0L)
189 return jjStartNfa_0(0, old0);
190 try { curChar = input_stream.readChar(); }
191 catch(java.io.IOException e) {
192 jjStopStringLiteralDfa_0(1, active0);
198 return jjMoveStringLiteralDfa3_0(active0, 0x4000000L);
200 return jjMoveStringLiteralDfa3_0(active0, 0x1800000L);
202 if ((active0 & 0x2000000L) != 0L)
203 return jjStartNfaWithStates_0(2, 25, 46);
204 return jjMoveStringLiteralDfa3_0(active0, 0x200000L);
206 return jjMoveStringLiteralDfa3_0(active0, 0x400000L);
210 return jjStartNfa_0(1, active0);
212 private int jjMoveStringLiteralDfa3_0(long old0, long active0){
213 if (((active0 &= old0)) == 0L)
214 return jjStartNfa_0(1, old0);
215 try { curChar = input_stream.readChar(); }
216 catch(java.io.IOException e) {
217 jjStopStringLiteralDfa_0(2, active0);
223 if ((active0 & 0x200000L) != 0L)
224 return jjStartNfaWithStates_0(3, 21, 46);
225 else if ((active0 & 0x400000L) != 0L)
226 return jjStartNfaWithStates_0(3, 22, 46);
227 return jjMoveStringLiteralDfa4_0(active0, 0x4000000L);
229 if ((active0 & 0x1000000L) != 0L)
230 return jjStartNfaWithStates_0(3, 24, 46);
233 return jjMoveStringLiteralDfa4_0(active0, 0x800000L);
237 return jjStartNfa_0(2, active0);
239 private int jjMoveStringLiteralDfa4_0(long old0, long active0){
240 if (((active0 &= old0)) == 0L)
241 return jjStartNfa_0(2, old0);
242 try { curChar = input_stream.readChar(); }
243 catch(java.io.IOException e) {
244 jjStopStringLiteralDfa_0(3, active0);
250 if ((active0 & 0x800000L) != 0L)
251 return jjStartNfaWithStates_0(4, 23, 46);
254 return jjMoveStringLiteralDfa5_0(active0, 0x4000000L);
258 return jjStartNfa_0(3, active0);
260 private int jjMoveStringLiteralDfa5_0(long old0, long active0){
261 if (((active0 &= old0)) == 0L)
262 return jjStartNfa_0(3, old0);
263 try { curChar = input_stream.readChar(); }
264 catch(java.io.IOException e) {
265 jjStopStringLiteralDfa_0(4, active0);
271 return jjMoveStringLiteralDfa6_0(active0, 0x4000000L);
275 return jjStartNfa_0(4, active0);
277 private int jjMoveStringLiteralDfa6_0(long old0, long active0){
278 if (((active0 &= old0)) == 0L)
279 return jjStartNfa_0(4, old0);
280 try { curChar = input_stream.readChar(); }
281 catch(java.io.IOException e) {
282 jjStopStringLiteralDfa_0(5, active0);
288 return jjMoveStringLiteralDfa7_0(active0, 0x4000000L);
292 return jjStartNfa_0(5, active0);
294 private int jjMoveStringLiteralDfa7_0(long old0, long active0){
295 if (((active0 &= old0)) == 0L)
296 return jjStartNfa_0(5, old0);
297 try { curChar = input_stream.readChar(); }
298 catch(java.io.IOException e) {
299 jjStopStringLiteralDfa_0(6, active0);
305 return jjMoveStringLiteralDfa8_0(active0, 0x4000000L);
309 return jjStartNfa_0(6, active0);
311 private int jjMoveStringLiteralDfa8_0(long old0, long active0){
312 if (((active0 &= old0)) == 0L)
313 return jjStartNfa_0(6, old0);
314 try { curChar = input_stream.readChar(); }
315 catch(java.io.IOException e) {
316 jjStopStringLiteralDfa_0(7, active0);
322 if ((active0 & 0x4000000L) != 0L)
323 return jjStartNfaWithStates_0(8, 26, 46);
328 return jjStartNfa_0(7, active0);
330 private int jjStartNfaWithStates_0(int pos, int kind, int state)
332 jjmatchedKind = kind;
334 try { curChar = input_stream.readChar(); }
335 catch(java.io.IOException e) { return pos + 1; }
336 return jjMoveNfa_0(state, pos + 1);
338 static final long[] jjbitVec0 = {
339 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
341 private int jjMoveNfa_0(int startState, int curPos)
346 jjstateSet[0] = startState;
347 int kind = 0x7fffffff;
350 if (++jjround == 0x7fffffff)
354 long l = 1L << curChar;
357 switch(jjstateSet[--i])
360 if ((0x3ff000000000000L & l) != 0L)
361 { jjCheckNAddStates(0, 3); }
362 else if (curChar == 46)
364 if ((0x3ff000000000000L & l) != 0L)
372 if ((0xafffffffffffffffL & l) != 0L)
373 { jjCheckNAddTwoStates(48, 49); }
374 else if (curChar == 62)
381 if ((0x3ff000000000000L & l) != 0L)
385 { jjCheckNAddStates(4, 8); }
387 else if ((0x100002600L & l) != 0L)
392 else if ((0x280000000000L & l) != 0L)
394 else if (curChar == 47)
395 { jjAddStates(9, 10); }
396 else if (curChar == 60)
397 { jjCheckNAddTwoStates(48, 49); }
398 else if (curChar == 46)
400 else if (curChar == 34)
401 jjstateSet[jjnewStateCnt++] = 13;
403 { jjAddStates(11, 14); }
404 else if (curChar == 34)
405 { jjCheckNAddStates(15, 17); }
409 { jjCheckNAddStates(15, 17); }
412 if ((0xfffffffbfffffbffL & l) != 0L)
413 { jjCheckNAddStates(15, 17); }
416 if ((0xfffffffffffffbffL & l) != 0L)
417 { jjCheckNAddStates(15, 17); }
420 if (curChar == 34 && kind > 27)
425 { jjCheckNAddStates(18, 20); }
428 if ((0xfffffffbffffffffL & l) != 0L)
429 { jjCheckNAddStates(18, 20); }
438 { jjAddStates(21, 22); }
441 if (curChar == 34 && kind > 28)
446 jjstateSet[jjnewStateCnt++] = 11;
450 jjstateSet[jjnewStateCnt++] = 6;
454 jjstateSet[jjnewStateCnt++] = 13;
457 if ((0x280000000000L & l) != 0L)
461 if ((0x3ff000000000000L & l) == 0L)
469 { jjAddStates(11, 14); }
476 if ((0x3ff000000000000L & l) == 0L)
480 { jjCheckNAddTwoStates(19, 20); }
483 if ((0x280000000000L & l) != 0L)
487 if ((0x3ff000000000000L & l) == 0L)
494 if ((0x3ff000000000000L & l) != 0L)
495 { jjCheckNAddTwoStates(35, 36); }
502 if ((0x3ff000000000000L & l) == 0L)
506 { jjCheckNAddTwoStates(37, 38); }
509 if ((0x280000000000L & l) != 0L)
513 if ((0x3ff000000000000L & l) == 0L)
520 if ((0x3ff000000000000L & l) != 0L)
521 { jjCheckNAddTwoStates(41, 42); }
524 if ((0x280000000000L & l) != 0L)
528 if ((0x3ff000000000000L & l) == 0L)
535 if ((0x3ff000000000000L & l) == 0L)
539 jjstateSet[jjnewStateCnt++] = 46;
543 { jjCheckNAddTwoStates(48, 49); }
546 if ((0xafffffffffffffffL & l) != 0L)
547 { jjCheckNAddTwoStates(48, 49); }
550 if (curChar == 62 && kind > 33)
555 { jjAddStates(9, 10); }
559 { jjCheckNAddStates(23, 25); }
562 if ((0xfffffbffffffffffL & l) != 0L)
563 { jjCheckNAddStates(23, 25); }
567 jjstateSet[jjnewStateCnt++] = 54;
570 if ((0xffff7fffffffffffL & l) != 0L)
571 { jjCheckNAddStates(23, 25); }
574 if (curChar == 47 && kind > 2)
579 jjstateSet[jjnewStateCnt++] = 55;
589 if ((0xfffffffffffffbffL & l) == 0L)
596 if ((0x3ff000000000000L & l) == 0L)
600 { jjCheckNAddStates(4, 8); }
604 } while(i != startsAt);
606 else if (curChar < 128)
608 long l = 1L << (curChar & 077);
611 switch(jjstateSet[--i])
615 jjstateSet[jjnewStateCnt++] = 32;
616 else if (curChar == 78)
617 jjstateSet[jjnewStateCnt++] = 24;
621 { jjCheckNAddTwoStates(48, 49); }
624 if ((0x7fffffe87fffffeL & l) != 0L)
631 jjstateSet[jjnewStateCnt++] = 32;
632 else if (curChar == 78)
633 jjstateSet[jjnewStateCnt++] = 24;
636 if ((0xffffffffefffffffL & l) != 0L)
637 { jjCheckNAddStates(15, 17); }
641 jjstateSet[jjnewStateCnt++] = 4;
644 { jjCheckNAddStates(15, 17); }
647 { jjAddStates(18, 20); }
650 if ((0x2000000020L & l) != 0L)
651 { jjAddStates(26, 27); }
654 if (curChar == 78 && kind > 31)
659 jjstateSet[jjnewStateCnt++] = 23;
663 jjstateSet[jjnewStateCnt++] = 24;
666 if (curChar == 121 && kind > 31)
671 jjstateSet[jjnewStateCnt++] = 26;
675 jjstateSet[jjnewStateCnt++] = 27;
679 jjstateSet[jjnewStateCnt++] = 28;
683 jjstateSet[jjnewStateCnt++] = 29;
687 jjstateSet[jjnewStateCnt++] = 30;
691 jjstateSet[jjnewStateCnt++] = 31;
695 jjstateSet[jjnewStateCnt++] = 32;
698 if ((0x2000000020L & l) != 0L)
699 { jjAddStates(28, 29); }
702 if ((0x2000000020L & l) != 0L)
703 { jjAddStates(30, 31); }
707 if ((0x7fffffe87fffffeL & l) == 0L)
715 { jjCheckNAddStates(23, 25); }
720 jjstateSet[jjnewStateCnt++] = 58;
724 } while(i != startsAt);
728 int i2 = (curChar & 0xff) >> 6;
729 long l2 = 1L << (curChar & 077);
732 switch(jjstateSet[--i])
736 if ((jjbitVec0[i2] & l2) != 0L)
737 { jjCheckNAddTwoStates(48, 49); }
741 if ((jjbitVec0[i2] & l2) != 0L)
742 { jjCheckNAddStates(15, 17); }
745 if ((jjbitVec0[i2] & l2) != 0L)
746 { jjAddStates(18, 20); }
750 if ((jjbitVec0[i2] & l2) != 0L)
751 { jjCheckNAddStates(23, 25); }
754 if ((jjbitVec0[i2] & l2) == 0L)
758 jjstateSet[jjnewStateCnt++] = 58;
762 } while(i != startsAt);
764 if (kind != 0x7fffffff)
766 jjmatchedKind = kind;
767 jjmatchedPos = curPos;
771 if ((i = jjnewStateCnt) == (startsAt = 60 - (jjnewStateCnt = startsAt)))
773 try { curChar = input_stream.readChar(); }
774 catch(java.io.IOException e) { return curPos; }
777 static final int[] jjnextStates = {
778 35, 36, 41, 42, 16, 35, 36, 41, 42, 51, 57, 18, 25, 33, 34, 2,
779 3, 5, 7, 8, 9, 10, 12, 52, 53, 56, 21, 22, 39, 40, 43, 44,
782 /** Token literal values. */
783 public static final String[] jjstrLiteralImages = {
784 "", null, null, null, "\73", "\50", "\51", "\77", "\133", "\135", "\173",
785 "\175", "\174", "\46", "\72", "\54", "\56\56", "\56", "\75", "\74", "\76",
786 "\164\171\160\145", "\164\162\165\145", "\146\141\154\163\145", "\156\165\154\154",
787 "\155\141\160", "\162\145\146\145\162\141\142\154\145", null, null, null, null, null, null,
789 protected Token jjFillToken()
792 final String curTokenImage;
795 final int beginColumn;
797 String im = jjstrLiteralImages[jjmatchedKind];
798 curTokenImage = (im == null) ? input_stream.GetImage() : im;
799 beginLine = input_stream.getBeginLine();
800 beginColumn = input_stream.getBeginColumn();
801 endLine = input_stream.getEndLine();
802 endColumn = input_stream.getEndColumn();
803 t = Token.newToken(jjmatchedKind);
804 t.kind = jjmatchedKind;
805 t.image = curTokenImage;
807 t.beginLine = beginLine;
809 t.beginColumn = beginColumn;
810 t.endColumn = endColumn;
816 int defaultLexState = 0;
822 /** Get the next Token. */
823 public Token getNextToken()
833 curChar = input_stream.BeginToken();
839 matchedToken = jjFillToken();
846 jjmatchedKind = 0x7fffffff;
848 curPos = jjMoveStringLiteralDfa0_0();
849 if (jjmatchedKind != 0x7fffffff)
851 if (jjmatchedPos + 1 < curPos)
852 input_stream.backup(curPos - jjmatchedPos - 1);
853 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
855 matchedToken = jjFillToken();
856 TokenLexicalActions(matchedToken);
864 int error_line = input_stream.getEndLine();
865 int error_column = input_stream.getEndColumn();
866 String error_after = null;
867 boolean EOFSeen = false;
868 try { input_stream.readChar(); input_stream.backup(1); }
869 catch (java.io.IOException e1) {
871 error_after = curPos <= 1 ? "" : input_stream.GetImage();
872 if (curChar == '\n' || curChar == '\r') {
880 input_stream.backup(1);
881 error_after = curPos <= 1 ? "" : input_stream.GetImage();
883 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
887 void TokenLexicalActions(Token matchedToken)
889 switch(jjmatchedKind)
892 image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));
893 matchedToken.image = StringEscapeUtils.unescape(
894 matchedToken.image.substring(1,matchedToken.image.length()-1));
897 image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));
898 matchedToken.image = matchedToken.image.substring(3,matchedToken.image.length()-3);
901 image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));
902 matchedToken.image = matchedToken.image.substring(1,matchedToken.image.length()-1);
908 private void jjCheckNAdd(int state)
910 if (jjrounds[state] != jjround)
912 jjstateSet[jjnewStateCnt++] = state;
913 jjrounds[state] = jjround;
916 private void jjAddStates(int start, int end)
919 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
920 } while (start++ != end);
922 private void jjCheckNAddTwoStates(int state1, int state2)
928 private void jjCheckNAddStates(int start, int end)
931 jjCheckNAdd(jjnextStates[start]);
932 } while (start++ != end);
936 public DataParserTokenManager(SimpleCharStream stream){
938 if (SimpleCharStream.staticFlag)
939 throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
941 input_stream = stream;
945 public DataParserTokenManager (SimpleCharStream stream, int lexState){
950 /** Reinitialise parser. */
951 public void ReInit(SimpleCharStream stream)
954 jjmatchedPos = jjnewStateCnt = 0;
955 curLexState = defaultLexState;
956 input_stream = stream;
960 private void ReInitRounds()
963 jjround = 0x80000001;
964 for (i = 60; i-- > 0;)
965 jjrounds[i] = 0x80000000;
968 /** Reinitialise parser. */
969 public void ReInit( SimpleCharStream stream, int lexState)
976 /** Switch to specified lex state. */
977 public void SwitchTo(int lexState)
979 if (lexState >= 1 || lexState < 0)
980 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
982 curLexState = lexState;
985 /** Lexer state names. */
986 public static final String[] lexStateNames = {
989 static final long[] jjtoToken = {
992 static final long[] jjtoSkip = {
995 protected SimpleCharStream input_stream;
997 private final int[] jjrounds = new int[60];
998 private final int[] jjstateSet = new int[2 * 60];
1000 private final StringBuilder jjimage = new StringBuilder();
1001 private StringBuilder image = jjimage;
1002 private int jjimageLen;
1003 private int lengthOfMatch;
1005 protected int curChar;