public static void main(String[] args) throws IOException { for (String filename : args) { GrammarReader gr = new GrammarReader(true); gr.read(Paths.get(filename).toFile().toURI().toURL()); Grammar grammar = gr.getGrammar(); grammar.addRule("Goal", "CompilationUnit"); grammar.validateRules(); for (Rule r : grammar.getRules()) System.out.println(r); } }
protected void generateNFAs(Grammar g) { DOTGenerator dotGenerator = new DOTGenerator(g); Collection rules = g.getAllImportedRules(); rules.addAll(g.getRules()); for (Iterator itr = rules.iterator(); itr.hasNext(); ) { Rule r = (Rule) itr.next(); try { String dot = dotGenerator.getDOT(r.startState); if (dot != null) { writeDOTFile(g, r, dot); } } catch (IOException ioe) { ErrorManager.error(ErrorManager.MSG_CANNOT_WRITE_FILE, ioe); } } }