checkpoint
[sbp.git] / tests / meta.g
index 3139794..845af52 100644 (file)
@@ -1,58 +1,63 @@
-s           ::=  !ws Grammar ws              => "gram"
-Grammar     ::=  NonTerminal +/ ws           => "grammar"
-NonTerminal ::=  word  ^"::=" RHS /ws
+Grammar       =  NonTerminal +/ ws
+s             =  !ws (grammar::Grammar) !ws
+NonTerminal   =  Word ^"=" RHS /ws
 
-RHS         ::=  (Conjuncts +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
+// use 'a'-'z' or 'a-z' instead of [a-z]?
+// EOF token?
+// #include (with renaming?)
+// ANTLR uses ! and ^ suffixes
 
-Conjuncts   ::=  Sequence
-              |  Sequence ^"&"  Elements  /ws
-              |  Sequence ^"&~" Elements  /ws
-Elements    ::=  e*/ws
+blah = "Grammar"
+        
+RHS           =  (Sequence +/ (!ws "|" !ws)) +/ (!ws ">" !ws)
 
-psy         ::= Elements => "ps"
-              | psy !wp ^"/"  !ws e
-              | psy     ^"->"     e /ws
-              | psy     ^"=>" ("[]"|"()"|word|Quoted) /ws
-Sequence    ::= Quoted => "qprod"
-              > psy    => "psx"
+Elements      =  e*/ws
 
-ec          ::= ~[\-\]\\]
+PreSequence   = ps::  Elements
+              |       (Quoted|Word)   ^"::" PreSequence /ws
+              >       PreSequence     ^"/"      e       /ws
+              |       PreSequence     ^"->"     e       /ws
+
+Sequence      = psx:: PreSequence
+              |       Sequence ^"&"  Elements /ws
+              |       Sequence ^"&~" Elements /ws
+
+ec            = ~[\-\]\\]
               | escaped
 
-Range       ::= ec          => "range"
-              | ec ^"-" ec
-
-e           ::=  word                          => "nonTerminal"
-              |  Quoted                        => "literal"
-              |    ^"()"
-              |    ^"{" Sequence "}"       /ws
-              |    ^"["  Range* "]"
-
-              |  e ^"++"                   /ws -> ~[/]
-              |  e ^"+"                    /ws -> ~[+]
-              |  e ^"++/" e                /ws        
-              |  e ^"+/"  e                /ws        
-              |  e ^"**"                   /ws -> ~[/]
-              |  e ^"*"                    /ws -> ~[*]
-              |  e ^"**/" e                /ws        
-              |  e ^"*/"  e                /ws        
-              |    ^"!"   e                /ws
-              |  e ^"?"                    /ws
-              |    ^"^" Quoted             /ws
-
-              |     "(" word         ^")"  /ws
-              >    ^"(" RHS  ")"           /ws
-              |    ^"~" e
-
-word     ::= [a-zA-Z0-9_]++
-Quoted   ::= "\"" ((~[\"\\] | escaped)+) "\""
-           | "\"\"" => ""
-escaped  ::= "\\n" => "\n"
-           | "\\r" => "\r"
-           | "\\" ~[nr]
-
-
-w           ::= " " | "\n" | "\r"
-ws          ::=  w** => ()
-              |  w** "//" ~[\n]* "\n" ws => ()
-wp          ::=  w++
+Range         = range:: ec
+              |         ec ^"-" ec
+
+e             =                (Quoted|Word) ^":" e
+              > nonTerminal::          Word
+              | literal::       Quoted
+              |                  ^"()"
+              |                  ^"{" PreSequence "}"    /ws
+              |                  ^"["  Range* "]"
+              |                e ^"++"                   /ws -> ~[/]
+              |                e ^"+"                    /ws -> ~[+]
+              |                e ^"++/" e                /ws        
+              |                e ^"+/"  e                /ws        
+              |                e ^"**"                   /ws -> ~[/]
+              |                e ^"*"                    /ws -> ~[*]
+              |                e ^"**/" e                /ws        
+              |                e ^"*/"  e                /ws        
+              |                  ^"!"   e                /ws
+              |                e ^"?"                    /ws
+              |                  ^"^"   Quoted
+              |     "(" Word     ^")"                    /ws
+              >                  ^"(" RHS  ")"           /ws
+              |                  ^"~" e
+              >  "^^"::           "^" e
+
+Word       = [a-zA-Z0-9_]++
+Quoted     = "\"" ((~[\"\\] | escaped)+) "\""
+           | ""::   "\"\""
+escaped    = "\n":: "\\n"
+           | "\r":: "\\r"
+           |        "\\" ~[nr]
+
+w             = " " | "\n" | "\r"
+ws            =  "()":: w**
+              |  "()":: w** "//" (~[\n])* "\n" ws
+wp            =  w++