use >> and << for indent/dedent
[sbp.git] / tests / meta.g
index 216d3bf..f06eb2f 100644 (file)
@@ -1,44 +1,38 @@
-// use 'a'-'z' or 'a-z' instead of [a-z]?
-// EOF token?
-// #include (with renaming?)
+//funkanomitron
+s             = ws Grammar ws
 
-s             =  ws! Grammar ws!
+Grammar::     = Declaration +/ ws
 
-Grammar       =  Declaration +/ ws
+Declaration   = NonTerminal
+              | ^"#import" FileName            /ws
+              | ^"#import" FileName "as" Word  /ws
 
-Declaration   =  NonTerminal
-              |  ^"#import" ws! FileName (ws! "as" ws! Word)?
+FileName::    = (~[\r\n ] | escaped)+ -> [\r\n ]
 
-FileName      = FileNameChar+ -> [\r\n ]
-FileNameChar  = Space:: "\\ "
-              | ~[\r\n ]
-
-NonTerminal   =  Word           "="     RHS /ws
-              |  Word  "*" ws! ^"=" ws! RHS
-              |  Word  "*/" Word ws! ^"=" ws! RHS
+NonTerminal   = NonTerminal:: Word            ws  "=" ws RHS
+              | DropNT::      Word  "!"       ws  "=" ws RHS
+              | Colons::      Word  "::"      ws  "=" ws RHS
+              |               Word  "*"       ws ^"=" ws RHS
+              |               Word  "*/" Word ws ^"=" ws RHS
        
-RHS           =  (Sequence +/ (ws! "|" ws!)) +/ (ws! ">" ws!)
-
-Elements      =  e*/ws
+RHS::         = ("|":: Sequence +/ (ws "|" ws)) +/ (ws (">" -> ~">") ws)
 
-PreSequence   =  Elements
-              |  (Quoted|Word)   ^"::" PreSequence /ws
-              >  PreSequence     ^"/"      e       /ws
-              |  PreSequence     ^"->"     e       /ws
+Elements::    = e*/ws
 
-Sequence      = psx:: PreSequence
-              |       Sequence ^"&"  Elements /ws
-              |       Sequence ^"&~" Elements /ws
-
-ec            = ~[\-\]\\]
-              | escaped
+PreSequence   = Elements
+              | (Quoted|Word)   ^"::" PreSequence /ws
+              > PreSequence     ^"/"      e       /ws
+              | PreSequence     ^"->"     e       /ws
 
-Range         = ec
-              | ec "-" ec
+Sequence      = PreSequence
+              | Sequence ^"&"  Elements /ws
+              | ^"~~"  Elements /ws
+              | Sequence ^"&~" Elements /ws
 
-e             =                (Quoted|Word) ^":" e
-              >                NonTerminalReference
-              |                Literal
+e             =                                   e ^"!"
+              >                (Quoted|Word) ^":" e
+              >                NonTerminalReference:: Word
+              |                Literal:: Quoted
               |                  ^"()"
               |                  ^"{" PreSequence "}"    /ws
               |                  ^"["  Range* "]"
@@ -50,24 +44,34 @@ e             =                (Quoted|Word) ^":" e
               |                e ^"*"                    /ws -> ~[*]
               |                e ^"**/" e                /ws        
               |                e ^"*/"  e                /ws        
-              |                     e ^"!"
               |                e ^"?"                    /ws
               |                  ^"^"   Quoted
+              |                  ^"`"   e
+              |                  ^"..."
+              |                   "(" Word  ^")"
               >                  ^"(" RHS  ")"           /ws
-              |                  ^"~" e
+              |                 "~":: ("~" -> ~"~")!  e
+              |                  ^"\\{"
+              |                  ^"\\}"
+              |                  ^">>"
+              |                  ^"<<"
+
+Word::        = [.a-zA-Z0-9_]++ &~ "."+
+Quoted::      = "\"" (~[\"\\] | escaped)+ "\""
+              | "\"\""
 
-NonTerminalReference = Word
-Literal              = Quoted
-Word                 = [.a-zA-Z0-9_]++
-Quoted               = "\"" ((~[\"\\] | escaped)+) "\""
-                     | EmptyString
-                       EmptyString = "\"\""
+Range::       = ec
+              | ec "-" ec
+              | "<<":: [<][<]
+              | ">>":: [>][>]
 
-escaped    = "\n":: "\\n"
-           | "\r":: "\\r"
-           |        "\\" ~[nr]
+ec            = ~[\-\]\\<>]
+              | [>] -> ~[>]
+              | [<] -> ~[<]
+              | escaped
+escaped       = "\n"::  "\\n"
+              | "\r"::  "\\r"
+              |         "\\" ~[nr]
 
-w             = " " | "\n" | "\r"
-ws            =  "()":: w**
-              |  "()":: w** "//" (~[\n])* "\n" ws
-wp            =  w++
+ws!          = [ \r\n]**
+             | [ \r\n]** "//" ~[\n]* "\n" ws