package Parse; public class Parse { public ErrorMsg.ErrorMsg errorMsg; public Absyn.Exp tree; public Absyn.Print printer; // pretty printer public Parse(String filename) { errorMsg = new ErrorMsg.ErrorMsg(filename); printer = new Absyn.Print(System.out); {java.io.InputStream inp; try {inp=new java.io.FileInputStream(filename); } catch (java.io.FileNotFoundException e) { throw new Error("File not found: " + filename); } parser theparser = new parser(new Yylex(inp,errorMsg), errorMsg); // open input files, etc. here try { tree = (Absyn.Exp) (theparser.parse().value); // get tree } catch (Throwable e) { e.printStackTrace(); throw new Error(e.toString()); } finally { try {inp.close();} catch (java.io.IOException e) {} } // tree=theparser.parseResult; printer.prExp(tree,0); // pretty print tree } }// end of Parse constructor public static void main(String argv[]) { String filename = argv[0]; new Parse(filename); System.out.println("\nNice tree, no?"); } // end of main }