G4Processor { public Grammar processString(String inString) { return processStream(new ByteArrayInputStream((inString).getBytes()) ); }  Grammar processString(String inString); Grammar processStream(InputStream inStream); Grammar processFile(String fileName);  }
@Test public void shouldRecycleFewRules() throws Exception { Grammar grammarFromXml = Fixture.grammarResource( G4Processor.class, "/FewRules.xml"); String firstG4 = makeAntlr4(grammarFromXml); LOGGER.debug("Generated G4\n{}", firstG4); G4Processor g4processor = new G4Processor(); Grammar grammarFromG4 = g4processor.processString(firstG4); String intermediateG4 = makeAntlr4(grammarFromG4); LOGGER.debug("Regenerated G4\n{}", intermediateG4); Grammar grammarFromSecondGenG4 = g4processor.processString(intermediateG4); String finalG4 = makeAntlr4(grammarFromG4); assertEquals(intermediateG4, finalG4); }
@Test public void shouldRecycleCypher() throws Exception { Grammar grammarFromXml = Fixture.grammarResource( G4Processor.class, "/cypher.xml"); String firstG4 = makeAntlr4(grammarFromXml); LOGGER.debug("Generated G4\n{}", firstG4); G4Processor g4processor = new G4Processor(); Grammar grammarFromG4 = g4processor.processString(firstG4); String intermediateG4 = makeAntlr4(grammarFromG4); LOGGER.debug("Regenerated G4\n{}", intermediateG4); Grammar grammarFromSecondGenG4 = g4processor.processString(intermediateG4); String finalG4 = makeAntlr4(grammarFromG4); assertEquals(intermediateG4, finalG4); }