public static void work(BufferedReader ir) { TestParser testParser = new TestParser(); try { PushbackReader r = new PushbackReader(ir, 1024); Parser parser = new Parser(new Lexer(r)); Node syntaxTree = parser.parse(); syntaxTree.apply(testParser); } catch (LexerException e) { System.out.println(e.getMessage() + "."); } catch (ParserException e) { System.out.println(e.getMessage() + "."); } catch (IOException e) { System.out.println(e.getMessage() + "."); System.exit(1); } }
@Test public void shouldHaveNoCycles() { Graph<String> graph = new Graph<>(); packageDependencies.forEach( (key, set) -> { Node<String> node = graph.findOrCreateNode(key); set.stream() .filter(packageDependencies::containsKey) .forEach(target -> node.linkedTo(graph.findOrCreateNode(target))); }); graph.topologicalSort(); System.out.println("----------------------- dependencies:"); System.out.println(graph.toString()); System.out.println("-----------------------"); }