+ public static MicroInstructionMemory parseMemory(String inputPath) throws IOException
+ {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(inputPath))))
+ {
+ return parseMemory(reader);
+ }
+ }
+
+ /**
+ * First line must be the machine name, the rest must be in csv format
+ */
+ public static MicroInstructionMemory parseMemory(BufferedReader input)
+ {
+ try
+ {
+ return parseMemory(input.readLine(), input);
+ }
+ catch (IOException e)
+ {
+ throw new MicroInstructionMemoryParseException(e);
+ }
+ }
+
+ /**
+ * must be in csv format
+ */
+ public static MicroInstructionMemory parseMemory(String machineName, BufferedReader input)
+ {
+ try
+ {
+ MicroInstructionMemoryDefinition def = Objects
+ .requireNonNull(MachineRegistry.getinstalledMachines().get(machineName), "Unknown machine: " + machineName)
+ .getMicroInstructionMemoryDefinition();
+ MicroInstructionMemory memory = new StandardMicroInstructionMemory(def);
+ parseMemory(memory, input);
+ return memory;
+ }
+ catch (NullPointerException e)
+ {
+ throw new MicroInstructionMemoryParseException(e);
+ }
+ }
+
+ /**
+ * must be in csv format
+ */