checkpoint
[sbp.git] / src / edu / berkeley / sbp / meta / MetaGrammarBindings.java
index 9ccf8a8..742918b 100644 (file)
@@ -85,12 +85,17 @@ public class MetaGrammarBindings {
         }
     }
 
-    public static @bind.as("#import") GrammarNode poundimport(String fileName) {
-        System.err.println("#import " + fileName);
+    public static @bind.as("#import") GrammarNode poundimport(String fileName, String as) {
+        if (as==null) as = "";
+        System.err.println("#import " + fileName + " as " + as);
         try {
             Tree t = new CharParser(MetaGrammar.make()).parse(new FileInputStream(fileName)).expand1();
             Tree.TreeFunctor<Object,Object> red = (Tree.TreeFunctor<Object,Object>)t.head();
-            return (MetaGrammarBindings.GrammarNode)red.invoke(t);
+            String oldprefix = prefix;
+            prefix = as;
+            GrammarNode gn = (GrammarNode)red.invoke(t);
+            prefix = oldprefix;
+            return gn;
         } catch (Exception e) {
             e.printStackTrace();
             throw new RuntimeException(e);