Program: 87339
Project: 87339
Buggy source:
/** 
 * Retrieve a description of list pattern from given Writer object, and create it.
 */
public static ListPattern readPattern(BufferedReader reader) throws ParsingErrorException {
  boolean finished=false;
  Modality modality=Modality.VISUAL;
  List<Pattern> items=new ArrayList<Pattern>();
  FileUtilities.acceptOpenTag(reader,"String_Node_Str");
  while (!FileUtilities.checkCloseTag(reader,"String_Node_Str")) {
    if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
      FileUtilities.acceptOpenTag(reader,"String_Node_Str");
      while (!FileUtilities.checkCloseTag(reader,"String_Node_Str")) {
        if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
          items.add(StringPattern.readPattern(reader));
        }
 else         if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
          items.add(NumberPattern.readPattern(reader));
        }
 else         if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
          items.add(ItemSquarePattern.readPattern(reader));
        }
 else {
          throw new ParsingErrorException("String_Node_Str");
        }
      }
      FileUtilities.acceptCloseTag(reader,"String_Node_Str");
    }
 else     if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
      String mode=FileUtilities.readStringInTag(reader,"String_Node_Str");
      if (mode.equals("String_Node_Str")) {
        modality=Modality.VISUAL;
      }
 else       if (mode.equals("String_Node_Str")) {
        modality=Modality.VERBAL;
      }
 else {
        modality=Modality.ACTION;
      }
    }
 else     if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
      finished=FileUtilities.readBooleanInTag(reader,"String_Node_Str");
    }
 else {
      throw new ParsingErrorException();
    }
  }
  FileUtilities.acceptCloseTag(reader,"String_Node_Str");
  ListPattern pattern=new ListPattern(modality);
  for (  Pattern pat : items) {
    pattern.add(pat);
  }
  if (finished)   pattern.setFinished();
  return pattern;
}

Fixed version (ground truth):
/** 
 * Retrieve a description of list pattern from given Writer object, and create it.
 */
public static ListPattern readPattern(BufferedReader reader) throws ParsingErrorException {
  boolean finished=false;
  Modality modality=Modality.VISUAL;
  List<PrimitivePattern> items=new ArrayList<PrimitivePattern>();
  FileUtilities.acceptOpenTag(reader,"String_Node_Str");
  while (!FileUtilities.checkCloseTag(reader,"String_Node_Str")) {
    if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
      FileUtilities.acceptOpenTag(reader,"String_Node_Str");
      while (!FileUtilities.checkCloseTag(reader,"String_Node_Str")) {
        if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
          items.add(StringPattern.readPattern(reader));
        }
 else         if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
          items.add(NumberPattern.readPattern(reader));
        }
 else         if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
          items.add(ItemSquarePattern.readPattern(reader));
        }
 else {
          throw new ParsingErrorException("String_Node_Str");
        }
      }
      FileUtilities.acceptCloseTag(reader,"String_Node_Str");
    }
 else     if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
      String mode=FileUtilities.readStringInTag(reader,"String_Node_Str");
      if (mode.equals("String_Node_Str")) {
        modality=Modality.VISUAL;
      }
 else       if (mode.equals("String_Node_Str")) {
        modality=Modality.VERBAL;
      }
 else {
        modality=Modality.ACTION;
      }
    }
 else     if (FileUtilities.checkOpenTag(reader,"String_Node_Str")) {
      finished=FileUtilities.readBooleanInTag(reader,"String_Node_Str");
    }
 else {
      throw new ParsingErrorException();
    }
  }
  FileUtilities.acceptCloseTag(reader,"String_Node_Str");
  ListPattern pattern=new ListPattern(modality);
  for (  PrimitivePattern pat : items) {
    pattern.add(pat);
  }
  if (finished)   pattern.setFinished();
  return pattern;
}