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