public IElementType advance() throws java.io.IOException
  {
    int zzInput;
    int zzAction;

    // cached fields:
    int zzCurrentPosL;
    int zzMarkedPosL;
    int zzEndReadL = zzEndRead;
    CharSequence zzBufferL = zzBuffer;

    int [] zzTransL = ZZ_TRANS;
    int [] zzRowMapL = ZZ_ROWMAP;
    int [] zzAttrL = ZZ_ATTRIBUTE;

    while (true) {
      zzMarkedPosL = zzMarkedPos;

      zzAction = -1;

      zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;

      zzState = ZZ_LEXSTATE[zzLexicalState];

      // set up zzAction for empty match case:
      int zzAttributes = zzAttrL[zzState];
      if ( (zzAttributes & 1) == 1 ) {
        zzAction = zzState;
      }


      zzForAction: {
        while (true) {

          if (zzCurrentPosL < zzEndReadL) {
            zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL);
            zzCurrentPosL += Character.charCount(zzInput);
          }
          else if (zzAtEOF) {
            zzInput = YYEOF;
            break zzForAction;
          }
          else {
            // store back cached positions
            zzCurrentPos  = zzCurrentPosL;
            zzMarkedPos   = zzMarkedPosL;
            boolean eof = zzRefill();
            // get translated positions and possibly new buffer
            zzCurrentPosL  = zzCurrentPos;
            zzMarkedPosL   = zzMarkedPos;
            zzBufferL      = zzBuffer;
            zzEndReadL     = zzEndRead;
            if (eof) {
              zzInput = YYEOF;
              break zzForAction;
            }
            else {
              zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL);
              zzCurrentPosL += Character.charCount(zzInput);
            }
          }
          int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMap(zzInput) ];
          if (zzNext == -1) break zzForAction;
          zzState = zzNext;

          zzAttributes = zzAttrL[zzState];
          if ( (zzAttributes & 1) == 1 ) {
            zzAction = zzState;
            zzMarkedPosL = zzCurrentPosL;
            if ( (zzAttributes & 8) == 8 ) break zzForAction;
          }

        }
      }

      // store back cached position
      zzMarkedPos = zzMarkedPosL;

      if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
        zzAtEOF = true;
        return null;
      }
      else {
        switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
          case 1:
            { yybegin(YYINITIAL);   return XPathTokenTypes.BAD_CHARACTER;
            }
          // fall through
          case 81: break;
          case 2:
            { return XPathTokenTypes.WHITESPACE;
            }
          // fall through
          case 82: break;
          case 3:
            { yybegin(S1);          return XPathTokenTypes.STRING_LITERAL;
            }
          // fall through
          case 83: break;
          case 4:
            { yybegin(VAR);         return XPathTokenTypes.DOLLAR;
            }
          // fall through
          case 84: break;
          case 5:
            { yybegin(YYINITIAL);   return XPathTokenTypes.LPAREN;
            }
          // fall through
          case 85: break;
          case 6:
            { yybegin(S1);          return XPathTokenTypes.RPAREN;
            }
          // fall through
          case 86: break;
          case 7:
            { yybegin(S1);          return XPathTokenTypes.STAR;
            }
          // fall through
          case 87: break;
          case 8:
            { yybegin(YYINITIAL);   return XPathTokenTypes.PLUS;
            }
          // fall through
          case 88: break;
          case 9:
            { yybegin(YYINITIAL);   return XPathTokenTypes.COMMA;
            }
          // fall through
          case 89: break;
          case 10:
            { yybegin(YYINITIAL);   return XPathTokenTypes.MINUS;
            }
          // fall through
          case 90: break;
          case 11:
            { yybegin(S1);          return XPathTokenTypes.DOT;
            }
          // fall through
          case 91: break;
          case 12:
            { yybegin(YYINITIAL);   return XPathTokenTypes.PATH;
            }
          // fall through
          case 92: break;
          case 13:
            { yybegin(S1);          return XPathTokenTypes.NUMBER;
            }
          // fall through
          case 93: break;
          case 14:
            { yybegin(YYINITIAL);   return XPathTokenTypes.COL;
            }
          // fall through
          case 94: break;
          case 15:
            { yybegin(YYINITIAL);   return XPathTokenTypes.LT;
            }
          // fall through
          case 95: break;
          case 16:
            { yybegin(YYINITIAL);   return XPathTokenTypes.EQ;
            }
          // fall through
          case 96: break;
          case 17:
            { yybegin(YYINITIAL);   return XPathTokenTypes.GT;
            }
          // fall through
          case 97: break;
          case 18:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.QUEST; } else { return XPathTokenTypes.BAD_CHARACTER; }
            }
          // fall through
          case 98: break;
          case 19:
            { yybegin(YYINITIAL);   return XPathTokenTypes.AT;
            }
          // fall through
          case 99: break;
          case 20:
            { yybegin(S1);          return XPathTokenTypes.NCNAME;
            }
          // fall through
          case 100: break;
          case 21:
            { yybegin(YYINITIAL);   return XPathTokenTypes.LBRACKET;
            }
          // fall through
          case 101: break;
          case 22:
            { yybegin(S1);          return XPathTokenTypes.RBRACKET;
            }
          // fall through
          case 102: break;
          case 23:
            { return XPathTokenTypes.LBRACE;
            }
          // fall through
          case 103: break;
          case 24:
            { yybegin(YYINITIAL);   return XPathTokenTypes.UNION;
            }
          // fall through
          case 104: break;
          case 25:
            { return XPathTokenTypes.RBRACE;
            }
          // fall through
          case 105: break;
          case 26:
            { yybegin(YYINITIAL);   return XPathTokenTypes.MULT;
            }
          // fall through
          case 106: break;
          case 27:
            { return XPathTokenTypes.COL;
            }
          // fall through
          case 107: break;
          case 28:
            { yybegin(S1);          return XPathTokenTypes.VARIABLE_NAME;
            }
          // fall through
          case 108: break;
          case 29:
            { return XPathTokenTypes.LPAREN;
            }
          // fall through
          case 109: break;
          case 30:
            { return XPathTokenTypes.RPAREN;
            }
          // fall through
          case 110: break;
          case 31:
            { yybegin(S1); return XPathTokenTypes.STAR;
            }
          // fall through
          case 111: break;
          case 32:
            { yybegin(S1); return XPathTokenTypes.PLUS;
            }
          // fall through
          case 112: break;
          case 33:
            { yybegin(S1); return XPath2TokenTypes.QUEST;
            }
          // fall through
          case 113: break;
          case 34:
            { return XPathTokenTypes.NCNAME;
            }
          // fall through
          case 114: break;
          case 35:
            { yybegin(YYINITIAL);   return XPathTokenTypes.NE;
            }
          // fall through
          case 115: break;
          case 36:
            { if (allowXPath2Syntax) { readComment(); return XPath2TokenTypes.COMMENT; } else { yypushback(1); return XPathTokenTypes.LPAREN; }
            }
          // fall through
          case 116: break;
          case 37:
            { yybegin(S1);          return XPathTokenTypes.DOTDOT;
            }
          // fall through
          case 117: break;
          case 38:
            { yybegin(YYINITIAL);   return XPathTokenTypes.ANY_PATH;
            }
          // fall through
          case 118: break;
          case 39:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.END_COMMENT;            } else { yypushback(1); return XPathTokenTypes.COL;    }
            }
          // fall through
          case 119: break;
          case 40:
            { yybegin(YYINITIAL);   return XPathTokenTypes.COLCOL;
            }
          // fall through
          case 120: break;
          case 41:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.BEFORE; } else { yypushback(1); return XPathTokenTypes.LT; }
            }
          // fall through
          case 121: break;
          case 42:
            { yybegin(YYINITIAL);   return XPathTokenTypes.LE;
            }
          // fall through
          case 122: break;
          case 43:
            { yybegin(YYINITIAL);   return XPathTokenTypes.GE;
            }
          // fall through
          case 123: break;
          case 44:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.AFTER;  } else { yypushback(1); return XPathTokenTypes.GT; }
            }
          // fall through
          case 124: break;
          case 45:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.WEQ; } else { return ncName(); }
            }
          // fall through
          case 125: break;
          case 46:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.WGE; } else { return ncName(); }
            }
          // fall through
          case 126: break;
          case 47:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.WGT; } else { return ncName(); }
            }
          // fall through
          case 127: break;
          case 48:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.IF;        } else { return ncName(); }
            }
          // fall through
          case 128: break;
          case 49:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.IS;     } else { return ncName(); }
            }
          // fall through
          case 129: break;
          case 50:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.WLE; } else { return ncName(); }
            }
          // fall through
          case 130: break;
          case 51:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.WLT; } else { return ncName(); }
            }
          // fall through
          case 131: break;
          case 52:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.WNE; } else { return ncName(); }
            }
          // fall through
          case 132: break;
          case 53:
            { if (allowXPath2Syntax) { yybegin(TYPE); return XPath2TokenTypes.AS;        } else { return ncName(); }
            }
          // fall through
          case 133: break;
          case 54:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.IN;        } else { return ncName(); }
            }
          // fall through
          case 134: break;
          case 55:
            { if (allowXPath2Syntax) { yybegin(TYPE); return XPath2TokenTypes.OF;        } else { return ncName(); }
            }
          // fall through
          case 135: break;
          case 56:
            { yybegin(YYINITIAL);   return XPathTokenTypes.OR;
            }
          // fall through
          case 136: break;
          case 57:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.TO;        } else { return ncName(); }
            }
          // fall through
          case 137: break;
          case 58:
            // general lookahead, find correct zzMarkedPos
            { int zzFState = 4;
              int zzFPos = zzStartRead;
              if (zzFin == null || zzFin.size() <= zzBufferL.length()) {
                zzFin = new BitSet(zzBufferL.length()+1);
              }
              BitSet zzFinL = zzFin;
              while (zzFState != -1 && zzFPos < zzMarkedPos) {
                zzFinL.set(zzFPos, ((zzAttrL[zzFState] & 1) == 1));
                zzInput = Character.codePointAt(zzBufferL, zzFPos);
                zzFPos += Character.charCount(zzInput);
                zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMap(zzInput) ];
              }
              if (zzFState != -1) {
                zzFinL.set(zzFPos++, ((zzAttrL[zzFState] & 1) == 1));
              }
              while (zzFPos <= zzMarkedPos) {
                zzFinL.clear(zzFPos++);
              }

              zzFState = 5;
              zzFPos = zzMarkedPos;
              while (!zzFinL.get(zzFPos) || (zzAttrL[zzFState] & 1) != 1) {
                zzInput = Character.codePointBefore(zzBufferL, zzFPos);
                zzFPos -= Character.charCount(zzInput);
                zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMap(zzInput) ];
              };
              zzMarkedPos = zzFPos;
            }
            { return XPathTokenTypes.VARIABLE_PREFIX;
            }
          // fall through
          case 138: break;
          case 59:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.FOR;       } else { return ncName(); }
            }
          // fall through
          case 139: break;
          case 60:
            { yybegin(YYINITIAL);   return XPathTokenTypes.AND;
            }
          // fall through
          case 140: break;
          case 61:
            { yybegin(YYINITIAL);   return XPathTokenTypes.DIV;
            }
          // fall through
          case 141: break;
          case 62:
            { yybegin(YYINITIAL);   return XPathTokenTypes.MOD;
            }
          // fall through
          case 142: break;
          case 63:
            { yybegin(S1);          return XPathTokenTypes.NODE_TYPE;
            }
          // fall through
          case 143: break;
          case 64:
            { yybegin(S1);          return XPathTokenTypes.AXIS_NAME;
            }
          // fall through
          case 144: break;
          case 65:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.SOME;      } else { return ncName(); }
            }
          // fall through
          case 145: break;
          case 66:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.CAST;      } else { return ncName(); }
            }
          // fall through
          case 146: break;
          case 67:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.ELSE;      } else { return ncName(); }
            }
          // fall through
          case 147: break;
          case 68:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL);   return XPath2TokenTypes.IDIV; } else { return ncName(); }
            }
          // fall through
          case 148: break;
          case 69:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.THEN;      } else { return ncName(); }
            }
          // fall through
          case 149: break;
          case 70:
            { return  XPath2TokenTypes.ITEM;
            }
          // fall through
          case 150: break;
          case 71:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.EVERY;     } else { return ncName(); }
            }
          // fall through
          case 151: break;
          case 72:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.TREAT;     } else { return ncName(); }
            }
          // fall through
          case 152: break;
          case 73:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.UNION;     } else { return ncName(); }
            }
          // fall through
          case 153: break;
          case 74:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.EXCEPT;    } else { return ncName(); }
            }
          // fall through
          case 154: break;
          case 75:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.RETURN;    } else { return ncName(); }
            }
          // fall through
          case 155: break;
          case 76:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.CASTABLE;  } else { return ncName(); }
            }
          // fall through
          case 156: break;
          case 77:
            { if (allowXPath2Syntax) { return XPath2TokenTypes.INSTANCE;  } else { return ncName(); }
            }
          // fall through
          case 157: break;
          case 78:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.INTERSECT; } else { return ncName(); }
            }
          // fall through
          case 158: break;
          case 79:
            { if (allowXPath2Syntax) { yybegin(YYINITIAL); return XPath2TokenTypes.SATISFIES; } else { return ncName(); }
            }
          // fall through
          case 159: break;
          case 80:
            { yybegin(YYINITIAL); return XPath2TokenTypes.EMPTY_SEQUENCE;
            }
          // fall through
          case 160: break;
          default:
            zzScanError(ZZ_NO_MATCH);
          }
      }
    }
  }
public IElementType advance()