checkpoint
authoradam <adam@megacz.com>
Sun, 15 Jan 2006 23:22:34 +0000 (18:22 -0500)
committeradam <adam@megacz.com>
Sun, 15 Jan 2006 23:22:34 +0000 (18:22 -0500)
darcs-hash:20060115232234-5007d-8a4b23840c8d0b80055290a88dd84db664b431a7.gz

src/edu/berkeley/sbp/misc/MetaGrammar.java
tests/meta.g

index 013ab09..e181600 100644 (file)
@@ -118,6 +118,7 @@ public class MetaGrammar extends StringWalker {
         else if ("**".equals(head))  return Repeat.maximal0((Element)walk(tree.child(0)));
         else if ("++".equals(head))  return Repeat.maximal1((Element)walk(tree.child(0)));
         else if ("?".equals(head))   return Repeat.maybe((Element)walk(tree.child(0)));
+        else if ("!".equals(head))   return walk(tree.child(0));
         else if ("&".equals(head))
             return ((Sequence)walk(tree,0)).and(new PreSequence((Element[])Reflection.lub((Object[])walk(tree, 1)), null).buildSequence(null, true, false));
         else if ("&~".equals(head))
index 79e3159..110964f 100644 (file)
@@ -2,23 +2,23 @@ s         ::=  Grammar ws                  => "gram"
 w       !::= " "
            | "\n"
            | "\r"
-ws       !::=  w** | w** "//" (~[\n]*) "\n" ws
+ws       !::=  w** | w** "//" (~[\n]*) "\n" !ws
 wp       !::=  w++
 Grammar   ::=  r +/ ws                        => "grammar"
 
 r         ::=  word  ^"::=" alternatives /ws
             |  word ^"!::=" alternatives /ws
 
-alternatives  ::=  (Conjuncts +/ (ws "|" ws)) +/ (ws ">" ws)
+alternatives  ::=  (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
 
 Conjuncts  ::=  Sequence
              |  Sequence ^"&"  e*/ws   /ws
              |  Sequence ^"&~" e*/ws   /ws
 
 ps         ::= e*/ws                              => "ps"
-             | (e+/ws ws)? "^" Quoted (ws e+/ws)? => "ps2"
+             | (e+/ws !ws)? "^" Quoted (!ws e+/ws)? => "ps2"
 psy        ::= ps
-             | ps wp ^"/" ws e
+             | ps wp ^"/" !ws e
 psx        ::= psy                   => "psy"
 //             | e "<-" psy        /ws => "psyl"
              |        psy "->" e /ws => "psyr"