private static void parseLine(Program program, String line, Deque<InstructionBranch> branches) throws IllegalSimFormat {
        if (line == null) return;
        //System.out.println("Parsing line: " + line);
        String origLine = line;
        line = line.trim(); //get rid of whitespace
        if (line.isEmpty() || line.startsWith("#")) return;
        line = line.split(Patterns.NUMBERSIGN)[0].trim(); //get rid of trailing comments
        if (line.startsWith("$")) {
            String[] variable = line.split(Patterns.EQUALS);
            if (variable.length != 2) {
                throw new IllegalSimFormat("Incorrectly formatted variable!", Boxle.instance(), origLine);
            }
            program.setVariable(variable[0], variable[1]);
        } else if (line.endsWith(";")) {
            int semiLoc = line.indexOf(';');
            String atomName = line.substring(0, semiLoc);
            int numSemis = line.substring(semiLoc).length();
            branches.addFirst(addAtom(atomName, branches, origLine));
            if (numSemis > branches.size()) {
                throw new IllegalSimFormat("Too many semicolons!", Boxle.instance(), origLine);
            }
            for (int count = 0; count < numSemis; count++) {
                branches.remove();
            }
        } else if (line.endsWith(":")) {
            branches.addFirst(addAtom(line.substring(0, line.indexOf(':')), branches, origLine));
        } else {
            throw new IllegalSimFormat("Incorrectly formatted line!", Boxle.instance(), origLine);
        }
    }