Program: 144908
Project: 144908
Buggy source:
public static Vector lex(String expr) throws XPathSyntaxException {
  Vector tokens=new Vector();
  int i=0;
  int context=LEX_CONTEXT_VAL;
  while (i < expr.length()) {
    int c=expr.charAt(i);
    int d=getChar(expr,i + 1);
    Token token=null;
    int skip=1;
    if ("String_Node_Str".indexOf(c) >= 0) {
    }
 else     if (c == '=') {
      token=new Token(Token.EQ);
    }
 else     if (c == '!' && d == '=') {
      token=new Token(Token.NEQ);
      skip=2;
    }
 else     if (c == '<') {
      if (d == '=') {
        token=new Token(Token.LTE);
        skip=2;
      }
 else {
        token=new Token(Token.LT);
      }
    }
 else     if (c == '>') {
      if (d == '=') {
        token=new Token(Token.GTE);
        skip=2;
      }
 else {
        token=new Token(Token.GT);
      }
    }
 else     if (c == '+') {
      token=new Token(Token.PLUS);
    }
 else     if (c == '-') {
      token=new Token(context == LEX_CONTEXT_VAL ? Token.UMINUS : Token.MINUS);
    }
 else     if (c == '*') {
      token=new Token(context == LEX_CONTEXT_VAL ? Token.WILDCARD : Token.MULT);
    }
 else     if (c == '|') {
      token=new Token(Token.UNION);
    }
 else     if (c == '/') {
      if (d == '/') {
        token=new Token(Token.DBL_SLASH);
        skip=2;
      }
 else {
        token=new Token(Token.SLASH);
      }
    }
 else     if (c == '[') {
      token=new Token(Token.LBRACK);
    }
 else     if (c == ']') {
      token=new Token(Token.RBRACK);
    }
 else     if (c == '(') {
      token=new Token(Token.LPAREN);
    }
 else     if (c == ')') {
      token=new Token(Token.RPAREN);
    }
 else     if (c == '.') {
      if (d == '.') {
        token=new Token(Token.DBL_DOT);
        skip=2;
      }
 else       if (isDigit(d)) {
        skip=matchNumeric(expr,i);
        token=new Token(Token.NUM,Double.valueOf(expr.substring(i,i + skip)));
      }
 else {
        token=new Token(Token.DOT);
      }
    }
 else     if (c == '@') {
      token=new Token(Token.AT);
    }
 else     if (c == ',') {
      token=new Token(Token.COMMA);
    }
 else     if (c == ':' && d == ':') {
      token=new Token(Token.DBL_COLON);
      skip=2;
    }
 else     if (context == LEX_CONTEXT_OP && i + 3 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 3))) {
      token=new Token(Token.AND);
      skip=3;
    }
 else     if (context == LEX_CONTEXT_OP && i + 2 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 2))) {
      token=new Token(Token.OR);
      skip=2;
    }
 else     if (context == LEX_CONTEXT_OP && i + 3 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 3))) {
      token=new Token(Token.DIV);
      skip=3;
    }
 else     if (context == LEX_CONTEXT_OP && i + 3 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 3))) {
      token=new Token(Token.MOD);
      skip=3;
    }
 else     if (c == '$') {
      int len=matchQName(expr,i + 1);
      if (len == 0) {
        throw new XPathSyntaxException();
      }
 else {
        token=new Token(Token.VAR,new XPathQName(expr.substring(i + 1,i + len + 1)));
        skip=len + 1;
      }
    }
 else     if (c == '\'' || c == '\"') {
      int end=expr.indexOf(c,i + 1);
      if (end == -1) {
        throw new XPathSyntaxException();
      }
 else {
        token=new Token(Token.STR,expr.substring(i + 1,end));
        skip=(end - i) + 1;
      }
    }
 else     if (isDigit(c)) {
      skip=matchNumeric(expr,i);
      token=new Token(Token.NUM,Double.valueOf(expr.substring(i,i + skip)));
    }
 else     if (context == LEX_CONTEXT_VAL && (isAlpha(c) || c == '_')) {
      int len=matchQName(expr,i);
      String name=expr.substring(i,i + len);
      if (name.indexOf(':') == -1 && getChar(expr,i + len) == ':' && getChar(expr,i + len + 1) == '*') {
        token=new Token(Token.NSWILDCARD,name);
        skip=len + 2;
      }
 else {
        token=new Token(Token.QNAME,new XPathQName(name));
        skip=len;
      }
    }
 else {
      throw new XPathSyntaxException();
    }
    if (token != null) {
      if (token.type == Token.WILDCARD || token.type == Token.NSWILDCARD || token.type == Token.QNAME || token.type == Token.VAR || token.type == Token.NUM || token.type == Token.STR || token.type == Token.RBRACK || token.type == Token.RPAREN || token.type == Token.DOT || token.type == Token.DBL_DOT) {
        context=LEX_CONTEXT_OP;
      }
 else {
        context=LEX_CONTEXT_VAL;
      }
      tokens.addElement(token);
    }
    i+=skip;
  }
  return tokens;
}

Fixed version (ground truth):
public static Vector lex(String expr) throws XPathSyntaxException {
  Vector tokens=new Vector();
  int i=0;
  int context=LEX_CONTEXT_VAL;
  while (i < expr.length()) {
    int c=expr.charAt(i);
    int d=getChar(expr,i + 1);
    Token token=null;
    int skip=1;
    if ("String_Node_Str".indexOf(c) >= 0) {
    }
 else     if (c == '=') {
      token=new Token(Token.EQ);
    }
 else     if (c == '!' && d == '=') {
      token=new Token(Token.NEQ);
      skip=2;
    }
 else     if (c == '<') {
      if (d == '=') {
        token=new Token(Token.LTE);
        skip=2;
      }
 else {
        token=new Token(Token.LT);
      }
    }
 else     if (c == '>') {
      if (d == '=') {
        token=new Token(Token.GTE);
        skip=2;
      }
 else {
        token=new Token(Token.GT);
      }
    }
 else     if (c == '+') {
      token=new Token(Token.PLUS);
    }
 else     if (c == '-') {
      token=new Token(context == LEX_CONTEXT_VAL ? Token.UMINUS : Token.MINUS);
    }
 else     if (c == '*') {
      token=new Token(context == LEX_CONTEXT_VAL ? Token.WILDCARD : Token.MULT);
    }
 else     if (c == '|') {
      token=new Token(Token.UNION);
    }
 else     if (c == '/') {
      if (d == '/') {
        token=new Token(Token.DBL_SLASH);
        skip=2;
      }
 else {
        token=new Token(Token.SLASH);
      }
    }
 else     if (c == '[') {
      token=new Token(Token.LBRACK);
    }
 else     if (c == ']') {
      token=new Token(Token.RBRACK);
    }
 else     if (c == '(') {
      token=new Token(Token.LPAREN);
    }
 else     if (c == ')') {
      token=new Token(Token.RPAREN);
    }
 else     if (c == '.') {
      if (d == '.') {
        token=new Token(Token.DBL_DOT);
        skip=2;
      }
 else       if (isDigit(d)) {
        skip=matchNumeric(expr,i);
        token=new Token(Token.NUM,Double.valueOf(expr.substring(i,i + skip)));
      }
 else {
        token=new Token(Token.DOT);
      }
    }
 else     if (c == '@') {
      token=new Token(Token.AT);
    }
 else     if (c == ',') {
      token=new Token(Token.COMMA);
    }
 else     if (c == ':' && d == ':') {
      token=new Token(Token.DBL_COLON);
      skip=2;
    }
 else     if (context == LEX_CONTEXT_OP && i + 3 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 3))) {
      token=new Token(Token.AND);
      skip=3;
    }
 else     if (context == LEX_CONTEXT_OP && i + 2 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 2))) {
      token=new Token(Token.OR);
      skip=2;
    }
 else     if (context == LEX_CONTEXT_OP && i + 3 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 3))) {
      token=new Token(Token.DIV);
      skip=3;
    }
 else     if (context == LEX_CONTEXT_OP && i + 3 <= expr.length() && "String_Node_Str".equals(expr.substring(i,i + 3))) {
      token=new Token(Token.MOD);
      skip=3;
    }
 else     if (c == '$') {
      int len=matchQName(expr,i + 1);
      if (len == 0) {
        badParse(expr,i,(char)c);
      }
 else {
        token=new Token(Token.VAR,new XPathQName(expr.substring(i + 1,i + len + 1)));
        skip=len + 1;
      }
    }
 else     if (c == '\'' || c == '\"') {
      int end=expr.indexOf(c,i + 1);
      if (end == -1) {
        badParse(expr,i,(char)c);
      }
 else {
        token=new Token(Token.STR,expr.substring(i + 1,end));
        skip=(end - i) + 1;
      }
    }
 else     if (isDigit(c)) {
      skip=matchNumeric(expr,i);
      token=new Token(Token.NUM,Double.valueOf(expr.substring(i,i + skip)));
    }
 else     if (context == LEX_CONTEXT_VAL && (isAlpha(c) || c == '_')) {
      int len=matchQName(expr,i);
      String name=expr.substring(i,i + len);
      if (name.indexOf(':') == -1 && getChar(expr,i + len) == ':' && getChar(expr,i + len + 1) == '*') {
        token=new Token(Token.NSWILDCARD,name);
        skip=len + 2;
      }
 else {
        token=new Token(Token.QNAME,new XPathQName(name));
        skip=len;
      }
    }
 else {
      badParse(expr,i,(char)c);
    }
    if (token != null) {
      if (token.type == Token.WILDCARD || token.type == Token.NSWILDCARD || token.type == Token.QNAME || token.type == Token.VAR || token.type == Token.NUM || token.type == Token.STR || token.type == Token.RBRACK || token.type == Token.RPAREN || token.type == Token.DOT || token.type == Token.DBL_DOT) {
        context=LEX_CONTEXT_OP;
      }
 else {
        context=LEX_CONTEXT_VAL;
      }
      tokens.addElement(token);
    }
    i+=skip;
  }
  return tokens;
}