/* Generated By:JavaCC: Do not edit this line. CCParserTokenManager.java */

/*
Copyright (C) 2014 Martin Frické (mfricke@u.arizona.edu http://softoption.us mfricke@softoption.us)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, 
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package us.softoption.parser;

/** Token Manager. */
public class CCParserTokenManager implements CCParserConstants
{

  /** Debug output. */
  public  java.io.PrintStream debugStream = System.out;
  /** Set debug output. */
  public  void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
private final int jjStopStringLiteralDfa_0(int pos, long active0)
{
   switch (pos)
   {
      default :
         return -1;
   }
}
private final int jjStartNfa_0(int pos, long active0)
{
   return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
}
private int jjStopAtPos(int pos, int kind)
{
   jjmatchedKind = kind;
   jjmatchedPos = pos;
   return pos + 1;
}
private int jjMoveStringLiteralDfa0_0()
{
   switch(curChar)
   {
      case 39:
         return jjStopAtPos(0, 37);
      case 40:
         return jjStopAtPos(0, 24);
      case 41:
         return jjStopAtPos(0, 25);
      case 44:
         return jjStopAtPos(0, 33);
      case 47:
         return jjStopAtPos(0, 30);
      case 58:
         return jjStopAtPos(0, 34);
      case 60:
         return jjStopAtPos(0, 31);
      case 61:
         return jjStopAtPos(0, 10);
      case 62:
         return jjStopAtPos(0, 32);
      case 91:
         return jjStopAtPos(0, 26);
      case 93:
         return jjStopAtPos(0, 27);
      case 123:
         return jjStopAtPos(0, 28);
      case 124:
         return jjStopAtPos(0, 35);
      case 125:
         return jjStopAtPos(0, 29);
      case 8472:
         return jjStopAtPos(0, 36);
      case 8704:
         return jjStopAtPos(0, 17);
      case 8707:
         jjmatchedKind = 18;
         return jjMoveStringLiteralDfa1_0(0x80000L);
      case 8744:
         return jjStopAtPos(0, 21);
      case 8745:
         return jjStopAtPos(0, 40);
      case 8746:
         return jjStopAtPos(0, 41);
      default :
         return jjMoveNfa_0(0, 0);
   }
}
private int jjMoveStringLiteralDfa1_0(long active0)
{
   try { curChar = input_stream.readChar(); }
   catch(java.io.IOException e) {
      jjStopStringLiteralDfa_0(0, active0);
      return 1;
   }
   switch(curChar)
   {
      case 33:
         if ((active0 & 0x80000L) != 0L)
            return jjStopAtPos(1, 19);
         break;
      default :
         break;
   }
   return jjStartNfa_0(0, active0);
}
static final long[] jjbitVec0 = {
   0x0L, 0x0L, 0x0L, 0x10000000L
};
static final long[] jjbitVec1 = {
   0x20L, 0x0L, 0x0L, 0x0L
};
static final long[] jjbitVec2 = {
   0x0L, 0x0L, 0x3feL, 0x0L
};
static final long[] jjbitVec3 = {
   0x0L, 0x0L, 0x20000000200000L, 0x0L
};
static final long[] jjbitVec4 = {
   0x300L, 0x0L, 0x4L, 0x0L
};
static final long[] jjbitVec5 = {
   0x0L, 0x0L, 0x3000000000L, 0x0L
};
static final long[] jjbitVec6 = {
   0x0L, 0x0L, 0x100000000000L, 0x0L
};
static final long[] jjbitVec7 = {
   0x1000000000000000L, 0x0L, 0x0L, 0x0L
};
static final long[] jjbitVec8 = {
   0x0L, 0x0L, 0x0L, 0x80000000L
};
static final long[] jjbitVec9 = {
   0x0L, 0x0L, 0x0L, 0x580L
};
static final long[] jjbitVec10 = {
   0x0L, 0x0L, 0x100000L, 0x0L
};
static final long[] jjbitVec11 = {
   0x0L, 0x0L, 0x200000000L, 0x0L
};
static final long[] jjbitVec12 = {
   0x0L, 0x0L, 0x400000004000000L, 0x0L
};
static final long[] jjbitVec13 = {
   0x0L, 0x0L, 0x200000000L, 0x2L
};
static final long[] jjbitVec14 = {
   0x8000000000L, 0x0L, 0x0L, 0x0L
};
static final long[] jjbitVec15 = {
   0x0L, 0x0L, 0x40000L, 0x0L
};
static final long[] jjbitVec16 = {
   0x0L, 0x0L, 0x8L, 0x0L
};
static final long[] jjbitVec17 = {
   0x0L, 0x200000000L, 0x0L, 0x0L
};
static final long[] jjbitVec18 = {
   0x0L, 0x0L, 0x0L, 0x800000L
};
private int jjMoveNfa_0(int startState, int curPos)
{
   int startsAt = 0;
   jjnewStateCnt = 19;
   int i = 1;
   jjstateSet[0] = startState;
   int kind = 0x7fffffff;
   for (;;)
   {
      if (++jjround == 0x7fffffff)
         ReInitRounds();
      if (curChar < 64)
      {
         long l = 1L << curChar;
         do
         {
            switch(jjstateSet[--i])
            {
               case 0:
                  if ((0x3ff000000000000L & l) != 0L)
                  {
                     if (kind > 5)
                        kind = 5;
                  }
                  else if ((0x280000000000L & l) != 0L)
                  {
                     if (kind > 39)
                        kind = 39;
                  }
                  else if (curChar == 46)
                  {
                     if (kind > 38)
                        kind = 38;
                  }
                  else if (curChar == 38)
                  {
                     if (kind > 20)
                        kind = 20;
                  }
                  break;
               case 14:
                  if (curChar == 38)
                     kind = 20;
                  break;
               case 17:
                  if (curChar == 46)
                     kind = 38;
                  break;
               case 18:
                  if ((0x280000000000L & l) != 0L)
                     kind = 39;
                  break;
               default : break;
            }
         } while(i != startsAt);
      }
      else if (curChar < 128)
      {
         long l = 1L << (curChar & 077);
         do
         {
            switch(jjstateSet[--i])
            {
               case 0:
                  if ((0x7fffffeL & l) != 0L)
                  {
                     if (kind > 8)
                        kind = 8;
                     jjstateSet[jjnewStateCnt++] = 6;
                  }
                  else if ((0x7ffffe00000000L & l) != 0L)
                  {
                     if (kind > 6)
                        kind = 6;
                     jjstateSet[jjnewStateCnt++] = 2;
                  }
                  else if ((0x780000000000000L & l) != 0L)
                  {
                     if (kind > 7)
                        kind = 7;
                     jjstateSet[jjnewStateCnt++] = 4;
                  }
                  else if (curChar == 126)
                  {
                     if (kind > 12)
                        kind = 12;
                  }
                  break;
               case 1:
                  if ((0x7ffffe00000000L & l) == 0L)
                     break;
                  kind = 6;
                  jjstateSet[jjnewStateCnt++] = 2;
                  break;
               case 3:
                  if ((0x780000000000000L & l) == 0L)
                     break;
                  kind = 7;
                  jjstateSet[jjnewStateCnt++] = 4;
                  break;
               case 5:
                  if ((0x7fffffeL & l) == 0L)
                     break;
                  kind = 8;
                  jjstateSet[jjnewStateCnt++] = 6;
                  break;
               case 9:
                  if (curChar == 126)
                     kind = 12;
                  break;
               default : break;
            }
         } while(i != startsAt);
      }
      else
      {
         int hiByte = (int)(curChar >> 8);
         int i1 = hiByte >> 6;
         long l1 = 1L << (hiByte & 077);
         int i2 = (curChar & 0xff) >> 6;
         long l2 = 1L << (curChar & 077);
         do
         {
            switch(jjstateSet[--i])
            {
               case 0:
                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 5)
                        kind = 5;
                  }
                  if (jjCanMove_2(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 9)
                        kind = 9;
                  }
                  if (jjCanMove_3(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 11)
                        kind = 11;
                  }
                  if (jjCanMove_4(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 12)
                        kind = 12;
                  }
                  if (jjCanMove_5(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 13)
                        kind = 13;
                  }
                  if (jjCanMove_6(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 14)
                        kind = 14;
                  }
                  if (jjCanMove_7(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 15)
                        kind = 15;
                  }
                  if (jjCanMove_8(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 16)
                        kind = 16;
                  }
                  if (jjCanMove_9(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 20)
                        kind = 20;
                  }
                  if (jjCanMove_10(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 22)
                        kind = 22;
                  }
                  if (jjCanMove_11(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 23)
                        kind = 23;
                  }
                  if (jjCanMove_12(hiByte, i1, i2, l1, l2))
                  {
                     if (kind > 38)
                        kind = 38;
                  }
                  break;
               case 2:
                  if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
                     break;
                  if (kind > 6)
                     kind = 6;
                  jjstateSet[jjnewStateCnt++] = 2;
                  break;
               case 4:
                  if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
                     break;
                  if (kind > 7)
                     kind = 7;
                  jjstateSet[jjnewStateCnt++] = 4;
                  break;
               case 6:
                  if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
                     break;
                  if (kind > 8)
                     kind = 8;
                  jjstateSet[jjnewStateCnt++] = 6;
                  break;
               case 7:
                  if (jjCanMove_2(hiByte, i1, i2, l1, l2) && kind > 9)
                     kind = 9;
                  break;
               case 8:
                  if (jjCanMove_3(hiByte, i1, i2, l1, l2) && kind > 11)
                     kind = 11;
                  break;
               case 9:
                  if (jjCanMove_4(hiByte, i1, i2, l1, l2) && kind > 12)
                     kind = 12;
                  break;
               case 10:
                  if (jjCanMove_5(hiByte, i1, i2, l1, l2) && kind > 13)
                     kind = 13;
                  break;
               case 11:
                  if (jjCanMove_6(hiByte, i1, i2, l1, l2) && kind > 14)
                     kind = 14;
                  break;
               case 12:
                  if (jjCanMove_7(hiByte, i1, i2, l1, l2) && kind > 15)
                     kind = 15;
                  break;
               case 13:
                  if (jjCanMove_8(hiByte, i1, i2, l1, l2) && kind > 16)
                     kind = 16;
                  break;
               case 14:
                  if (jjCanMove_9(hiByte, i1, i2, l1, l2) && kind > 20)
                     kind = 20;
                  break;
               case 15:
                  if (jjCanMove_10(hiByte, i1, i2, l1, l2) && kind > 22)
                     kind = 22;
                  break;
               case 16:
                  if (jjCanMove_11(hiByte, i1, i2, l1, l2) && kind > 23)
                     kind = 23;
                  break;
               case 17:
                  if (jjCanMove_12(hiByte, i1, i2, l1, l2) && kind > 38)
                     kind = 38;
                  break;
               default : break;
            }
         } while(i != startsAt);
      }
      if (kind != 0x7fffffff)
      {
         jjmatchedKind = kind;
         jjmatchedPos = curPos;
         kind = 0x7fffffff;
      }
      ++curPos;
      if ((i = jjnewStateCnt) == (startsAt = 19 - (jjnewStateCnt = startsAt)))
         return curPos;
      try { curChar = input_stream.readChar(); }
      catch(java.io.IOException e) { return curPos; }
   }
}
static final int[] jjnextStates = {
};
private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 0:
         return ((jjbitVec0[i2] & l2) != 0L);
      case 34:
         return ((jjbitVec1[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 32:
         return ((jjbitVec2[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 3:
         return ((jjbitVec3[i2] & l2) != 0L);
      case 34:
         return ((jjbitVec4[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_3(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 34:
         return ((jjbitVec5[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_4(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 0:
         return ((jjbitVec6[i2] & l2) != 0L);
      case 2:
         return ((jjbitVec0[i2] & l2) != 0L);
      case 34:
         return ((jjbitVec7[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_5(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 32:
         return ((jjbitVec8[i2] & l2) != 0L);
      case 37:
         return ((jjbitVec9[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_6(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 35:
         return ((jjbitVec10[i2] & l2) != 0L);
      case 37:
         return ((jjbitVec11[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_7(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 3:
         return ((jjbitVec12[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_8(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 3:
         return ((jjbitVec13[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_9(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 34:
         return ((jjbitVec14[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_10(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 33:
         return ((jjbitVec15[i2] & l2) != 0L);
      case 34:
         return ((jjbitVec16[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_11(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 33:
         return ((jjbitVec10[i2] & l2) != 0L);
      case 34:
         return ((jjbitVec17[i2] & l2) != 0L);
      default :
         return false;
   }
}
private static final boolean jjCanMove_12(int hiByte, int i1, int i2, long l1, long l2)
{
   switch(hiByte)
   {
      case 0:
         return ((jjbitVec18[i2] & l2) != 0L);
      default :
         return false;
   }
}

/** Token literal values. */
public static final String[] jjstrLiteralImages = {
"", null, null, null, null, null, null, null, null, null, "\75", null, null, 
null, null, null, null, "\u2200", "\u2203", "\u2203\41", null, "\u2228", null, null, 
"\50", "\51", "\133", "\135", "\173", "\175", "\57", "\74", "\76", "\54", "\72", 
"\174", "\u2118", "\47", null, null, "\u2229", "\u222a", null, null, };

/** Lexer state names. */
public static final String[] lexStateNames = {
   "DEFAULT",
};
static final long[] jjtoToken = {
   0x3ffffffffe1L, 
};
static final long[] jjtoSkip = {
   0x1eL, 
};
protected JavaCharStream input_stream;
private final int[] jjrounds = new int[19];
private final int[] jjstateSet = new int[38];
protected char curChar;
/** Constructor. */
public CCParserTokenManager(JavaCharStream stream){
   if (JavaCharStream.staticFlag)
      throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
   input_stream = stream;
}

/** Constructor. */
public CCParserTokenManager(JavaCharStream stream, int lexState){
   this(stream);
   SwitchTo(lexState);
}

/** Reinitialise parser. */
public void ReInit(JavaCharStream stream)
{
   jjmatchedPos = jjnewStateCnt = 0;
   curLexState = defaultLexState;
   input_stream = stream;
   ReInitRounds();
}
private void ReInitRounds()
{
   int i;
   jjround = 0x80000001;
   for (i = 19; i-- > 0;)
      jjrounds[i] = 0x80000000;
}

/** Reinitialise parser. */
public void ReInit(JavaCharStream stream, int lexState)
{
   ReInit(stream);
   SwitchTo(lexState);
}

/** Switch to specified lex state. */
public void SwitchTo(int lexState)
{
   if (lexState >= 1 || lexState < 0)
      throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
   else
      curLexState = lexState;
}

protected Token jjFillToken()
{
   final Token t;
   final String curTokenImage;
   final int beginLine;
   final int endLine;
   final int beginColumn;
   final int endColumn;
   String im = jjstrLiteralImages[jjmatchedKind];
   curTokenImage = (im == null) ? input_stream.GetImage() : im;
   beginLine = input_stream.getBeginLine();
   beginColumn = input_stream.getBeginColumn();
   endLine = input_stream.getEndLine();
   endColumn = input_stream.getEndColumn();
   t = Token.newToken(jjmatchedKind, curTokenImage);

   t.beginLine = beginLine;
   t.endLine = endLine;
   t.beginColumn = beginColumn;
   t.endColumn = endColumn;

   return t;
}

int curLexState = 0;
int defaultLexState = 0;
int jjnewStateCnt;
int jjround;
int jjmatchedPos;
int jjmatchedKind;

/** Get the next Token. */
public Token getNextToken() 
{
  Token matchedToken;
  int curPos = 0;

  EOFLoop :
  for (;;)
  {
   try
   {
      curChar = input_stream.BeginToken();
   }
   catch(java.io.IOException e)
   {
      jjmatchedKind = 0;
      matchedToken = jjFillToken();
      return matchedToken;
   }

   try { input_stream.backup(0);
      while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
         curChar = input_stream.BeginToken();
   }
   catch (java.io.IOException e1) { continue EOFLoop; }
   jjmatchedKind = 0x7fffffff;
   jjmatchedPos = 0;
   curPos = jjMoveStringLiteralDfa0_0();
   if (jjmatchedKind != 0x7fffffff)
   {
      if (jjmatchedPos + 1 < curPos)
         input_stream.backup(curPos - jjmatchedPos - 1);
      if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
      {
         matchedToken = jjFillToken();
         return matchedToken;
      }
      else
      {
         continue EOFLoop;
      }
   }
   int error_line = input_stream.getEndLine();
   int error_column = input_stream.getEndColumn();
   String error_after = null;
   boolean EOFSeen = false;
   try { input_stream.readChar(); input_stream.backup(1); }
   catch (java.io.IOException e1) {
      EOFSeen = true;
      error_after = curPos <= 1 ? "" : input_stream.GetImage();
      if (curChar == '\n' || curChar == '\r') {
         error_line++;
         error_column = 0;
      }
      else
         error_column++;
   }
   if (!EOFSeen) {
      input_stream.backup(1);
      error_after = curPos <= 1 ? "" : input_stream.GetImage();
   }
   throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
  }
}

private void jjCheckNAdd(int state)
{
   if (jjrounds[state] != jjround)
   {
      jjstateSet[jjnewStateCnt++] = state;
      jjrounds[state] = jjround;
   }
}
private void jjAddStates(int start, int end)
{
   do {
      jjstateSet[jjnewStateCnt++] = jjnextStates[start];
   } while (start++ != end);
}
private void jjCheckNAddTwoStates(int state1, int state2)
{
   jjCheckNAdd(state1);
   jjCheckNAdd(state2);
}

}
