1 // Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
3 // Copyright 2006-2007 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.*;
18 public static void main(String[] s) throws Exception {
21 Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(s[0])).expand1();
23 //AnnotationGrammarBindings resolver = new AnnotationGrammarBindings(Java15.class);
24 Grammar.Bindings resolver = new Grammar.Bindings() {
25 public Object repeatTag() { return ""; }
27 Union javaGrammar = Grammar.create(res, "s", resolver);
29 System.err.println("parsing " + s[1]);
30 Tree t = new CharParser(javaGrammar).parse(new FileInputStream(s[1])).expand1();
32 System.out.println("tree:\n" + t.toPrettyString());
34 } catch (Ambiguous a) {
35 FileOutputStream fos = new FileOutputStream("/Users/megacz/Desktop/out.dot");
36 PrintWriter p = new PrintWriter(new OutputStreamWriter(fos));
37 GraphViz gv = new GraphViz();
38 a.getAmbiguity().toGraphViz(gv);
44 } catch (Exception e) {