Program: 166681
Project: 166681
Buggy source:
/** 
 * Top-level method that react a Term in general, which may recursively call itself. <p> There are 5 valid cases: 1. (Op, A1, ..., An) is a CompoundTerm if Op is a built-in getOperator 2. {A1, ..., An} is an SetExt; 3. [A1, ..., An] is an SetInt; 4. <T1 Re T2> is a Statement (including higher-order Statement); 5. otherwise it is a simple term.
 * @param s0 the String to be parsed
 * @param memory Reference to the memory
 * @return the Term generated from the String
 */
public Term parseTerm(String s) throws InvalidInputException {
  s=s.trim();
  if (s.length() == 0)   return null;
  final int index=s.length() - 1;
  final char first=s.charAt(0);
  final char last=s.charAt(index);
  final NativeOperator opener=getOpener(first);
  if (opener != null) {
switch (opener) {
case COMPOUND_TERM_OPENER:
      if (last == COMPOUND_TERM_CLOSER.ch) {
        return parseCompoundTerm(s.substring(1,index));
      }
 else {
        throw new InvalidInputException("String_Node_Str");
      }
case SET_EXT_OPENER:
    if (last == SET_EXT_CLOSER.ch) {
      return SetExt.make(parseArguments(s.substring(1,index) + ARGUMENT_SEPARATOR));
    }
 else {
      throw new InvalidInputException("String_Node_Str");
    }
case SET_INT_OPENER:
  if (last == SET_INT_CLOSER.ch) {
    return SetInt.make(parseArguments(s.substring(1,index) + ARGUMENT_SEPARATOR));
  }
 else {
    throw new InvalidInputException("String_Node_Str");
  }
case STATEMENT_OPENER:
if (last == STATEMENT_CLOSER.ch) {
  return parseStatement(s.substring(1,index));
}
 else {
  throw new InvalidInputException("String_Node_Str");
}
}
}
 else if (Parameters.FUNCTIONAL_OPERATIONAL_FORMAT) {
final int pOpen=s.indexOf('(');
final int pClose=s.lastIndexOf(')');
if ((pOpen != -1) && (pClose != -1) && (pClose == s.length() - 1)) {
final String operatorString=Operator.addPrefixIfMissing(s.substring(0,pOpen));
final Operator operator=memory.getOperator(operatorString);
if (operator == null) {
throw new InvalidInputException("String_Node_Str" + operatorString);
}
final String argString=s.substring(pOpen + 1,pClose + 1);
final Term[] a;
if (argString.length() > 1) {
final List<Term> args=parseArguments(argString);
a=args.toArray(new Term[args.size()]);
}
 else {
a=Operation.SELF_TERM_ARRAY;
}
final Operation o=Operation.make(operator,a,true);
return o;
}
}
return parseAtomicTerm(s);
}

Fixed version (ground truth):
/** 
 * Top-level method that react a Term in general, which may recursively call itself. <p> There are 5 valid cases: 1. (Op, A1, ..., An) is a CompoundTerm if Op is a built-in getOperator 2. {A1, ..., An} is an SetExt; 3. [A1, ..., An] is an SetInt; 4. <T1 Re T2> is a Statement (including higher-order Statement); 5. otherwise it is a simple term.
 * @param s0 the String to be parsed
 * @param memory Reference to the memory
 * @return the Term generated from the String
 */
public Term parseTerm(String s) throws InvalidInputException {
  s=s.trim();
  if (s.length() == 0)   return null;
  final int index=s.length() - 1;
  final char first=s.charAt(0);
  final char last=s.charAt(index);
  final NativeOperator opener=getOpener(first);
  if (opener != null) {
switch (opener) {
case COMPOUND_TERM_OPENER:
      if (last == COMPOUND_TERM_CLOSER.ch) {
        return parseCompoundTerm(s.substring(1,index));
      }
 else {
        throw new InvalidInputException("String_Node_Str");
      }
case SET_EXT_OPENER:
    if (last == SET_EXT_CLOSER.ch) {
      return SetExt.make(parseArguments(s.substring(1,index) + ARGUMENT_SEPARATOR));
    }
 else {
      throw new InvalidInputException("String_Node_Str");
    }
case SET_INT_OPENER:
  if (last == SET_INT_CLOSER.ch) {
    return SetInt.make(parseArguments(s.substring(1,index) + ARGUMENT_SEPARATOR));
  }
 else {
    throw new InvalidInputException("String_Node_Str");
  }
case STATEMENT_OPENER:
if (last == STATEMENT_CLOSER.ch) {
  return parseStatement(s.substring(1,index));
}
 else {
  throw new InvalidInputException("String_Node_Str");
}
}
}
 else if (Parameters.FUNCTIONAL_OPERATIONAL_FORMAT) {
final int pOpen=s.indexOf('(');
final int pClose=s.lastIndexOf(')');
if ((pOpen != -1) && (pClose != -1) && (pClose == s.length() - 1)) {
final String operatorString=Operator.addPrefixIfMissing(s.substring(0,pOpen));
final Operator operator=memory.getOperator(operatorString);
if (operator == null) {
throw new InvalidInputException("String_Node_Str" + operatorString);
}
final String argString=s.substring(pOpen + 1,pClose + 1);
final Term[] a;
if (argString.length() > 1) {
final List<Term> args=parseArguments(argString);
a=args.toArray(new Term[0]);
}
 else {
a=Operation.SELF_TERM_ARRAY;
}
final Operation o=Operation.make(operator,a,true);
return o;
}
}
return parseAtomicTerm(s);
}