Program: 8734
Project: 8734
Buggy source:
private Statement convertToStatement(String query) throws ParseException {
  query=query.trim();
  Statement statement=new Statement();
  if (query.startsWith("String_Node_Str")) {
    query=query.substring("String_Node_Str".length()).trim();
    statement.setExplain(true);
  }
  if (query.startsWith("String_Node_Str")) {
    query=query.substring("String_Node_Str".length()).trim();
    statement.setMeasure(true);
  }
  if (query.isEmpty()) {
    query="String_Node_Str";
  }
  statement.setOriginalQuery(query);
  initialize(query);
  expected=new ArrayList<String>();
  read();
  if (currentTokenType == END) {
    throw getSyntaxError("String_Node_Str");
  }
  currentSelector.name="String_Node_Str";
  String pathPattern="String_Node_Str";
  boolean startOfQuery=true;
  while (true) {
    boolean shortcut=false;
    boolean slash=readIf("String_Node_Str");
    if (!slash) {
      if (startOfQuery) {
        currentSelector.path="String_Node_Str";
        pathPattern="String_Node_Str";
        currentSelector.isChild=true;
      }
 else {
        break;
      }
    }
 else     if (readIf("String_Node_Str")) {
      if (!pathPattern.isEmpty()) {
        throw getSyntaxError("String_Node_Str");
      }
      if (readIf("String_Node_Str")) {
        currentSelector.path="String_Node_Str";
        pathPattern="String_Node_Str";
        if (readIf("String_Node_Str")) {
          pathPattern="String_Node_Str";
          currentSelector.isDescendant=true;
        }
 else {
          currentSelector.isChild=true;
        }
      }
 else {
        pathPattern="String_Node_Str";
        currentSelector.path="String_Node_Str";
        shortcut=true;
      }
    }
 else     if (readIf("String_Node_Str")) {
      pathPattern+="String_Node_Str";
      if (currentSelector.isDescendant) {
        nextSelector(true);
      }
      currentSelector.isDescendant=true;
    }
 else {
      pathPattern+="String_Node_Str";
      if (startOfQuery) {
        currentSelector.path="String_Node_Str";
      }
 else {
        if (currentSelector.isDescendant) {
          nextSelector(true);
        }
        currentSelector.isChild=true;
      }
    }
    int startParseIndex=parseIndex;
    if (shortcut) {
    }
 else     if (readIf("String_Node_Str")) {
      pathPattern+="String_Node_Str";
      if (!currentSelector.isDescendant) {
        if (selectors.size() == 0 && currentSelector.path.equals("String_Node_Str")) {
          currentSelector.path="String_Node_Str";
        }
      }
    }
 else     if (currentTokenType == IDENTIFIER) {
      String identifier=readIdentifier();
      if (readIf("String_Node_Str")) {
        if ("String_Node_Str".equals(identifier)) {
          currentSelector.isChild=false;
          pathPattern+="String_Node_Str";
          read("String_Node_Str");
          if (currentSelector.isDescendant) {
            currentSelector.nodeName="String_Node_Str";
          }
 else {
            currentSelector.path=PathUtils.concat(currentSelector.path,"String_Node_Str");
          }
        }
 else         if ("String_Node_Str".equals(identifier)) {
          if (readIf("String_Node_Str")) {
            pathPattern+="String_Node_Str";
          }
 else {
            if (readIf("String_Node_Str")) {
              pathPattern+="String_Node_Str";
            }
 else {
              String name=readPathSegment();
              pathPattern+=name;
              appendNodeName(name);
            }
            if (readIf("String_Node_Str")) {
              currentSelector.nodeType=readIdentifier();
            }
            read("String_Node_Str");
          }
        }
 else         if ("String_Node_Str".equals(identifier)) {
          readOpenDotClose(false);
          rewindSelector();
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
 else {
          throw getSyntaxError();
        }
      }
 else {
        String name=ISO9075.decode(identifier);
        pathPattern+=name;
        appendNodeName(name);
      }
    }
 else     if (readIf("String_Node_Str")) {
      rewindSelector();
      Expression.Property p=readProperty();
      statement.addSelectColumn(p);
    }
 else     if (readIf("String_Node_Str")) {
      rewindSelector();
      do {
        if (readIf("String_Node_Str")) {
          Expression.Property p=readProperty();
          statement.addSelectColumn(p);
        }
 else         if (readIf("String_Node_Str")) {
          readOpenDotClose(true);
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
 else         if (readIf("String_Node_Str")) {
          read("String_Node_Str");
          read("String_Node_Str");
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
 else         if (readIf("String_Node_Str")) {
          readOpenDotClose(true);
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
      }
 while (readIf("String_Node_Str"));
      if (!readIf("String_Node_Str")) {
        return convertToUnion(query,statement,startParseIndex - 1);
      }
    }
 else     if (readIf("String_Node_Str")) {
      if (readIf("String_Node_Str")) {
        String name="String_Node_Str";
        pathPattern+=name;
        if (!currentSelector.isChild) {
          currentSelector.nodeName=name;
        }
 else {
          if (currentSelector.isChild) {
            currentSelector.isChild=false;
            currentSelector.isParent=true;
          }
        }
      }
 else {
        if (selectors.size() > 0) {
          currentSelector=selectors.remove(selectors.size() - 1);
          currentSelector.condition=null;
          currentSelector.joinCondition=null;
        }
      }
    }
 else {
      throw getSyntaxError();
    }
    if (readIf("String_Node_Str")) {
      Expression c=parseConstraint();
      currentSelector.condition=Expression.and(currentSelector.condition,c);
      read("String_Node_Str");
    }
    startOfQuery=false;
    nextSelector(false);
  }
  if (selectors.size() == 0) {
    nextSelector(true);
  }
  currentSelector=selectors.get(selectors.size() - 1);
  if (selectors.size() == 1) {
    currentSelector.onlySelector=true;
  }
  if (readIf("String_Node_Str")) {
    read("String_Node_Str");
    do {
      Order order=new Order();
      order.expr=parseExpression();
      if (readIf("String_Node_Str")) {
        order.descending=true;
      }
 else {
        readIf("String_Node_Str");
      }
      statement.addOrderBy(order);
    }
 while (readIf("String_Node_Str"));
  }
  QueryOptions options=new QueryOptions();
  if (readIf("String_Node_Str")) {
    read("String_Node_Str");
    if (readIf("String_Node_Str")) {
      String type=readIdentifier().toUpperCase(Locale.ENGLISH);
      options.traversal=Traversal.valueOf(type);
    }
    read("String_Node_Str");
  }
  if (!currentToken.isEmpty()) {
    throw getSyntaxError("String_Node_Str");
  }
  statement.setColumnSelector(currentSelector);
  statement.setSelectors(selectors);
  statement.setQueryOptions(options);
  Expression where=null;
  for (  Selector s : selectors) {
    where=Expression.and(where,s.condition);
  }
  statement.setWhere(where);
  return statement;
}

Fixed version (ground truth):
private Statement convertToStatement(String query) throws ParseException {
  query=query.trim();
  Statement statement=new Statement();
  if (query.startsWith("String_Node_Str")) {
    query=query.substring("String_Node_Str".length()).trim();
    statement.setExplain(true);
  }
  if (query.startsWith("String_Node_Str")) {
    query=query.substring("String_Node_Str".length()).trim();
    statement.setMeasure(true);
  }
  if (query.isEmpty()) {
    query="String_Node_Str";
  }
  statement.setOriginalQuery(query);
  initialize(query);
  expected=new ArrayList<String>();
  read();
  if (currentTokenType == END) {
    throw getSyntaxError("String_Node_Str");
  }
  currentSelector.name="String_Node_Str";
  String pathPattern="String_Node_Str";
  boolean startOfQuery=true;
  while (true) {
    boolean shortcut=false;
    boolean slash=readIf("String_Node_Str");
    if (!slash) {
      if (startOfQuery) {
        currentSelector.path="String_Node_Str";
        pathPattern="String_Node_Str";
        currentSelector.isChild=true;
      }
 else {
        break;
      }
    }
 else     if (readIf("String_Node_Str")) {
      if (!pathPattern.isEmpty()) {
        throw getSyntaxError("String_Node_Str");
      }
      if (readIf("String_Node_Str")) {
        currentSelector.path="String_Node_Str";
        pathPattern="String_Node_Str";
        if (readIf("String_Node_Str")) {
          pathPattern="String_Node_Str";
          currentSelector.isDescendant=true;
        }
 else {
          currentSelector.isChild=true;
        }
      }
 else {
        pathPattern="String_Node_Str";
        currentSelector.path="String_Node_Str";
        shortcut=true;
      }
    }
 else     if (readIf("String_Node_Str")) {
      pathPattern+="String_Node_Str";
      if (currentSelector.isDescendant) {
        nextSelector(true);
      }
      currentSelector.isDescendant=true;
    }
 else {
      pathPattern+="String_Node_Str";
      if (startOfQuery) {
        currentSelector.path="String_Node_Str";
      }
 else {
        if (currentSelector.isDescendant) {
          nextSelector(true);
        }
        currentSelector.isChild=true;
      }
    }
    int startParseIndex=parseIndex;
    if (shortcut) {
    }
 else     if (readIf("String_Node_Str")) {
      pathPattern+="String_Node_Str";
      if (!currentSelector.isDescendant) {
        if (selectors.size() == 0 && currentSelector.path.equals("String_Node_Str")) {
          currentSelector.path="String_Node_Str";
        }
      }
    }
 else     if (currentTokenType == IDENTIFIER) {
      String identifier=readIdentifier();
      if (readIf("String_Node_Str")) {
        if ("String_Node_Str".equals(identifier)) {
          currentSelector.isChild=false;
          pathPattern+="String_Node_Str";
          read("String_Node_Str");
          if (currentSelector.isDescendant) {
            currentSelector.nodeName="String_Node_Str";
          }
 else {
            currentSelector.path=PathUtils.concat(currentSelector.path,"String_Node_Str");
          }
        }
 else         if ("String_Node_Str".equals(identifier)) {
          if (readIf("String_Node_Str")) {
            pathPattern+="String_Node_Str";
          }
 else {
            if (readIf("String_Node_Str")) {
              pathPattern+="String_Node_Str";
            }
 else {
              String name=readPathSegment();
              pathPattern+=name;
              appendNodeName(name);
            }
            if (readIf("String_Node_Str")) {
              currentSelector.nodeType=readIdentifier();
            }
            read("String_Node_Str");
          }
        }
 else         if ("String_Node_Str".equals(identifier)) {
          readOpenDotClose(false);
          rewindSelector();
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
 else {
          throw getSyntaxError();
        }
      }
 else {
        String name=ISO9075.decode(identifier);
        pathPattern+=name;
        appendNodeName(name);
      }
    }
 else     if (readIf("String_Node_Str")) {
      rewindSelector();
      Expression.Property p=readProperty();
      statement.addSelectColumn(p);
    }
 else     if (readIf("String_Node_Str")) {
      rewindSelector();
      do {
        if (readIf("String_Node_Str")) {
          Expression.Property p=readProperty();
          statement.addSelectColumn(p);
        }
 else         if (readIf("String_Node_Str")) {
          readOpenDotClose(true);
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
 else         if (readIf("String_Node_Str")) {
          read("String_Node_Str");
          read("String_Node_Str");
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
 else         if (readIf("String_Node_Str")) {
          readOpenDotClose(true);
          Expression.Property p=new Expression.Property(currentSelector,"String_Node_Str",false);
          statement.addSelectColumn(p);
        }
      }
 while (readIf("String_Node_Str"));
      if (!readIf("String_Node_Str")) {
        return convertToUnion(query,statement,startParseIndex - 1);
      }
    }
 else     if (readIf("String_Node_Str")) {
      if (readIf("String_Node_Str")) {
        String name="String_Node_Str";
        pathPattern+=name;
        if (!currentSelector.isChild) {
          currentSelector.nodeName=name;
        }
 else {
          if (currentSelector.isChild) {
            currentSelector.isChild=false;
            currentSelector.isParent=true;
          }
        }
      }
 else {
        if (selectors.size() > 0) {
          currentSelector=selectors.remove(selectors.size() - 1);
          currentSelector.condition=null;
          currentSelector.joinCondition=null;
        }
      }
    }
 else {
      throw getSyntaxError();
    }
    if (readIf("String_Node_Str")) {
      do {
        Expression c=parseConstraint();
        currentSelector.condition=Expression.and(currentSelector.condition,c);
        read("String_Node_Str");
      }
 while (readIf("String_Node_Str"));
    }
    startOfQuery=false;
    nextSelector(false);
  }
  if (selectors.size() == 0) {
    nextSelector(true);
  }
  currentSelector=selectors.get(selectors.size() - 1);
  if (selectors.size() == 1) {
    currentSelector.onlySelector=true;
  }
  if (readIf("String_Node_Str")) {
    read("String_Node_Str");
    do {
      Order order=new Order();
      order.expr=parseExpression();
      if (readIf("String_Node_Str")) {
        order.descending=true;
      }
 else {
        readIf("String_Node_Str");
      }
      statement.addOrderBy(order);
    }
 while (readIf("String_Node_Str"));
  }
  QueryOptions options=new QueryOptions();
  if (readIf("String_Node_Str")) {
    read("String_Node_Str");
    if (readIf("String_Node_Str")) {
      String type=readIdentifier().toUpperCase(Locale.ENGLISH);
      options.traversal=Traversal.valueOf(type);
    }
    read("String_Node_Str");
  }
  if (!currentToken.isEmpty()) {
    throw getSyntaxError("String_Node_Str");
  }
  statement.setColumnSelector(currentSelector);
  statement.setSelectors(selectors);
  statement.setQueryOptions(options);
  Expression where=null;
  for (  Selector s : selectors) {
    where=Expression.and(where,s.condition);
  }
  statement.setWhere(where);
  return statement;
}