Program: 12234
Project: 12234
Buggy source:
/** 
 * This is a utility routine which figures out what kind(s) of symbol a given string could represent. At entry: s, length_of_s represent the string. At exit: possible_xxx is set to TRUE/FALSE to indicate whether the given string could represent that kind of symbol; rereadable is set to TRUE indicating whether the lexer would read the given string as a symbol with exactly the same name (as opposed to treating it as a special lexeme like "+", changing upper to lower case, etc. <p>lexer.cpp:1225:determine_possible_symbol_types_for_string
 */
public static PossibleSymbolTypes determine_possible_symbol_types_for_string(String s){
  PossibleSymbolTypes p=new PossibleSymbolTypes();
  if (s.length() == 0) {
    return p;
  }
  if (Lexer.number_starters[s.charAt(0)]) {
    int ch=0;
    if ((s.charAt(ch) == '+') || (s.charAt(ch) == '-'))     ch++;
    while (ch < s.length() && Character.isDigit(s.charAt(ch)))     ch++;
    if (ch == s.length() && Character.isDigit(s.charAt(ch - 1)))     p.possible_ic=true;
    if (ch < s.length() && s.charAt(ch) == '.') {
      ch++;
      while (ch < s.length() && Character.isDigit(s.charAt(ch)))       ch++;
      if (ch < s.length() && (s.charAt(ch) == 'e' || s.charAt(ch) == 'E')) {
        ch++;
        if (ch < s.length() && (s.charAt(ch) == '+' || s.charAt(ch) == '-'))         ch++;
        while (ch < s.length() && Character.isDigit(s.charAt(ch)))         ch++;
      }
      if (ch == s.length())       p.possible_fc=true;
    }
  }
  for (int i=0; i < s.length(); ++i) {
    if (!isConstituentChar(s.charAt(i))) {
      return p;
    }
  }
  boolean rereadability_questionable=false;
  boolean rereadability_dead=false;
  for (int i=0; i < s.length(); i++) {
    char ch=s.charAt(i);
    if (Character.isLowerCase(ch) || Character.isDigit(ch))     continue;
    if (Character.isUpperCase(ch)) {
      rereadability_dead=true;
      break;
    }
    rereadability_questionable=true;
  }
  if (!rereadability_dead) {
    if ((!rereadability_questionable) || (s.length() >= LENGTH_OF_LONGEST_SPECIAL_LEXEME) || ((s.length() == 1) && (s.charAt(0) == '*')))     p.rereadable=true;
  }
  p.possible_sc=true;
  if ((s.charAt(0) == '<') && (s.charAt(s.length() - 1) == '>')) {
    p.possible_var=true;
  }
  if (Character.isLetter(s.charAt(0))) {
    int i=1;
    while (i < s.length() && Character.isDigit(s.charAt(i))) {
      ++i;
    }
    p.possible_id=i == s.length();
  }
  return p;
}

Fixed version (ground truth):
/** 
 * This is a utility routine which figures out what kind(s) of symbol a given string could represent. At entry: s, length_of_s represent the string. At exit: possible_xxx is set to TRUE/FALSE to indicate whether the given string could represent that kind of symbol; rereadable is set to TRUE indicating whether the lexer would read the given string as a symbol with exactly the same name (as opposed to treating it as a special lexeme like "+", changing upper to lower case, etc. <p>lexer.cpp:1225:determine_possible_symbol_types_for_string
 */
public static PossibleSymbolTypes determine_possible_symbol_types_for_string(String s){
  PossibleSymbolTypes p=new PossibleSymbolTypes();
  if (s.length() == 0) {
    return p;
  }
  if (Lexer.number_starters[s.charAt(0)]) {
    int ch=0;
    if ((s.charAt(ch) == '+') || (s.charAt(ch) == '-'))     ch++;
    while (ch < s.length() && Character.isDigit(s.charAt(ch)))     ch++;
    if (ch == s.length() && Character.isDigit(s.charAt(ch - 1)))     p.possible_ic=true;
    if (ch < s.length() && s.charAt(ch) == '.') {
      ch++;
      while (ch < s.length() && Character.isDigit(s.charAt(ch)))       ch++;
      if (ch < s.length() && (s.charAt(ch) == 'e' || s.charAt(ch) == 'E')) {
        ch++;
        if (ch < s.length() && (s.charAt(ch) == '+' || s.charAt(ch) == '-'))         ch++;
        while (ch < s.length() && Character.isDigit(s.charAt(ch)))         ch++;
      }
      if (ch == s.length())       p.possible_fc=true;
    }
  }
  boolean all_alphanum=true;
  for (int i=0; i < s.length(); ++i) {
    final char c=s.charAt(i);
    if (!isConstituentChar(c)) {
      return p;
    }
    all_alphanum=all_alphanum && Character.isLetterOrDigit(c);
  }
  if (all_alphanum || (s.length() > LENGTH_OF_LONGEST_SPECIAL_LEXEME) || ((s.length() == 1) && (s.charAt(0) == '*'))) {
    p.rereadable=true;
  }
  p.possible_sc=true;
  if ((s.charAt(0) == '<') && (s.charAt(s.length() - 1) == '>')) {
    p.possible_var=true;
  }
  final int idStartIndex=s.charAt(0) == '@' ? 1 : 0;
  final char idStart=s.charAt(idStartIndex);
  if (s.length() > 1 && Character.isLetter(idStart) && Character.isUpperCase(idStart)) {
    int i=idStartIndex + 1;
    while (i < s.length() && Character.isDigit(s.charAt(i))) {
      ++i;
    }
    p.possible_id=i == s.length();
  }
  return p;
}