public static void main(String[] args) throws Exception { InputStream in; System.out.print("loading WiX grammar... "); CharParser meta = new CharParser(GrammarAST.getMetaGrammar()); System.out.print("wix.g "); in = BuildParser.class.getClassLoader().getResourceAsStream("wix.g"); Tree wix = meta.parse(in).expand1(); System.out.print("indent.g "); in = BuildParser.class.getClassLoader().getResourceAsStream("indent.g"); Tree indent = meta.parse(in).expand1(); System.out.print("tokens.g "); in = BuildParser.class.getClassLoader().getResourceAsStream("tokens.g"); Tree tokens = meta.parse(in).expand1(); System.out.print("url.g "); in = BuildParser.class.getClassLoader().getResourceAsStream("url.g"); Tree url = meta.parse(in).expand1(); System.out.println("done."); System.out.print("writing WiXGrammar.java... "); Writer out = new FileWriter("build/WiXGrammar.java"); out.write("/* AUTO GENERATED, DO NOT EDIT */\n"); out.write("package com.zentus.wixer;\n"); out.write("import edu.berkeley.sbp.*;\n"); out.write("public class WiXGrammar {\n\n"); out.write("public static final Tree wix, indent, tokens, url;\n\n"); out.write("static {\n"); out.write(" Tree w = null, i = null, t = null, u = null;\n"); out.write(" try {\n"); out.write(" w = \n"); wix.toJava(out); out.write(" ;\n"); out.write(" i = \n"); indent.toJava(out); out.write(" ;\n"); out.write(" t = \n"); tokens.toJava(out); out.write(" ;\n"); out.write(" u = \n"); url.toJava(out); out.write(" ;\n"); out.write(" } catch (Exception e) {throw new RuntimeException(e);}\n"); out.write(" wix = w;\n"); out.write(" indent = i;\n"); out.write(" tokens = t;\n"); out.write(" url = u;\n"); out.write("}\n"); out.write("}\n"); out.close(); System.out.println("done."); }