move meta.g into src/, cleanup
[sbp.git] / src / edu / berkeley / sbp / misc / RegressionTests.java
index 6fd3dd0..aa12c2a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2006 all rights reserved; see LICENSE file for BSD-style license
+// Copyright 2006-2007 all rights reserved; see LICENSE file for BSD-style license
 
 package edu.berkeley.sbp.misc;
 import java.io.*;
@@ -16,7 +16,7 @@ public class RegressionTests {
     public static File[] includes = new File[] { new File("tests") };
 
     public static void main() throws Exception {
-        main(new String[] { "tests/meta.g", "tests/testcase.g", "tests/regression.tc" });
+        main(new String[] { null, "tests/testcase.g", "tests/regression.tc" });
     }
 
     public static void main(String[] s) throws Exception {
@@ -35,14 +35,17 @@ public class RegressionTests {
                 s = s2;
             }
 
-            System.err.println("parsing " + s[0]);
-            Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(s[0])).expand1();
-            Union meta = GrammarBuilder.buildFromAST(res, "s", includes);
+            InputStream metaGrammarStream =
+                s[0] == null
+                ? RegressionTests.class.getClassLoader().getResourceAsStream("edu/berkeley/sbp/meta/meta.g")
+                : new FileInputStream(s[0]);
+            Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(metaGrammarStream).expand1();
+            Union meta = GrammarAST.buildFromAST(res, "s", includes);
 
             System.err.println("parsing " + s[1]);
             res = new CharParser(meta).parse(new FileInputStream(s[1])).expand1();
 
-            Union testcasegrammar = GrammarBuilder.buildFromAST(res, "s", includes);
+            Union testcasegrammar = GrammarAST.buildFromAST(res, "s", includes);
             if (testcasegrammar==null) return;
             CharParser parser = new CharParser(testcasegrammar);
 
@@ -63,7 +66,7 @@ public class RegressionTests {
             }
             System.err.println("expanding...");
 
-            TestCase[] expanded = (TestCase[])new GrammarBuilder(includes, "").walkChildren(r2.expand1());
+            TestCase[] expanded = (TestCase[])new GrammarAST(includes, "").walkChildren(r2.expand1());
             for(TestCase tc : expanded)
                 tc.execute();