Program: 30721
Project: 30721
Buggy source:
private void parseFromClause(QueryModel model,QueryModel masterModel) throws ParserException {
  CharSequence tok=expectTableNameOrSubQuery();
  if (Chars.equals(tok,'(')) {
    model.setNestedModel(parseSubQuery());
    expectTok(')');
    tok=optTok();
    if (tok != null && !tableAliasStop.contains(tok)) {
      model.setAlias(literal(tok));
      tok=optTok();
    }
    ExprNode timestamp=parseTimestamp(tok);
    if (timestamp != null) {
      model.setTimestamp(timestamp);
      tok=optTok();
    }
  }
 else {
    parseSelectFrom(model,tok,masterModel);
    tok=optTok();
    if (tok != null && !tableAliasStop.contains(tok)) {
      model.setAlias(literal(tok));
      tok=optTok();
    }
    ExprNode timestamp=parseTimestamp(tok);
    if (timestamp != null) {
      model.setTimestamp(timestamp);
      tok=optTok();
    }
    if (Chars.equalsNc("String_Node_Str",tok)) {
      parseLatestBy(model);
      tok=optTok();
    }
  }
  int joinType;
  while (tok != null && (joinType=joinStartSet.get(tok)) != -1) {
    model.addJoinModel(parseJoin(tok,joinType,masterModel));
    tok=optTok();
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    model.setWhereClause(expr());
    tok=optTok();
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    expectTok("String_Node_Str");
    model.setSampleBy(expectLiteral());
    tok=optTok();
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    expectTok("String_Node_Str");
    do {
      tok=tok("String_Node_Str");
      if (Chars.equals(tok,')')) {
        throw err("String_Node_Str");
      }
      lexer.unparse();
      ExprNode n=expectLiteral();
      tok=optTok();
      if (tok != null && Chars.equalsIgnoreCase(tok,"String_Node_Str")) {
        model.addOrderBy(n,QueryModel.ORDER_DIRECTION_DESCENDING);
        tok=optTok();
      }
 else {
        model.addOrderBy(n,QueryModel.ORDER_DIRECTION_ASCENDING);
        if (tok != null && Chars.equalsIgnoreCase(tok,"String_Node_Str")) {
          tok=optTok();
        }
      }
      if (model.getOrderBy().size() >= MAX_ORDER_BY_COLUMNS) {
        throw err("String_Node_Str");
      }
    }
 while (tok != null && Chars.equals(tok,','));
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    ExprNode lo=expr();
    ExprNode hi=null;
    tok=optTok();
    if (tok != null && Chars.equals(tok,',')) {
      hi=expr();
    }
 else {
      lexer.unparse();
    }
    model.setLimit(lo,hi);
  }
 else {
    lexer.unparse();
  }
}

Fixed version (ground truth):
private void parseFromClause(QueryModel model,QueryModel masterModel) throws ParserException {
  CharSequence tok=expectTableNameOrSubQuery();
  if (Chars.equals(tok,'(')) {
    model.setNestedModel(parseSubQuery());
    expectTok(')');
    tok=optTok();
    if (tok != null && !tableAliasStop.contains(tok)) {
      model.setAlias(literal(tok));
      tok=optTok();
    }
    ExprNode timestamp=parseTimestamp(tok);
    if (timestamp != null) {
      model.setTimestamp(timestamp);
      tok=optTok();
    }
  }
 else {
    parseSelectFrom(model,tok,masterModel);
    tok=optTok();
    if (tok != null && !tableAliasStop.contains(tok)) {
      model.setAlias(literal(tok));
      tok=optTok();
    }
    ExprNode timestamp=parseTimestamp(tok);
    if (timestamp != null) {
      model.setTimestamp(timestamp);
      tok=optTok();
    }
    if (Chars.equalsNc("String_Node_Str",tok)) {
      parseLatestBy(model);
      tok=optTok();
    }
  }
  int joinType;
  while (tok != null && (joinType=joinStartSet.get(tok)) != -1) {
    model.addJoinModel(parseJoin(tok,joinType,masterModel));
    tok=optTok();
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    model.setWhereClause(expr());
    tok=optTok();
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    expectTok("String_Node_Str");
    model.setSampleBy(expectLiteral());
    tok=optTok();
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    expectTok("String_Node_Str");
    do {
      ExprNode n=expectLiteral();
      tok=optTok();
      if (tok != null && Chars.equalsIgnoreCase(tok,"String_Node_Str")) {
        model.addOrderBy(n,QueryModel.ORDER_DIRECTION_DESCENDING);
        tok=optTok();
      }
 else {
        model.addOrderBy(n,QueryModel.ORDER_DIRECTION_ASCENDING);
        if (tok != null && Chars.equalsIgnoreCase(tok,"String_Node_Str")) {
          tok=optTok();
        }
      }
      if (model.getOrderBy().size() >= MAX_ORDER_BY_COLUMNS) {
        throw err("String_Node_Str");
      }
    }
 while (tok != null && Chars.equals(tok,','));
  }
  if (tok != null && Chars.equals(tok,"String_Node_Str")) {
    ExprNode lo=expr();
    ExprNode hi=null;
    tok=optTok();
    if (tok != null && Chars.equals(tok,',')) {
      hi=expr();
    }
 else {
      lexer.unparse();
    }
    model.setLimit(lo,hi);
  }
 else {
    lexer.unparse();
  }
}