clean up HaskellHelper
authoradam <adam@megacz.com>
Mon, 26 Mar 2007 07:12:37 +0000 (03:12 -0400)
committeradam <adam@megacz.com>
Mon, 26 Mar 2007 07:12:37 +0000 (03:12 -0400)
darcs-hash:20070326071237-5007d-03522ba7e32c2f633139a1186f28907721312b93.gz

src/edu/berkeley/sbp/misc/HaskellHelper.java

index e544441..d5a3eae 100644 (file)
@@ -10,64 +10,12 @@ import edu.berkeley.sbp.tib.*;
 import java.io.*;
 
 public class HaskellHelper {
-
-    public static void main(String[] argv) throws Throwable {
-        help(argv[0], argv[1]);
-    }
+    public static void main(String[] argv) throws Throwable { help(argv[0], argv[1]); }
     public static boolean isNull(Object o) { return o==null; }
-    public static Tree help0(String grammarFile, String targetFile) throws Throwable {
-        try {
-            Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(grammarFile)).expand1();
-            Union meta = Grammar.create(res, "s" /*,
-                                        new Grammar.Bindings() {
-                                            public Sequence createSequence(Production p) {
-                                                Element[] els = p.elements;
-                                                if (p.tag != null)
-                                                    return Sequence.create(p.tag, p.elements, p.drops, false);
-                                                int idx = -1;
-                                                for(int i=0; i<els.length; i++)
-                                                    if (!p.drops[i])
-                                                        if (idx==-1) idx = i;
-                                                        else return Sequence.create(p.nonTerminal, p.elements, p.drops, false);
-                                                if (idx != -1) return Sequence.create(els, idx);
-                                                else           return Sequence.create(els, "");
-                                            }
-                                            
-                                            }*/);
-            System.out.println();
-            System.out.println();
-            CharInput input = new CharInput(new FileInputStream(targetFile), "", true);
-            //Input input = new Tib(new FileInputStream(targetFile));
-            Tree ret = new CharParser(meta).parse(input).expand1();
-            if (ret==null) throw new NullPointerException("CharParser returned null");
-            return ret;
-        } catch (Throwable e) {
-            e.printStackTrace();
-            throw e;
-        }
-    }
     public static Tree help(String grammarFile, String targetFile) throws Throwable {
         try {
             Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(grammarFile)).expand1();
-            Union meta = Grammar.create(res, "s" /*,
-                                        new Grammar.Bindings() {
-                                            public Sequence createSequence(Production p) {
-                                                Element[] els = p.elements;
-                                                if (p.tag != null && !"".equals(p.tag))
-                                                    return Sequence.create(p.tag, p.elements, p.drops, false);
-                                                int idx = -1;
-                                                for(int i=0; i<els.length; i++)
-                                                    if (!p.drops[i])
-                                                        if (idx==-1) idx = i;
-                                                        else return Sequence.create(p.nonTerminal, p.elements, p.drops, false);
-                                                if (idx != -1) return Sequence.create(els, idx);
-                                                else           return Sequence.create(els, "");
-                                            }
-                                            
-                                            }*/);
-            System.out.println();
-            System.out.println();
-            //CharInput input = new CharInput(new FileInputStream(targetFile), "", true);
+            Union meta = Grammar.create(res, "s");
             Input input = new Tib(new FileInputStream(targetFile));
             Tree ret = new CharParser(meta).parse(input).expand1();
             if (ret==null) throw new NullPointerException("CharParser returned null");
@@ -77,6 +25,4 @@ public class HaskellHelper {
             throw e;
         }
     }
-
-
 }