1 // Copyright 2006 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
5 package edu.berkeley.sbp.misc;
6 import edu.berkeley.sbp.*;
7 import edu.berkeley.sbp.misc.*;
8 import edu.berkeley.sbp.meta.*;
9 import edu.berkeley.sbp.util.*;
10 import edu.berkeley.sbp.chr.*;
11 import edu.berkeley.sbp.bind.*;
17 public static void main(String[] s) throws Exception {
20 Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(s[0])).expand1();
22 //AnnotationGrammarBindings resolver = new AnnotationGrammarBindings(Java15.class);
23 Grammar.Bindings resolver = new Grammar.Bindings();
24 Union javaGrammar = Grammar.create(res, "s", resolver);
26 System.err.println("parsing " + s[1]);
27 Tree t = new CharParser(javaGrammar).parse(new FileInputStream(s[1])).expand1();
29 System.out.println("tree:\n" + t.toPrettyString());
31 } catch (Ambiguous a) {
32 FileOutputStream fos = new FileOutputStream("/Users/megacz/Desktop/out.dot");
33 PrintWriter p = new PrintWriter(new OutputStreamWriter(fos));
34 GraphViz gv = new GraphViz();
35 a.getAmbiguity().toGraphViz(gv);
41 } catch (Exception e) {