checkpoint
[sbp.git] / tests / meta.g
index 0d2be6f..a51109f 100644 (file)
@@ -1,6 +1,13 @@
-s             =  ws grammar:Grammar ws
+s             =  !ws Grammar !ws
+
 Grammar       =  NonTerminal +/ ws
-NonTerminal   =  Word  !wp ^"=" !wp RHS
+
+NonTerminal   =  Word "=" RHS /ws
+
+// use 'a'-'z' or 'a-z' instead of [a-z]?
+// EOF token?
+// #include (with renaming?)
+// ANTLR uses ! and ^ suffixes
         
 RHS           =  (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
 
@@ -8,24 +15,24 @@ Elements      =  e*/ws
 
 PreSequence   = ps::  Elements
               |       (Quoted|Word)   ^"::" PreSequence /ws
-              >       PreSequence !wp ^"/"   !ws e
-              |       PreSequence     ^"->"     e /ws
+              >       PreSequence     ^"/"      e       /ws
+              |       PreSequence     ^"->"     e       /ws
 
 Sequence      = psx:: PreSequence
-              |       Sequence !ws ^"&"  !ws Elements
-              |       Sequence !ws ^"&~" !ws Elements
+              |       Sequence ^"&"  Elements /ws
+              |       Sequence ^"&~" Elements /ws
 
 ec            = ~[\-\]\\]
               | escaped
 
-Range         = range:: ec
-              |         ec ^"-" ec
+Range         = ec
+              | ec ^"-" ec
 
 e             =                (Quoted|Word) ^":" e
-              > nonTerminal::          Word
-              | literal::       Quoted
+              >                NonTerminalReference
+              |                Literal
               |                  ^"()"
-              |                  ^"{" Sequence "}"       /ws
+              |                  ^"{" PreSequence "}"    /ws
               |                  ^"["  Range* "]"
               |                e ^"++"                   /ws -> ~[/]
               |                e ^"+"                    /ws -> ~[+]
@@ -41,8 +48,10 @@ e             =                (Quoted|Word) ^":" e
               |     "(" Word     ^")"                    /ws
               >                  ^"(" RHS  ")"           /ws
               |                  ^"~" e
-              >  "^^"::           "^"   e
+              >  "^^"::           "^" e
 
+NonTerminalReference = Word
+Literal = Quoted
 Word       = [a-zA-Z0-9_]++
 Quoted     = "\"" ((~[\"\\] | escaped)+) "\""
            | ""::   "\"\""
@@ -52,5 +61,5 @@ escaped    = "\n":: "\\n"
 
 w             = " " | "\n" | "\r"
 ws            =  "()":: w**
-              |  "()":: w** "//" ~[\n]* "\n" ws
+              |  "()":: w** "//" (~[\n])* "\n" ws
 wp            =  w++