Program: 51560
Project: 51560
Buggy source:
/** 
 * This method parses a String and tries to find a label, opCode and all the other parts of a Command line.
 * @param symbolicOpcode Symbolic form of an operation code. 
 */
public String[] parseLine(String symbolicOpcode) throws TTK91CompileException {
  String label="String_Node_Str";
  String opcode="String_Node_Str";
  String firstRegister="String_Node_Str";
  String addressingMode="String_Node_Str";
  String secondRegister="String_Node_Str";
  String address="String_Node_Str";
  String comment;
  String[] parsedLine;
  String wordTemp="String_Node_Str";
  int nextToCheck=0;
  int fieldEnd=0;
  boolean spaceBetweenMemorymodeAndAddress=false;
  fieldEnd=symbolicOpcode.indexOf("String_Node_Str");
  if (fieldEnd != -1) {
    symbolicOpcode=symbolicOpcode.substring(0,fieldEnd);
  }
  symbolicOpcode=symbolicOpcode.replace('\t',' ');
  symbolicOpcode=symbolicOpcode.replace('�',' ');
  symbolicOpcode=symbolicOpcode.toLowerCase();
  symbolicOpcode=symbolicOpcode.trim();
  if (symbolicOpcode.length() == 0) {
    parsedLine=new String[6];
    for (int i=0; i < parsedLine.length; ++i)     parsedLine[i]="String_Node_Str";
    return parsedLine;
  }
  String[] lineAsArray=symbolicOpcode.split("String_Node_Str");
  int lineAsArrayIndex=0;
  wordTemp=lineAsArray[lineAsArrayIndex];
  if (symbolicInterpreter.getOpcode(wordTemp) == -1) {
    if (!validLabelName(wordTemp)) {
      comment=new Message("String_Node_Str",new Message("String_Node_Str",wordTemp).toString()).toString();
      throw new TTK91CompileException(comment);
    }
    label=wordTemp;
    ++lineAsArrayIndex;
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    opcode=lineAsArray[lineAsArrayIndex];
    ++lineAsArrayIndex;
    if (symbolicInterpreter.getOpcode(opcode) < 0) {
      comment=new Message("String_Node_Str",new Message("String_Node_Str",opcode).toString()).toString();
      throw new TTK91CompileException(comment);
    }
  }
 else {
    comment=new Message("String_Node_Str",new Message("String_Node_Str",opcode).toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].charAt(lineAsArray[lineAsArrayIndex].length() - 1) == ',') {
      if (symbolicInterpreter.getRegisterId(lineAsArray[lineAsArrayIndex].substring(0,lineAsArray[lineAsArrayIndex].length() - 1)) != -1) {
        firstRegister=lineAsArray[lineAsArrayIndex].substring(0,lineAsArray[lineAsArrayIndex].length() - 1);
        ++lineAsArrayIndex;
      }
    }
 else {
      if (symbolicInterpreter.getRegisterId(lineAsArray[lineAsArrayIndex]) != -1) {
        firstRegister=lineAsArray[lineAsArrayIndex];
        ++lineAsArrayIndex;
      }
    }
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].charAt(0) == '(' && (opcode.equalsIgnoreCase("String_Node_Str") || opcode.equalsIgnoreCase("String_Node_Str")))     lineAsArray[lineAsArrayIndex]='0' + lineAsArray[lineAsArrayIndex];
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].charAt(0) == '=' || lineAsArray[lineAsArrayIndex].charAt(0) == '@') {
      addressingMode="String_Node_Str" + lineAsArray[lineAsArrayIndex].charAt(0);
      if (lineAsArray[lineAsArrayIndex].length() == 1) {
        spaceBetweenMemorymodeAndAddress=true;
        ++lineAsArrayIndex;
      }
    }
 else {
      addressingMode="String_Node_Str";
    }
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") != -1) {
      if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") < lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str")) {
        comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
        throw new TTK91CompileException(comment);
      }
 else {
        if (spaceBetweenMemorymodeAndAddress) {
          address=lineAsArray[lineAsArrayIndex].substring(0,lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        }
 else {
          address=lineAsArray[lineAsArrayIndex].substring(addressingMode.length(),lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        }
        secondRegister=lineAsArray[lineAsArrayIndex].substring(lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") + 1,lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        if (symbolicInterpreter.getRegisterId(secondRegister) == -1) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str",secondRegister).toString()).toString();
          throw new TTK91CompileException(comment);
        }
      }
    }
 else {
      if (spaceBetweenMemorymodeAndAddress) {
        address=lineAsArray[lineAsArrayIndex];
      }
 else {
        address=lineAsArray[lineAsArrayIndex].substring(addressingMode.length());
      }
      if (lineAsArrayIndex + 1 < lineAsArray.length) {
        ++lineAsArrayIndex;
        if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") == -1 || lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") == -1) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
          throw new TTK91CompileException(comment);
        }
        if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") < lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str")) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
          throw new TTK91CompileException(comment);
        }
 else {
          secondRegister=lineAsArray[lineAsArrayIndex].substring(lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") + 1,lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        }
      }
    }
    ++lineAsArrayIndex;
  }
  if (symbolicInterpreter.getRegisterId(address) != -1) {
    secondRegister=address;
    address="String_Node_Str";
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.length() > 0) {
    if (opcode.charAt(0) == 'j' || opcode.charAt(0) == 'J' || opcode.toLowerCase().equals("String_Node_Str")) {
      if (opcode.toLowerCase().matches("String_Node_Str" + "String_Node_Str" + "String_Node_Str") || opcode.toLowerCase().equals("String_Node_Str")) {
        if (firstRegister.equals("String_Node_Str")) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
          throw new TTK91CompileException(comment);
        }
      }
      if (((!opcode.toLowerCase().equals("String_Node_Str")) && (addressingMode.equals("String_Node_Str") || address.equals("String_Node_Str")))) {
        comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
        throw new TTK91CompileException(comment);
      }
    }
 else {
      if (opcode.equalsIgnoreCase("String_Node_Str")) {
      }
 else {
        if (opcode.equalsIgnoreCase("String_Node_Str")) {
          if (addressingMode.equals("String_Node_Str") || addressingMode.equals("String_Node_Str") || !address.equals("String_Node_Str")) {
            comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
            throw new TTK91CompileException(comment);
          }
        }
 else {
          if (opcode.equalsIgnoreCase("String_Node_Str") || opcode.equalsIgnoreCase("String_Node_Str")) {
            if (firstRegister.equals("String_Node_Str")) {
              comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
              throw new TTK91CompileException(comment);
            }
          }
 else {
            if (firstRegister.equals("String_Node_Str") || (address.equals("String_Node_Str") && secondRegister.equals("String_Node_Str"))) {
              comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
              throw new TTK91CompileException(comment);
            }
          }
        }
      }
    }
  }
  if (!address.equals("String_Node_Str")) {
    boolean isANumber=true;
    for (int i=0; i < address.length(); ++i) {
      if (!(i == 0 && address.charAt(i) == '-')) {
        if (!Character.isDigit(address.charAt(i)))         isANumber=false;
      }
    }
    if (isANumber) {
      if (address.length() > ("String_Node_Str" + ADDRESSMIN).length() || Integer.parseInt(address) > ADDRESSMAX || Integer.parseInt(address) < ADDRESSMIN) {
        comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
        throw new TTK91CompileException(comment);
      }
    }
  }
  if (addressingMode.equals("String_Node_Str") && address.equals("String_Node_Str")) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.equalsIgnoreCase("String_Node_Str") && address.equals("String_Node_Str") && !addressingMode.equals("String_Node_Str")) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.equalsIgnoreCase("String_Node_Str") && addressingMode.equals("String_Node_Str")) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str","String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.equals("String_Node_Str") && (!label.equals("String_Node_Str") || !firstRegister.equals("String_Node_Str") || !addressingMode.equals("String_Node_Str")|| !address.equals("String_Node_Str")|| !secondRegister.equals("String_Node_Str"))) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str","String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  parsedLine=new String[6];
  parsedLine[0]=label.trim();
  parsedLine[1]=opcode.trim();
  parsedLine[2]=firstRegister.trim();
  parsedLine[3]=addressingMode.trim();
  parsedLine[4]=address.trim();
  parsedLine[5]=secondRegister.trim();
  return parsedLine;
}

Fixed version (ground truth):
/** 
 * This method parses a String and tries to find a label, opCode and all the other parts of a Command line.
 * @param symbolicOpcode Symbolic form of an operation code. 
 */
public String[] parseLine(String symbolicOpcode) throws TTK91CompileException {
  String label="String_Node_Str";
  String opcode="String_Node_Str";
  String firstRegister="String_Node_Str";
  String addressingMode="String_Node_Str";
  String secondRegister="String_Node_Str";
  String address="String_Node_Str";
  String comment;
  String[] parsedLine;
  String wordTemp="String_Node_Str";
  int nextToCheck=0;
  int fieldEnd=0;
  boolean spaceBetweenMemorymodeAndAddress=false;
  fieldEnd=symbolicOpcode.indexOf("String_Node_Str");
  if (fieldEnd != -1) {
    symbolicOpcode=symbolicOpcode.substring(0,fieldEnd);
  }
  symbolicOpcode=symbolicOpcode.replace('\t',' ');
  symbolicOpcode=symbolicOpcode.replace(' ',' ');
  symbolicOpcode=symbolicOpcode.toLowerCase();
  symbolicOpcode=symbolicOpcode.trim();
  if (symbolicOpcode.length() == 0) {
    parsedLine=new String[6];
    for (int i=0; i < parsedLine.length; ++i)     parsedLine[i]="String_Node_Str";
    return parsedLine;
  }
  String[] lineAsArray=symbolicOpcode.split("String_Node_Str");
  int lineAsArrayIndex=0;
  wordTemp=lineAsArray[lineAsArrayIndex];
  if (symbolicInterpreter.getOpcode(wordTemp) == -1) {
    if (!validLabelName(wordTemp)) {
      comment=new Message("String_Node_Str",new Message("String_Node_Str",wordTemp).toString()).toString();
      throw new TTK91CompileException(comment);
    }
    label=wordTemp;
    ++lineAsArrayIndex;
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    opcode=lineAsArray[lineAsArrayIndex];
    ++lineAsArrayIndex;
    if (symbolicInterpreter.getOpcode(opcode) < 0) {
      comment=new Message("String_Node_Str",new Message("String_Node_Str",opcode).toString()).toString();
      throw new TTK91CompileException(comment);
    }
  }
 else {
    comment=new Message("String_Node_Str",new Message("String_Node_Str",opcode).toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].charAt(lineAsArray[lineAsArrayIndex].length() - 1) == ',') {
      if (symbolicInterpreter.getRegisterId(lineAsArray[lineAsArrayIndex].substring(0,lineAsArray[lineAsArrayIndex].length() - 1)) != -1) {
        firstRegister=lineAsArray[lineAsArrayIndex].substring(0,lineAsArray[lineAsArrayIndex].length() - 1);
        ++lineAsArrayIndex;
      }
    }
 else {
      if (symbolicInterpreter.getRegisterId(lineAsArray[lineAsArrayIndex]) != -1) {
        firstRegister=lineAsArray[lineAsArrayIndex];
        ++lineAsArrayIndex;
      }
    }
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].charAt(0) == '(' && (opcode.equalsIgnoreCase("String_Node_Str") || opcode.equalsIgnoreCase("String_Node_Str")))     lineAsArray[lineAsArrayIndex]='0' + lineAsArray[lineAsArrayIndex];
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].charAt(0) == '=' || lineAsArray[lineAsArrayIndex].charAt(0) == '@') {
      addressingMode="String_Node_Str" + lineAsArray[lineAsArrayIndex].charAt(0);
      if (lineAsArray[lineAsArrayIndex].length() == 1) {
        spaceBetweenMemorymodeAndAddress=true;
        ++lineAsArrayIndex;
      }
    }
 else {
      addressingMode="String_Node_Str";
    }
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") != -1) {
      if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") < lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str")) {
        comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
        throw new TTK91CompileException(comment);
      }
 else {
        if (spaceBetweenMemorymodeAndAddress) {
          address=lineAsArray[lineAsArrayIndex].substring(0,lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        }
 else {
          address=lineAsArray[lineAsArrayIndex].substring(addressingMode.length(),lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        }
        secondRegister=lineAsArray[lineAsArrayIndex].substring(lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") + 1,lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        if (symbolicInterpreter.getRegisterId(secondRegister) == -1) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str",secondRegister).toString()).toString();
          throw new TTK91CompileException(comment);
        }
      }
    }
 else {
      if (spaceBetweenMemorymodeAndAddress) {
        address=lineAsArray[lineAsArrayIndex];
      }
 else {
        address=lineAsArray[lineAsArrayIndex].substring(addressingMode.length());
      }
      if (lineAsArrayIndex + 1 < lineAsArray.length) {
        ++lineAsArrayIndex;
        if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") == -1 || lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") == -1) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
          throw new TTK91CompileException(comment);
        }
        if (lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") < lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str")) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
          throw new TTK91CompileException(comment);
        }
 else {
          secondRegister=lineAsArray[lineAsArrayIndex].substring(lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str") + 1,lineAsArray[lineAsArrayIndex].indexOf("String_Node_Str"));
        }
      }
    }
    ++lineAsArrayIndex;
  }
  if (symbolicInterpreter.getRegisterId(address) != -1) {
    secondRegister=address;
    address="String_Node_Str";
  }
  if (lineAsArrayIndex < lineAsArray.length) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.length() > 0) {
    if (opcode.charAt(0) == 'j' || opcode.charAt(0) == 'J' || opcode.toLowerCase().equals("String_Node_Str")) {
      if (opcode.toLowerCase().matches("String_Node_Str" + "String_Node_Str" + "String_Node_Str") || opcode.toLowerCase().equals("String_Node_Str")) {
        if (firstRegister.equals("String_Node_Str")) {
          comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
          throw new TTK91CompileException(comment);
        }
      }
      if (((!opcode.toLowerCase().equals("String_Node_Str")) && (addressingMode.equals("String_Node_Str") || address.equals("String_Node_Str")))) {
        comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
        throw new TTK91CompileException(comment);
      }
    }
 else {
      if (opcode.equalsIgnoreCase("String_Node_Str")) {
      }
 else {
        if (opcode.equalsIgnoreCase("String_Node_Str")) {
          if (addressingMode.equals("String_Node_Str") || addressingMode.equals("String_Node_Str") || !address.equals("String_Node_Str")) {
            comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
            throw new TTK91CompileException(comment);
          }
        }
 else {
          if (opcode.equalsIgnoreCase("String_Node_Str") || opcode.equalsIgnoreCase("String_Node_Str")) {
            if (firstRegister.equals("String_Node_Str")) {
              comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
              throw new TTK91CompileException(comment);
            }
          }
 else {
            if (firstRegister.equals("String_Node_Str") || (address.equals("String_Node_Str") && secondRegister.equals("String_Node_Str"))) {
              comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
              throw new TTK91CompileException(comment);
            }
          }
        }
      }
    }
  }
  if (!address.equals("String_Node_Str")) {
    boolean isANumber=true;
    for (int i=0; i < address.length(); ++i) {
      if (!(i == 0 && address.charAt(i) == '-')) {
        if (!Character.isDigit(address.charAt(i)))         isANumber=false;
      }
    }
    if (isANumber) {
      if (address.length() > ("String_Node_Str" + ADDRESSMIN).length() || Integer.parseInt(address) > ADDRESSMAX || Integer.parseInt(address) < ADDRESSMIN) {
        comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
        throw new TTK91CompileException(comment);
      }
    }
  }
  if (addressingMode.equals("String_Node_Str") && address.equals("String_Node_Str")) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.equalsIgnoreCase("String_Node_Str") && address.equals("String_Node_Str") && !addressingMode.equals("String_Node_Str")) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.equalsIgnoreCase("String_Node_Str") && addressingMode.equals("String_Node_Str")) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str","String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  if (opcode.equals("String_Node_Str") && (!label.equals("String_Node_Str") || !firstRegister.equals("String_Node_Str") || !addressingMode.equals("String_Node_Str")|| !address.equals("String_Node_Str")|| !secondRegister.equals("String_Node_Str"))) {
    comment=new Message("String_Node_Str",new Message("String_Node_Str","String_Node_Str").toString()).toString();
    throw new TTK91CompileException(comment);
  }
  parsedLine=new String[6];
  parsedLine[0]=label.trim();
  parsedLine[1]=opcode.trim();
  parsedLine[2]=firstRegister.trim();
  parsedLine[3]=addressingMode.trim();
  parsedLine[4]=address.trim();
  parsedLine[5]=secondRegister.trim();
  return parsedLine;
}