QueryParserTokenManager.java

  1. /* Generated By:JavaCC: Do not edit this line. QueryParserTokenManager.java */
  2. package gate.mimir.search.query.parser;
  3. import gate.Annotation;
  4. import gate.Corpus;
  5. import gate.Document;
  6. import gate.Factory;
  7. import gate.Gate;
  8. import gate.LanguageAnalyser;
  9. import gate.creole.ANNIEConstants;
  10. import gate.creole.ExecutionException;
  11. import gate.creole.ResourceInstantiationException;
  12. import gate.util.OffsetComparator;
  13. import gate.mimir.search.query.QueryNode;
  14. import gate.mimir.search.query.SequenceQuery.Gap;
  15. import gate.mimir.ConstraintType;
  16. import gate.mimir.Constraint;
  17. import java.io.StringReader;
  18. import java.util.ArrayList;
  19. import java.util.Collections;
  20. import java.util.List;

  21. public class QueryParserTokenManager implements QueryParserConstants
  22. {
  23.   public  java.io.PrintStream debugStream = System.out;
  24.   public  void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
  25. private final int jjStopStringLiteralDfa_0(int pos, long active0)
  26. {
  27.    switch (pos)
  28.    {
  29.       case 0:
  30.          if ((active0 & 0x40L) != 0L)
  31.             return 15;
  32.          if ((active0 & 0x10000000000L) != 0L)
  33.          {
  34.             jjmatchedKind = 44;
  35.             return 2;
  36.          }
  37.          if ((active0 & 0x84800000000L) != 0L)
  38.          {
  39.             jjmatchedKind = 44;
  40.             return 46;
  41.          }
  42.          return -1;
  43.       case 1:
  44.          if ((active0 & 0x4000000000L) != 0L)
  45.             return 46;
  46.          if ((active0 & 0x90800000000L) != 0L)
  47.          {
  48.             jjmatchedKind = 44;
  49.             jjmatchedPos = 1;
  50.             return 46;
  51.          }
  52.          return -1;
  53.       case 2:
  54.          if ((active0 & 0x90800000000L) != 0L)
  55.          {
  56.             jjmatchedKind = 44;
  57.             jjmatchedPos = 2;
  58.             return 46;
  59.          }
  60.          return -1;
  61.       case 3:
  62.          if ((active0 & 0x10000000000L) != 0L)
  63.             return 46;
  64.          if ((active0 & 0x80800000000L) != 0L)
  65.          {
  66.             jjmatchedKind = 44;
  67.             jjmatchedPos = 3;
  68.             return 46;
  69.          }
  70.          return -1;
  71.       default :
  72.          return -1;
  73.    }
  74. }
  75. private final int jjStartNfa_0(int pos, long active0)
  76. {
  77.    return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
  78. }
  79. private final int jjStopAtPos(int pos, int kind)
  80. {
  81.    jjmatchedKind = kind;
  82.    jjmatchedPos = pos;
  83.    return pos + 1;
  84. }
  85. private final int jjStartNfaWithStates_0(int pos, int kind, int state)
  86. {
  87.    jjmatchedKind = kind;
  88.    jjmatchedPos = pos;
  89.    try { curChar = input_stream.readChar(); }
  90.    catch(java.io.IOException e) { return pos + 1; }
  91.    return jjMoveNfa_0(state, pos + 1);
  92. }
  93. private final int jjMoveStringLiteralDfa0_0()
  94. {
  95.    switch(curChar)
  96.    {
  97.       case 13:
  98.          jjmatchedKind = 2;
  99.          return jjMoveStringLiteralDfa1_0(0x8L);
  100.       case 34:
  101.          return jjStartNfaWithStates_0(0, 6, 15);
  102.       case 40:
  103.          return jjStopAtPos(0, 27);
  104.       case 41:
  105.          return jjStopAtPos(0, 28);
  106.       case 43:
  107.          return jjStopAtPos(0, 36);
  108.       case 44:
  109.          return jjStopAtPos(0, 32);
  110.       case 45:
  111.          return jjStopAtPos(0, 39);
  112.       case 46:
  113.          return jjStopAtPos(0, 29);
  114.       case 58:
  115.          return jjStopAtPos(0, 31);
  116.       case 60:
  117.          jjmatchedKind = 23;
  118.          return jjMoveStringLiteralDfa1_0(0x200000L);
  119.       case 61:
  120.          return jjStopAtPos(0, 30);
  121.       case 62:
  122.          jjmatchedKind = 24;
  123.          return jjMoveStringLiteralDfa1_0(0x400000L);
  124.       case 63:
  125.          return jjStopAtPos(0, 37);
  126.       case 73:
  127.          return jjMoveStringLiteralDfa1_0(0x4000000000L);
  128.       case 77:
  129.          return jjMoveStringLiteralDfa1_0(0x800000000L);
  130.       case 79:
  131.          return jjMoveStringLiteralDfa1_0(0x10000000000L);
  132.       case 82:
  133.          return jjMoveStringLiteralDfa1_0(0x80000000000L);
  134.       case 91:
  135.          return jjStopAtPos(0, 41);
  136.       case 93:
  137.          return jjStopAtPos(0, 42);
  138.       case 123:
  139.          return jjStopAtPos(0, 25);
  140.       case 125:
  141.          return jjStopAtPos(0, 26);
  142.       default :
  143.          return jjMoveNfa_0(1, 0);
  144.    }
  145. }
  146. private final int jjMoveStringLiteralDfa1_0(long active0)
  147. {
  148.    try { curChar = input_stream.readChar(); }
  149.    catch(java.io.IOException e) {
  150.       jjStopStringLiteralDfa_0(0, active0);
  151.       return 1;
  152.    }
  153.    switch(curChar)
  154.    {
  155.       case 10:
  156.          if ((active0 & 0x8L) != 0L)
  157.             return jjStopAtPos(1, 3);
  158.          break;
  159.       case 61:
  160.          if ((active0 & 0x200000L) != 0L)
  161.             return jjStopAtPos(1, 21);
  162.          else if ((active0 & 0x400000L) != 0L)
  163.             return jjStopAtPos(1, 22);
  164.          break;
  165.       case 69:
  166.          return jjMoveStringLiteralDfa2_0(active0, 0x80000000000L);
  167.       case 73:
  168.          return jjMoveStringLiteralDfa2_0(active0, 0x800000000L);
  169.       case 78:
  170.          if ((active0 & 0x4000000000L) != 0L)
  171.             return jjStartNfaWithStates_0(1, 38, 46);
  172.          break;
  173.       case 86:
  174.          return jjMoveStringLiteralDfa2_0(active0, 0x10000000000L);
  175.       default :
  176.          break;
  177.    }
  178.    return jjStartNfa_0(0, active0);
  179. }
  180. private final int jjMoveStringLiteralDfa2_0(long old0, long active0)
  181. {
  182.    if (((active0 &= old0)) == 0L)
  183.       return jjStartNfa_0(0, old0);
  184.    try { curChar = input_stream.readChar(); }
  185.    catch(java.io.IOException e) {
  186.       jjStopStringLiteralDfa_0(1, active0);
  187.       return 2;
  188.    }
  189.    switch(curChar)
  190.    {
  191.       case 69:
  192.          return jjMoveStringLiteralDfa3_0(active0, 0x10000000000L);
  193.       case 71:
  194.          return jjMoveStringLiteralDfa3_0(active0, 0x80000000000L);
  195.       case 78:
  196.          return jjMoveStringLiteralDfa3_0(active0, 0x800000000L);
  197.       default :
  198.          break;
  199.    }
  200.    return jjStartNfa_0(1, active0);
  201. }
  202. private final int jjMoveStringLiteralDfa3_0(long old0, long active0)
  203. {
  204.    if (((active0 &= old0)) == 0L)
  205.       return jjStartNfa_0(1, old0);
  206.    try { curChar = input_stream.readChar(); }
  207.    catch(java.io.IOException e) {
  208.       jjStopStringLiteralDfa_0(2, active0);
  209.       return 3;
  210.    }
  211.    switch(curChar)
  212.    {
  213.       case 69:
  214.          return jjMoveStringLiteralDfa4_0(active0, 0x80000000000L);
  215.       case 82:
  216.          if ((active0 & 0x10000000000L) != 0L)
  217.             return jjStartNfaWithStates_0(3, 40, 46);
  218.          break;
  219.       case 85:
  220.          return jjMoveStringLiteralDfa4_0(active0, 0x800000000L);
  221.       default :
  222.          break;
  223.    }
  224.    return jjStartNfa_0(2, active0);
  225. }
  226. private final int jjMoveStringLiteralDfa4_0(long old0, long active0)
  227. {
  228.    if (((active0 &= old0)) == 0L)
  229.       return jjStartNfa_0(2, old0);
  230.    try { curChar = input_stream.readChar(); }
  231.    catch(java.io.IOException e) {
  232.       jjStopStringLiteralDfa_0(3, active0);
  233.       return 4;
  234.    }
  235.    switch(curChar)
  236.    {
  237.       case 83:
  238.          if ((active0 & 0x800000000L) != 0L)
  239.             return jjStartNfaWithStates_0(4, 35, 46);
  240.          break;
  241.       case 88:
  242.          if ((active0 & 0x80000000000L) != 0L)
  243.             return jjStartNfaWithStates_0(4, 43, 46);
  244.          break;
  245.       default :
  246.          break;
  247.    }
  248.    return jjStartNfa_0(3, active0);
  249. }
  250. private final void jjCheckNAdd(int state)
  251. {
  252.    if (jjrounds[state] != jjround)
  253.    {
  254.       jjstateSet[jjnewStateCnt++] = state;
  255.       jjrounds[state] = jjround;
  256.    }
  257. }
  258. private final void jjAddStates(int start, int end)
  259. {
  260.    do {
  261.       jjstateSet[jjnewStateCnt++] = jjnextStates[start];
  262.    } while (start++ != end);
  263. }
  264. private final void jjCheckNAddTwoStates(int state1, int state2)
  265. {
  266.    jjCheckNAdd(state1);
  267.    jjCheckNAdd(state2);
  268. }
  269. private final void jjCheckNAddStates(int start, int end)
  270. {
  271.    do {
  272.       jjCheckNAdd(jjnextStates[start]);
  273.    } while (start++ != end);
  274. }
  275. private final void jjCheckNAddStates(int start)
  276. {
  277.    jjCheckNAdd(jjnextStates[start]);
  278.    jjCheckNAdd(jjnextStates[start + 1]);
  279. }
  280. static final long[] jjbitVec0 = {
  281.    0x0L, 0x0L, 0x100c00000000L, 0x0L
  282. };
  283. static final long[] jjbitVec1 = {
  284.    0x0L, 0x0L, 0x100000000000L, 0x0L
  285. };
  286. static final long[] jjbitVec2 = {
  287.    0x1ff00000fffffffeL, 0xffffffffffffc000L, 0xffffffffL, 0x600000000000000L
  288. };
  289. static final long[] jjbitVec4 = {
  290.    0x0L, 0x0L, 0x0L, 0xff7fffffff7fffffL
  291. };
  292. static final long[] jjbitVec5 = {
  293.    0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
  294. };
  295. static final long[] jjbitVec6 = {
  296.    0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffL, 0x0L
  297. };
  298. static final long[] jjbitVec7 = {
  299.    0xffffffffffffffffL, 0xffffffffffffffffL, 0x0L, 0x0L
  300. };
  301. static final long[] jjbitVec8 = {
  302.    0x3fffffffffffL, 0x0L, 0x0L, 0x0L
  303. };
  304. private final int jjMoveNfa_0(int startState, int curPos)
  305. {
  306.    int[] nextStates;
  307.    int startsAt = 0;
  308.    jjnewStateCnt = 47;
  309.    int i = 1;
  310.    jjstateSet[0] = startState;
  311.    int j, kind = 0x7fffffff;
  312.    for (;;)
  313.    {
  314.       if (++jjround == 0x7fffffff)
  315.          ReInitRounds();
  316.       if (curChar < 64)
  317.       {
  318.          long l = 1L << curChar;
  319.          MatchLoop: do
  320.          {
  321.             switch(jjstateSet[--i])
  322.             {
  323.                case 1:
  324.                   if ((0x3ff000000000000L & l) != 0L)
  325.                   {
  326.                      if (kind > 18)
  327.                         kind = 18;
  328.                      jjCheckNAdd(0);
  329.                   }
  330.                   else if ((0x4ba00000000L & l) != 0L)
  331.                   {
  332.                      if (kind > 44)
  333.                         kind = 44;
  334.                      jjCheckNAddStates(0, 2);
  335.                   }
  336.                   else if (curChar == 34)
  337.                      jjAddStates(3, 7);
  338.                   else if (curChar == 38)
  339.                   {
  340.                      if (kind > 34)
  341.                         kind = 34;
  342.                   }
  343.                   if (curChar == 36)
  344.                   {
  345.                      if (kind > 44)
  346.                         kind = 44;
  347.                      jjCheckNAdd(46);
  348.                   }
  349.                   break;
  350.                case 2:
  351.                case 46:
  352.                   if ((0x3ff001000000000L & l) == 0L)
  353.                      break;
  354.                   if (kind > 44)
  355.                      kind = 44;
  356.                   jjCheckNAdd(46);
  357.                   break;
  358.                case 0:
  359.                   if ((0x3ff000000000000L & l) == 0L)
  360.                      break;
  361.                   if (kind > 18)
  362.                      kind = 18;
  363.                   jjCheckNAdd(0);
  364.                   break;
  365.                case 4:
  366.                   if (curChar == 38 && kind > 34)
  367.                      kind = 34;
  368.                   break;
  369.                case 8:
  370.                   if ((0x4ba00000000L & l) == 0L)
  371.                      break;
  372.                   if (kind > 44)
  373.                      kind = 44;
  374.                   jjCheckNAddStates(0, 2);
  375.                   break;
  376.                case 11:
  377.                   if (curChar == 34)
  378.                      jjAddStates(3, 7);
  379.                   break;
  380.                case 12:
  381.                   if (curChar != 34)
  382.                      break;
  383.                   if (kind > 44)
  384.                      kind = 44;
  385.                   jjCheckNAddStates(0, 2);
  386.                   break;
  387.                case 30:
  388.                   if (curChar != 40)
  389.                      break;
  390.                   kind = 44;
  391.                   jjCheckNAddStates(0, 2);
  392.                   break;
  393.                case 31:
  394.                   if (curChar != 41)
  395.                      break;
  396.                   kind = 44;
  397.                   jjCheckNAddStates(0, 2);
  398.                   break;
  399.                case 32:
  400.                   if (curChar != 58)
  401.                      break;
  402.                   kind = 44;
  403.                   jjCheckNAddStates(0, 2);
  404.                   break;
  405.                case 33:
  406.                   if (curChar != 43)
  407.                      break;
  408.                   kind = 44;
  409.                   jjCheckNAddStates(0, 2);
  410.                   break;
  411.                case 34:
  412.                   if (curChar != 38)
  413.                      break;
  414.                   if (kind > 44)
  415.                      kind = 44;
  416.                   jjCheckNAddStates(0, 2);
  417.                   break;
  418.                case 36:
  419.                   if (curChar != 63)
  420.                      break;
  421.                   kind = 44;
  422.                   jjCheckNAddStates(0, 2);
  423.                   break;
  424.                case 38:
  425.                   if (curChar != 46)
  426.                      break;
  427.                   kind = 44;
  428.                   jjCheckNAddStates(0, 2);
  429.                   break;
  430.                case 39:
  431.                   if (curChar != 61)
  432.                      break;
  433.                   kind = 44;
  434.                   jjCheckNAddStates(0, 2);
  435.                   break;
  436.                case 42:
  437.                   if (curChar != 60)
  438.                      break;
  439.                   kind = 44;
  440.                   jjCheckNAddStates(0, 2);
  441.                   break;
  442.                case 43:
  443.                   if (curChar != 62)
  444.                      break;
  445.                   kind = 44;
  446.                   jjCheckNAddStates(0, 2);
  447.                   break;
  448.                case 44:
  449.                   if (curChar != 44)
  450.                      break;
  451.                   kind = 44;
  452.                   jjCheckNAddStates(0, 2);
  453.                   break;
  454.                case 45:
  455.                   if (curChar != 36)
  456.                      break;
  457.                   if (kind > 44)
  458.                      kind = 44;
  459.                   jjCheckNAdd(46);
  460.                   break;
  461.                default : break;
  462.             }
  463.          } while(i != startsAt);
  464.       }
  465.       else if (curChar < 128)
  466.       {
  467.          long l = 1L << (curChar & 077);
  468.          MatchLoop: do
  469.          {
  470.             switch(jjstateSet[--i])
  471.             {
  472.                case 1:
  473.                   if ((0x7fffffe87fffffeL & l) != 0L)
  474.                   {
  475.                      if (kind > 44)
  476.                         kind = 44;
  477.                      jjCheckNAdd(46);
  478.                   }
  479.                   else if (curChar == 92)
  480.                      jjCheckNAddStates(8, 25);
  481.                   else if (curChar == 124)
  482.                   {
  483.                      if (kind > 33)
  484.                         kind = 33;
  485.                   }
  486.                   if ((0x40000001c0000001L & l) != 0L)
  487.                   {
  488.                      if (kind > 44)
  489.                         kind = 44;
  490.                      jjCheckNAddStates(0, 2);
  491.                   }
  492.                   else if (curChar == 65)
  493.                      jjstateSet[jjnewStateCnt++] = 6;
  494.                   else if (curChar == 79)
  495.                      jjstateSet[jjnewStateCnt++] = 2;
  496.                   break;
  497.                case 15:
  498.                   if (curChar == 82)
  499.                      jjstateSet[jjnewStateCnt++] = 27;
  500.                   else if (curChar == 79)
  501.                      jjstateSet[jjnewStateCnt++] = 22;
  502.                   else if (curChar == 73)
  503.                      jjstateSet[jjnewStateCnt++] = 18;
  504.                   else if (curChar == 65)
  505.                      jjstateSet[jjnewStateCnt++] = 14;
  506.                   if (curChar == 79)
  507.                      jjstateSet[jjnewStateCnt++] = 16;
  508.                   break;
  509.                case 2:
  510.                   if ((0x7fffffe87fffffeL & l) != 0L)
  511.                   {
  512.                      if (kind > 44)
  513.                         kind = 44;
  514.                      jjCheckNAdd(46);
  515.                   }
  516.                   if (curChar == 82)
  517.                   {
  518.                      if (kind > 33)
  519.                         kind = 33;
  520.                   }
  521.                   break;
  522.                case 3:
  523.                   if (curChar == 79)
  524.                      jjstateSet[jjnewStateCnt++] = 2;
  525.                   break;
  526.                case 5:
  527.                   if (curChar == 68 && kind > 34)
  528.                      kind = 34;
  529.                   break;
  530.                case 6:
  531.                   if (curChar == 78)
  532.                      jjstateSet[jjnewStateCnt++] = 5;
  533.                   break;
  534.                case 7:
  535.                   if (curChar == 65)
  536.                      jjstateSet[jjnewStateCnt++] = 6;
  537.                   break;
  538.                case 8:
  539.                   if ((0x40000001c0000001L & l) == 0L)
  540.                      break;
  541.                   if (kind > 44)
  542.                      kind = 44;
  543.                   jjCheckNAddStates(0, 2);
  544.                   break;
  545.                case 9:
  546.                   if (curChar == 92)
  547.                      jjCheckNAddStates(8, 25);
  548.                   break;
  549.                case 10:
  550.                   if (curChar != 91)
  551.                      break;
  552.                   kind = 44;
  553.                   jjCheckNAddStates(0, 2);
  554.                   break;
  555.                case 13:
  556.                   if (curChar == 68)
  557.                      jjCheckNAdd(12);
  558.                   break;
  559.                case 14:
  560.                   if (curChar == 78)
  561.                      jjstateSet[jjnewStateCnt++] = 13;
  562.                   break;
  563.                case 16:
  564.                case 20:
  565.                   if (curChar == 82)
  566.                      jjCheckNAdd(12);
  567.                   break;
  568.                case 17:
  569.                   if (curChar == 79)
  570.                      jjstateSet[jjnewStateCnt++] = 16;
  571.                   break;
  572.                case 18:
  573.                   if (curChar == 78)
  574.                      jjCheckNAdd(12);
  575.                   break;
  576.                case 19:
  577.                   if (curChar == 73)
  578.                      jjstateSet[jjnewStateCnt++] = 18;
  579.                   break;
  580.                case 21:
  581.                   if (curChar == 69)
  582.                      jjstateSet[jjnewStateCnt++] = 20;
  583.                   break;
  584.                case 22:
  585.                   if (curChar == 86)
  586.                      jjstateSet[jjnewStateCnt++] = 21;
  587.                   break;
  588.                case 23:
  589.                   if (curChar == 79)
  590.                      jjstateSet[jjnewStateCnt++] = 22;
  591.                   break;
  592.                case 24:
  593.                   if (curChar == 88)
  594.                      jjCheckNAdd(12);
  595.                   break;
  596.                case 25:
  597.                   if (curChar == 69)
  598.                      jjstateSet[jjnewStateCnt++] = 24;
  599.                   break;
  600.                case 26:
  601.                   if (curChar == 71)
  602.                      jjstateSet[jjnewStateCnt++] = 25;
  603.                   break;
  604.                case 27:
  605.                   if (curChar == 69)
  606.                      jjstateSet[jjnewStateCnt++] = 26;
  607.                   break;
  608.                case 28:
  609.                   if (curChar == 82)
  610.                      jjstateSet[jjnewStateCnt++] = 27;
  611.                   break;
  612.                case 29:
  613.                   if (curChar != 93)
  614.                      break;
  615.                   kind = 44;
  616.                   jjCheckNAddStates(0, 2);
  617.                   break;
  618.                case 35:
  619.                   if (curChar != 124)
  620.                      break;
  621.                   if (kind > 44)
  622.                      kind = 44;
  623.                   jjCheckNAddStates(0, 2);
  624.                   break;
  625.                case 37:
  626.                   if (curChar != 92)
  627.                      break;
  628.                   if (kind > 44)
  629.                      kind = 44;
  630.                   jjCheckNAddStates(0, 2);
  631.                   break;
  632.                case 40:
  633.                   if (curChar != 123)
  634.                      break;
  635.                   kind = 44;
  636.                   jjCheckNAddStates(0, 2);
  637.                   break;
  638.                case 41:
  639.                   if (curChar != 125)
  640.                      break;
  641.                   kind = 44;
  642.                   jjCheckNAddStates(0, 2);
  643.                   break;
  644.                case 45:
  645.                   if ((0x7fffffe87fffffeL & l) == 0L)
  646.                      break;
  647.                   if (kind > 44)
  648.                      kind = 44;
  649.                   jjCheckNAdd(46);
  650.                   break;
  651.                case 46:
  652.                   if ((0x7fffffe87fffffeL & l) == 0L)
  653.                      break;
  654.                   if (kind > 44)
  655.                      kind = 44;
  656.                   jjCheckNAdd(46);
  657.                   break;
  658.                default : break;
  659.             }
  660.          } while(i != startsAt);
  661.       }
  662.       else
  663.       {
  664.          int hiByte = (int)(curChar >> 8);
  665.          int i1 = hiByte >> 6;
  666.          long l1 = 1L << (hiByte & 077);
  667.          int i2 = (curChar & 0xff) >> 6;
  668.          long l2 = 1L << (curChar & 077);
  669.          MatchLoop: do
  670.          {
  671.             switch(jjstateSet[--i])
  672.             {
  673.                case 1:
  674.                   if (jjCanMove_0(hiByte, i1, i2, l1, l2))
  675.                   {
  676.                      if (kind > 44)
  677.                         kind = 44;
  678.                      jjCheckNAddStates(0, 2);
  679.                   }
  680.                   if (jjCanMove_1(hiByte, i1, i2, l1, l2))
  681.                   {
  682.                      if (kind > 44)
  683.                         kind = 44;
  684.                      jjCheckNAdd(46);
  685.                   }
  686.                   break;
  687.                case 2:
  688.                case 46:
  689.                   if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
  690.                      break;
  691.                   if (kind > 44)
  692.                      kind = 44;
  693.                   jjCheckNAdd(46);
  694.                   break;
  695.                case 8:
  696.                   if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
  697.                      break;
  698.                   if (kind > 44)
  699.                      kind = 44;
  700.                   jjCheckNAddStates(0, 2);
  701.                   break;
  702.                case 45:
  703.                   if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
  704.                      break;
  705.                   if (kind > 44)
  706.                      kind = 44;
  707.                   jjCheckNAdd(46);
  708.                   break;
  709.                default : break;
  710.             }
  711.          } while(i != startsAt);
  712.       }
  713.       if (kind != 0x7fffffff)
  714.       {
  715.          jjmatchedKind = kind;
  716.          jjmatchedPos = curPos;
  717.          kind = 0x7fffffff;
  718.       }
  719.       ++curPos;
  720.       if ((i = jjnewStateCnt) == (startsAt = 47 - (jjnewStateCnt = startsAt)))
  721.          return curPos;
  722.       try { curChar = input_stream.readChar(); }
  723.       catch(java.io.IOException e) { return curPos; }
  724.    }
  725. }
  726. private final int jjStopStringLiteralDfa_1(int pos, long active0)
  727. {
  728.    switch (pos)
  729.    {
  730.       case 0:
  731.          if ((active0 & 0x7f80L) != 0L)
  732.             return 0;
  733.          return -1;
  734.       default :
  735.          return -1;
  736.    }
  737. }
  738. private final int jjStartNfa_1(int pos, long active0)
  739. {
  740.    return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
  741. }
  742. private final int jjStartNfaWithStates_1(int pos, int kind, int state)
  743. {
  744.    jjmatchedKind = kind;
  745.    jjmatchedPos = pos;
  746.    try { curChar = input_stream.readChar(); }
  747.    catch(java.io.IOException e) { return pos + 1; }
  748.    return jjMoveNfa_1(state, pos + 1);
  749. }
  750. private final int jjMoveStringLiteralDfa0_1()
  751. {
  752.    switch(curChar)
  753.    {
  754.       case 34:
  755.          return jjStopAtPos(0, 17);
  756.       case 92:
  757.          return jjMoveStringLiteralDfa1_1(0x7f80L);
  758.       default :
  759.          return jjMoveNfa_1(5, 0);
  760.    }
  761. }
  762. private final int jjMoveStringLiteralDfa1_1(long active0)
  763. {
  764.    try { curChar = input_stream.readChar(); }
  765.    catch(java.io.IOException e) {
  766.       jjStopStringLiteralDfa_1(0, active0);
  767.       return 1;
  768.    }
  769.    switch(curChar)
  770.    {
  771.       case 34:
  772.          if ((active0 & 0x1000L) != 0L)
  773.             return jjStopAtPos(1, 12);
  774.          break;
  775.       case 39:
  776.          if ((active0 & 0x2000L) != 0L)
  777.             return jjStopAtPos(1, 13);
  778.          break;
  779.       case 92:
  780.          if ((active0 & 0x4000L) != 0L)
  781.             return jjStopAtPos(1, 14);
  782.          break;
  783.       case 98:
  784.          if ((active0 & 0x400L) != 0L)
  785.             return jjStopAtPos(1, 10);
  786.          break;
  787.       case 102:
  788.          if ((active0 & 0x800L) != 0L)
  789.             return jjStopAtPos(1, 11);
  790.          break;
  791.       case 110:
  792.          if ((active0 & 0x80L) != 0L)
  793.             return jjStopAtPos(1, 7);
  794.          break;
  795.       case 114:
  796.          if ((active0 & 0x100L) != 0L)
  797.             return jjStopAtPos(1, 8);
  798.          break;
  799.       case 116:
  800.          if ((active0 & 0x200L) != 0L)
  801.             return jjStopAtPos(1, 9);
  802.          break;
  803.       default :
  804.          break;
  805.    }
  806.    return jjStartNfa_1(0, active0);
  807. }
  808. static final long[] jjbitVec9 = {
  809.    0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
  810. };
  811. static final long[] jjbitVec10 = {
  812.    0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
  813. };
  814. private final int jjMoveNfa_1(int startState, int curPos)
  815. {
  816.    int[] nextStates;
  817.    int startsAt = 0;
  818.    jjnewStateCnt = 7;
  819.    int i = 1;
  820.    jjstateSet[0] = startState;
  821.    int j, kind = 0x7fffffff;
  822.    for (;;)
  823.    {
  824.       if (++jjround == 0x7fffffff)
  825.          ReInitRounds();
  826.       if (curChar < 64)
  827.       {
  828.          long l = 1L << curChar;
  829.          MatchLoop: do
  830.          {
  831.             switch(jjstateSet[--i])
  832.             {
  833.                case 5:
  834.                   if ((0xfffffffbffffffffL & l) != 0L && kind > 16)
  835.                      kind = 16;
  836.                   break;
  837.                case 1:
  838.                   if ((0x3ff000000000000L & l) != 0L)
  839.                      jjstateSet[jjnewStateCnt++] = 2;
  840.                   break;
  841.                case 2:
  842.                   if ((0x3ff000000000000L & l) != 0L)
  843.                      jjstateSet[jjnewStateCnt++] = 3;
  844.                   break;
  845.                case 3:
  846.                   if ((0x3ff000000000000L & l) != 0L)
  847.                      jjstateSet[jjnewStateCnt++] = 4;
  848.                   break;
  849.                case 4:
  850.                   if ((0x3ff000000000000L & l) != 0L && kind > 15)
  851.                      kind = 15;
  852.                   break;
  853.                default : break;
  854.             }
  855.          } while(i != startsAt);
  856.       }
  857.       else if (curChar < 128)
  858.       {
  859.          long l = 1L << (curChar & 077);
  860.          MatchLoop: do
  861.          {
  862.             switch(jjstateSet[--i])
  863.             {
  864.                case 5:
  865.                   if ((0xffffffffefffffffL & l) != 0L)
  866.                   {
  867.                      if (kind > 16)
  868.                         kind = 16;
  869.                   }
  870.                   else if (curChar == 92)
  871.                      jjstateSet[jjnewStateCnt++] = 0;
  872.                   break;
  873.                case 0:
  874.                   if (curChar == 117)
  875.                      jjstateSet[jjnewStateCnt++] = 1;
  876.                   break;
  877.                case 1:
  878.                   if ((0x7e0000007eL & l) != 0L)
  879.                      jjstateSet[jjnewStateCnt++] = 2;
  880.                   break;
  881.                case 2:
  882.                   if ((0x7e0000007eL & l) != 0L)
  883.                      jjstateSet[jjnewStateCnt++] = 3;
  884.                   break;
  885.                case 3:
  886.                   if ((0x7e0000007eL & l) != 0L)
  887.                      jjstateSet[jjnewStateCnt++] = 4;
  888.                   break;
  889.                case 4:
  890.                   if ((0x7e0000007eL & l) != 0L && kind > 15)
  891.                      kind = 15;
  892.                   break;
  893.                case 6:
  894.                   if ((0xffffffffefffffffL & l) != 0L && kind > 16)
  895.                      kind = 16;
  896.                   break;
  897.                default : break;
  898.             }
  899.          } while(i != startsAt);
  900.       }
  901.       else
  902.       {
  903.          int hiByte = (int)(curChar >> 8);
  904.          int i1 = hiByte >> 6;
  905.          long l1 = 1L << (hiByte & 077);
  906.          int i2 = (curChar & 0xff) >> 6;
  907.          long l2 = 1L << (curChar & 077);
  908.          MatchLoop: do
  909.          {
  910.             switch(jjstateSet[--i])
  911.             {
  912.                case 5:
  913.                   if (jjCanMove_2(hiByte, i1, i2, l1, l2) && kind > 16)
  914.                      kind = 16;
  915.                   break;
  916.                default : break;
  917.             }
  918.          } while(i != startsAt);
  919.       }
  920.       if (kind != 0x7fffffff)
  921.       {
  922.          jjmatchedKind = kind;
  923.          jjmatchedPos = curPos;
  924.          kind = 0x7fffffff;
  925.       }
  926.       ++curPos;
  927.       if ((i = jjnewStateCnt) == (startsAt = 7 - (jjnewStateCnt = startsAt)))
  928.          return curPos;
  929.       try { curChar = input_stream.readChar(); }
  930.       catch(java.io.IOException e) { return curPos; }
  931.    }
  932. }
  933. static final int[] jjnextStates = {
  934.    8, 9, 11, 15, 17, 19, 23, 28, 10, 29, 30, 31, 32, 33, 34, 35,
  935.    36, 37, 38, 12, 39, 40, 41, 42, 43, 44,
  936. };
  937. private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
  938. {
  939.    switch(hiByte)
  940.    {
  941.       case 0:
  942.          return ((jjbitVec0[i2] & l2) != 0L);
  943.       case 32:
  944.          return ((jjbitVec1[i2] & l2) != 0L);
  945.       default :
  946.          return false;
  947.    }
  948. }
  949. private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
  950. {
  951.    switch(hiByte)
  952.    {
  953.       case 0:
  954.          return ((jjbitVec4[i2] & l2) != 0L);
  955.       case 48:
  956.          return ((jjbitVec5[i2] & l2) != 0L);
  957.       case 49:
  958.          return ((jjbitVec6[i2] & l2) != 0L);
  959.       case 51:
  960.          return ((jjbitVec7[i2] & l2) != 0L);
  961.       case 61:
  962.          return ((jjbitVec8[i2] & l2) != 0L);
  963.       default :
  964.          if ((jjbitVec2[i1] & l1) != 0L)
  965.             return true;
  966.          return false;
  967.    }
  968. }
  969. private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2)
  970. {
  971.    switch(hiByte)
  972.    {
  973.       case 0:
  974.          return ((jjbitVec10[i2] & l2) != 0L);
  975.       default :
  976.          if ((jjbitVec9[i1] & l1) != 0L)
  977.             return true;
  978.          return false;
  979.    }
  980. }
  981. public static final String[] jjstrLiteralImages = {
  982. "", null, null, null, null, null, null, null, null, null, null, null, null,
  983. null, null, null, null, null, null, null, null, "\74\75", "\76\75", "\74", "\76",
  984. "\173", "\175", "\50", "\51", "\56", "\75", "\72", "\54", null, null,
  985. "\115\111\116\125\123", "\53", "\77", "\111\116", "\55", "\117\126\105\122", "\133", "\135",
  986. "\122\105\107\105\130", null, null, null, };
  987. public static final String[] lexStateNames = {
  988.    "DEFAULT",
  989.    "IN_STRING",
  990. };
  991. public static final int[] jjnewLexState = {
  992.    -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1,
  993.    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
  994. };
  995. static final long[] jjtoToken = {
  996.    0x1fffffe60001L,
  997. };
  998. static final long[] jjtoSkip = {
  999.    0x3eL,
  1000. };
  1001. static final long[] jjtoMore = {
  1002.    0x1ffc0L,
  1003. };
  1004. protected SimpleCharStream input_stream;
  1005. private final int[] jjrounds = new int[47];
  1006. private final int[] jjstateSet = new int[94];
  1007. StringBuffer image;
  1008. int jjimageLen;
  1009. int lengthOfMatch;
  1010. protected char curChar;
  1011. public QueryParserTokenManager(SimpleCharStream stream){
  1012.    if (SimpleCharStream.staticFlag)
  1013.       throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
  1014.    input_stream = stream;
  1015. }
  1016. public QueryParserTokenManager(SimpleCharStream stream, int lexState){
  1017.    this(stream);
  1018.    SwitchTo(lexState);
  1019. }
  1020. public void ReInit(SimpleCharStream stream)
  1021. {
  1022.    jjmatchedPos = jjnewStateCnt = 0;
  1023.    curLexState = defaultLexState;
  1024.    input_stream = stream;
  1025.    ReInitRounds();
  1026. }
  1027. private final void ReInitRounds()
  1028. {
  1029.    int i;
  1030.    jjround = 0x80000001;
  1031.    for (i = 47; i-- > 0;)
  1032.       jjrounds[i] = 0x80000000;
  1033. }
  1034. public void ReInit(SimpleCharStream stream, int lexState)
  1035. {
  1036.    ReInit(stream);
  1037.    SwitchTo(lexState);
  1038. }
  1039. public void SwitchTo(int lexState)
  1040. {
  1041.    if (lexState >= 2 || lexState < 0)
  1042.       throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
  1043.    else
  1044.       curLexState = lexState;
  1045. }

  1046. protected Token jjFillToken()
  1047. {
  1048.    Token t = Token.newToken(jjmatchedKind);
  1049.    t.kind = jjmatchedKind;
  1050.    String im = jjstrLiteralImages[jjmatchedKind];
  1051.    t.image = (im == null) ? input_stream.GetImage() : im;
  1052.    t.beginLine = input_stream.getBeginLine();
  1053.    t.beginColumn = input_stream.getBeginColumn();
  1054.    t.endLine = input_stream.getEndLine();
  1055.    t.endColumn = input_stream.getEndColumn();
  1056.    return t;
  1057. }

  1058. int curLexState = 0;
  1059. int defaultLexState = 0;
  1060. int jjnewStateCnt;
  1061. int jjround;
  1062. int jjmatchedPos;
  1063. int jjmatchedKind;

  1064. public Token getNextToken()
  1065. {
  1066.   int kind;
  1067.   Token specialToken = null;
  1068.   Token matchedToken;
  1069.   int curPos = 0;

  1070.   EOFLoop :
  1071.   for (;;)
  1072.   {  
  1073.    try  
  1074.    {    
  1075.       curChar = input_stream.BeginToken();
  1076.    }    
  1077.    catch(java.io.IOException e)
  1078.    {        
  1079.       jjmatchedKind = 0;
  1080.       matchedToken = jjFillToken();
  1081.       return matchedToken;
  1082.    }
  1083.    image = null;
  1084.    jjimageLen = 0;

  1085.    for (;;)
  1086.    {
  1087.      switch(curLexState)
  1088.      {
  1089.        case 0:
  1090.          try { input_stream.backup(0);
  1091.             while (curChar <= 32 && (0x100000600L & (1L << curChar)) != 0L)
  1092.                curChar = input_stream.BeginToken();
  1093.          }
  1094.          catch (java.io.IOException e1) { continue EOFLoop; }
  1095.          jjmatchedKind = 0x7fffffff;
  1096.          jjmatchedPos = 0;
  1097.          curPos = jjMoveStringLiteralDfa0_0();
  1098.          break;
  1099.        case 1:
  1100.          jjmatchedKind = 0x7fffffff;
  1101.          jjmatchedPos = 0;
  1102.          curPos = jjMoveStringLiteralDfa0_1();
  1103.          break;
  1104.      }
  1105.      if (jjmatchedKind != 0x7fffffff)
  1106.      {
  1107.         if (jjmatchedPos + 1 < curPos)
  1108.            input_stream.backup(curPos - jjmatchedPos - 1);
  1109.         if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
  1110.         {
  1111.            matchedToken = jjFillToken();
  1112.            TokenLexicalActions(matchedToken);
  1113.        if (jjnewLexState[jjmatchedKind] != -1)
  1114.          curLexState = jjnewLexState[jjmatchedKind];
  1115.            return matchedToken;
  1116.         }
  1117.         else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
  1118.         {
  1119.          if (jjnewLexState[jjmatchedKind] != -1)
  1120.            curLexState = jjnewLexState[jjmatchedKind];
  1121.            continue EOFLoop;
  1122.         }
  1123.         MoreLexicalActions();
  1124.       if (jjnewLexState[jjmatchedKind] != -1)
  1125.         curLexState = jjnewLexState[jjmatchedKind];
  1126.         curPos = 0;
  1127.         jjmatchedKind = 0x7fffffff;
  1128.         try {
  1129.            curChar = input_stream.readChar();
  1130.            continue;
  1131.         }
  1132.         catch (java.io.IOException e1) { }
  1133.      }
  1134.      int error_line = input_stream.getEndLine();
  1135.      int error_column = input_stream.getEndColumn();
  1136.      String error_after = null;
  1137.      boolean EOFSeen = false;
  1138.      try { input_stream.readChar(); input_stream.backup(1); }
  1139.      catch (java.io.IOException e1) {
  1140.         EOFSeen = true;
  1141.         error_after = curPos <= 1 ? "" : input_stream.GetImage();
  1142.         if (curChar == '\n' || curChar == '\r') {
  1143.            error_line++;
  1144.            error_column = 0;
  1145.         }
  1146.         else
  1147.            error_column++;
  1148.      }
  1149.      if (!EOFSeen) {
  1150.         input_stream.backup(1);
  1151.         error_after = curPos <= 1 ? "" : input_stream.GetImage();
  1152.      }
  1153.      throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
  1154.    }
  1155.   }
  1156. }

  1157. void MoreLexicalActions()
  1158. {
  1159.    jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
  1160.    switch(jjmatchedKind)
  1161.    {
  1162.       case 7 :
  1163.          if (image == null)
  1164.             image = new StringBuffer();
  1165.          image.append(input_stream.GetSuffix(jjimageLen));
  1166.          jjimageLen = 0;
  1167.              image.setLength(image.length() - 2); image.append("\n");
  1168.          break;
  1169.       case 8 :
  1170.          if (image == null)
  1171.             image = new StringBuffer();
  1172.          image.append(input_stream.GetSuffix(jjimageLen));
  1173.          jjimageLen = 0;
  1174.              image.setLength(image.length() - 2); image.append("\r");
  1175.          break;
  1176.       case 9 :
  1177.          if (image == null)
  1178.             image = new StringBuffer();
  1179.          image.append(input_stream.GetSuffix(jjimageLen));
  1180.          jjimageLen = 0;
  1181.              image.setLength(image.length() - 2); image.append("\t");
  1182.          break;
  1183.       case 10 :
  1184.          if (image == null)
  1185.             image = new StringBuffer();
  1186.          image.append(input_stream.GetSuffix(jjimageLen));
  1187.          jjimageLen = 0;
  1188.              image.setLength(image.length() - 2); image.append("\b");
  1189.          break;
  1190.       case 11 :
  1191.          if (image == null)
  1192.             image = new StringBuffer();
  1193.          image.append(input_stream.GetSuffix(jjimageLen));
  1194.          jjimageLen = 0;
  1195.              image.setLength(image.length() - 2); image.append("\f");
  1196.          break;
  1197.       case 12 :
  1198.          if (image == null)
  1199.             image = new StringBuffer();
  1200.          image.append(input_stream.GetSuffix(jjimageLen));
  1201.          jjimageLen = 0;
  1202.               image.setLength(image.length() - 2); image.append("\"");
  1203.          break;
  1204.       case 13 :
  1205.          if (image == null)
  1206.             image = new StringBuffer();
  1207.          image.append(input_stream.GetSuffix(jjimageLen));
  1208.          jjimageLen = 0;
  1209.               image.setLength(image.length() - 2); image.append("\'");
  1210.          break;
  1211.       case 14 :
  1212.          if (image == null)
  1213.             image = new StringBuffer();
  1214.          image.append(input_stream.GetSuffix(jjimageLen));
  1215.          jjimageLen = 0;
  1216.               image.setLength(image.length() - 2); image.append("\\");
  1217.          break;
  1218.       case 15 :
  1219.          if (image == null)
  1220.             image = new StringBuffer();
  1221.          image.append(input_stream.GetSuffix(jjimageLen));
  1222.          jjimageLen = 0;
  1223.              String digits = image.substring(image.length() - 4, image.length());
  1224.              image.setLength(image.length() - 6);
  1225.              image.append((char)Integer.parseInt(digits, 16));
  1226.          break;
  1227.       default :
  1228.          break;
  1229.    }
  1230. }
  1231. void TokenLexicalActions(Token matchedToken)
  1232. {
  1233.    switch(jjmatchedKind)
  1234.    {
  1235.       case 17 :
  1236.         if (image == null)
  1237.             image = new StringBuffer();
  1238.             image.append(input_stream.GetSuffix(jjimageLen + (lengthOfMatch = jjmatchedPos + 1)));
  1239.     // image.setLength(image.length() - 1);
  1240.      matchedToken.image = image.toString();
  1241.          break;
  1242.       default :
  1243.          break;
  1244.    }
  1245. }
  1246. }