BNFProcessor { 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 trailingDescription() { String[] inputBnf = { "<something> ::= <newthing>", " String inBnf = lines(inputBnf).trim(); BNFProcessor processor = new BNFProcessor(); Grammar grammar = processor.processString(lines(inputBnf)); String outputBnf = makeSQLBNF(grammar); String[] expected = { " String expect = lines(expected).trim(); assertEquals(unPretty(expect), unPretty(outputBnf)); }
@Test public void shouldRecycleCypher() throws Exception { Grammar grammar = Fixture.grammarResource( BNFProcessor.class, "/cypher.xml"); String firstBNF = makeSQLBNF(grammar); LOGGER.debug("Generated \n{}", firstBNF); BNFProcessor secondProcessor = new BNFProcessor(); Grammar grammarTwo = secondProcessor.processString(firstBNF); String intermediateBNF = makeSQLBNF(grammarTwo); LOGGER.debug("Regenerated\n{}", intermediateBNF); Grammar grammarThree = secondProcessor.processString(intermediateBNF); String finalBNF = makeSQLBNF(grammarTwo); assertEquals(intermediateBNF, finalBNF); }