comp.setContents(comparisonFileName);
comparisonProgram = new short[comp.getNumberOfLines()];
for (int i = 0; i < comp.getNumberOfLines(); i++) {
if (comp.getLineAt(i).length() != Definitions.BITS_PER_WORD) {
throw new HackTranslatorException("Error in file " + comparisonFileName + ": Line " + i + " does not contain exactly " + Definitions.BITS_PER_WORD + " characters");
}
try {
comparisonProgram[i] = (short) Conversions.binaryToInt(comp.getLineAt(i));
} catch (NumberFormatException nfe) {
throw new HackTranslatorException("Error in file " + comparisonFileName + ": Line " + i + " does not contain only 1/0 characters");
}
}
}
} catch (IOException ioe) {
throw new HackTranslatorException("Error reading from file " + comparisonFileName);
}
}