checkpoint
authoradam <adam@megacz.com>
Wed, 5 Jul 2006 02:13:35 +0000 (22:13 -0400)
committeradam <adam@megacz.com>
Wed, 5 Jul 2006 02:13:35 +0000 (22:13 -0400)
darcs-hash:20060705021335-5007d-55b9a884bb8a4dca62a4e17ae7496031cba8f78c.gz

src/edu/berkeley/sbp/misc/Demo.java
src/edu/berkeley/sbp/tib/TibDoc.java

index 5aa2224..c9c18f3 100644 (file)
@@ -49,11 +49,11 @@ public class Demo {
             this(MG.class,
                  new Class[] {
                      MG.Grammar.class,
-                     MG.NonTerminal.class,
                      MG.AnonUn.class,
                      MG.Range.class,
                      MG.El.class,
                      MG.Seq.class,
+                     MG.NonTerminal.class,
                      MG.NonTerminalReference.class,
                      MG.StringLiteral.class,
                      MG.XTree.class,
@@ -71,21 +71,23 @@ public class Demo {
             if (c != null && t.equals("") && c.getSimpleName().equals(s)) return true;
             return false;
         }
+        /*
         private boolean match(nonterminal t, Class c, String s) {
             if (t==null) return false;
             if (t.value().equals(s)) return true;
             if (c != null && t.equals("") && c.getSimpleName().equals(s)) return true;
             return false;
         }
+        */
         private boolean match(Class c, String s, String nonTerminalName) {
             if (match((tag)c.getAnnotation(tag.class), c, s)) return true;
-            if (match((nonterminal)c.getAnnotation(nonterminal.class), c, nonTerminalName)) return true;
+            //if (match((nonterminal)c.getAnnotation(tag.class), c, nonTerminalName)) return true;
             return false;
         }
         public boolean match(Constructor con, String s, String nonTerminalName) {
             Class c = con.getDeclaringClass();
             if (match((tag)con.getAnnotation(tag.class), null, s)) return true;
-            if (match((nonterminal)con.getAnnotation(nonterminal.class), c, s)) return true;
+            //if (match((nonterminal)con.getAnnotation(tag.class), c, s)) return true;
             return false;
         }
         public Object repeatTag() {
@@ -126,7 +128,9 @@ public class Demo {
      *  that is arg-compatible.  If value() is undefined, then the
      *  class/constructor/method name is used.
      */ 
+    /*
     @Retention(RetentionPolicy.RUNTIME) public static @interface nonterminal { String value() default ""; }
+    */
 
     @Retention(RetentionPolicy.RUNTIME) public static @interface raw { }
 
@@ -186,7 +190,7 @@ public class Demo {
 
         public String getName() { return _bindable.getSimpleName(); }
         public tag getTag() { return (tag)_bindable.getAnnotation(tag.class); }
-        public nonterminal getNonTerminal() { return (nonterminal)_bindable.getAnnotation(nonterminal.class); }
+        //public nonterminal getNonTerminal() { return (nonterminal)_bindable.getAnnotation(tag.class); }
         public String toString() { return _bindable.getSimpleName(); }
         public Object plant(Object[] fields) { return _bindable.impose(fields); }
         public boolean isRaw() { return _bindable.isAnnotationPresent(raw.class); }
@@ -199,7 +203,7 @@ public class Demo {
                  (t.value().equals("") && getName().equals(p.tag))))
                 return buildSequence(p)!=null;
 
-            nonterminal n = getNonTerminal();
+            tag n = getTag();
             if (n != null &&
                 (n.value().equals(p.nonTerminal) ||
                  (n.value().equals("") && getName().equals(p.nonTerminal))))
@@ -398,8 +402,8 @@ public class Demo {
         }
         public static class NonTerminal extends Un {
             public String  name = null;
-            public @nonterminal("NonTerminal") NonTerminal(@arg("Word") String name,
-                                                           @arg("RHS") Seq[][] sequences) {
+            public @tag("=") NonTerminal(@arg("Word") String name,
+                                         @arg("RHS") Seq[][] sequences) {
                 this.name = name;
                 this.sequences = sequences;
             }
@@ -616,9 +620,9 @@ public class Demo {
 
         //public static @tag("(")   El subexpression(Seq[][] rhs)                { return new NonTerminal(rhs); }
 
-        public static @nonterminal("Word")    String word(String s) { return s; }
-        public static @nonterminal("Quoted")  String quoted(String s) { return s; }
-        public static @nonterminal("escaped") String c(char c) { return c+""; }
+        public static @tag("Word")    String word(String s) { return s; }
+        public static @tag("Quoted")  String quoted(String s) { return s; }
+        public static @tag("escaped") String c(char c) { return c+""; }
         public static @tag("\"\"")            String emptystring() { return ""; }
         public static @tag("\n")              String retur() { return "\n"; }
         public static @tag("\r")              String lf() { return "\r"; }
index bbf0545..2400ea4 100644 (file)
@@ -330,27 +330,27 @@ toContex ll = prefix ++ (concatMap tl ll) ++ suffix
 
     public static class TD {
 
-        public @nonterminal static class Doc extends Dump {
+        public @tag static class Doc extends Dump {
             public @arg Header head;
             public @arg Body body;
         }
 
-        public @nonterminal static class Header extends Dump {
+        public @tag static class Header extends Dump {
             public @arg KeyVal[] attrs;
             // FIXME: it would be nice to be able to
             // void KeyVal(String, String) { ... } imperatively
         }
         
-        public @nonterminal static class Body extends Dump {
+        public @tag static class Body extends Dump {
             public Section[] sections;
         }
         
-        public @nonterminal("Section") static class Section extends Dump {
+        public @tag("Section") static class Section extends Dump {
             public String      header;
             public Paragraph[] paragraphs;
         }
         
-        public @nonterminal static class KeyVal extends Dump {
+        public @tag static class KeyVal extends Dump {
             public @arg String key;
             public @arg Object val;
         }