Assembler { @Nullable public static AssemblerConfig loadConfig(@Nullable Reader configReader) { if (configReader != null) { Yaml yaml = new Yaml(); return yaml.loadAs(configReader, AssemblerConfig.class); } return null; } private  Assembler(); @Nullable static AssemblerConfig loadConfig(@Nullable Reader configReader); static List<String> assemble(@Nonnull String input, @Nullable AssemblerConfig config, @Nonnull PrintStream logger, boolean insertIOConfiguration); @Nonnull static List<Instruction> parseAssembly(@Nonnull String input); static List<Instruction> insertIOConfiguration(List<Instruction> instructions, AssemblerConfig config); static List<Instruction> processDollarLabelOperands(List<Instruction> instructions); static List<Instruction> processChanDirectives(List<Instruction> instructions, AssemblerConfig config); static List<Instruction> processDataDirectives(List<Instruction> instructions); static Assembly makeLabelMap(List<Instruction> instructions); static Map<String, Long> getConfigLabels(@Nonnull AssemblerConfig config); static Assembly patchLabels(Assembly assembly); static List<Byte> processIndirectInstruction(Instruction instruction); static List<Byte> processDirectInstructionWithLabelOperand(Instruction instruction, Map<String, Long> labelMap); static byte processDirectInstructionWithConstantOperand(Instruction instruction); static List<Instruction> prefix(Instruction instruction); static ParseTree parseExpression(String expression, Function<AssemblerExpressionParser, ParseTree> startRule); final static long maxInt; final static long minInt; final static Pattern inputComment; final static Pattern instructionPattern; final static Pattern directivePattern; final static Pattern dollarPattern; static Map<String, Opcode> opcodes; }
@Test public void testLoadConfigIOPins() { StringReader configReader = new StringReader( "processor:\n" + " processor_id: 0\n" + " iopins:\n" + " - addr: 70\n" + " channel: pin0\n" + " config: 1\n"); AssemblerConfig config = Assembler.loadConfig(configReader); assertThat(config.getProcessor().getConnections(), is(equalTo(Collections.emptyList()))); assertThat(config.getProcessor().getProcessor_id(), is(equalTo(0))); assertThat(config.getProcessor().getIopins().get(0).getAddr(), is(equalTo(70))); assertThat(config.getProcessor().getIopins().get(0).getChannel(), is(equalTo("pin0"))); assertThat(config.getProcessor().getIopins().get(0).getConfig(), is(equalTo(1))); }
@Test public void testLoadConfigConnections() { StringReader configReader = new StringReader( "processor:\n" + " processor_id: 2\n" + " connections:\n" + " - target_processor: 1\n" + " dest_port: 0\n" + " channel: channel0\n" + " - target_processor: 0\n" + " dest_port: 4\n" + " channel: channel1\n"); AssemblerConfig config = Assembler.loadConfig(configReader); assertThat(config.getProcessor().getIopins(), is(equalTo(Collections.emptyList()))); assertThat(config.getProcessor().getProcessor_id(), is(equalTo(2))); assertThat(config.getProcessor().getConnections().get(0).getTarget_processor(), is(equalTo(1))); assertThat(config.getProcessor().getConnections().get(0).getDest_port(), is(equalTo(0))); assertThat(config.getProcessor().getConnections().get(0).getChannel(), is(equalTo("channel0"))); assertThat(config.getProcessor().getConnections().get(1).getTarget_processor(), is(equalTo(0))); assertThat(config.getProcessor().getConnections().get(1).getDest_port(), is(equalTo(4))); assertThat(config.getProcessor().getConnections().get(1).getChannel(), is(equalTo("channel1"))); }