checkpoint
[sbp.git] / tests / meta.g
index f2dfb17..11cb9f8 100644 (file)
@@ -1,18 +1,28 @@
+// use 'a'-'z' or 'a-z' instead of [a-z]?
+// EOF token?
+// #include (with renaming?)
+
 s             =  ws! Grammar ws!
 
-Grammar       =  NonTerminal +/ ws
+Grammar       =  Declaration +/ ws
 
-NonTerminal   =  Word "=" RHS /ws
+Declaration   =  NonTerminal
+              |  ^"#import" ws! FileName //(ws! "as" ws! Prefix)?
 
-// use 'a'-'z' or 'a-z' instead of [a-z]?
-// EOF token?
-// #include (with renaming?)
-        
+//Prefix        = ([a-zA-Z] ".")+ "*"
+FileName      = FileNameChar+ -> [\r\n ]
+FileNameChar  = Space:: "\\ "
+              | ~[\r\n ]
+
+NonTerminal   =  Word           "="     RHS /ws
+              |  Word  "*" ws! ^"=" ws! RHS
+              |  Word  "*/" Word ws! ^"=" ws! RHS
+       
 RHS           =  (Sequence +/ (ws! "|" ws!)) +/ (ws! ">" ws!)
 
 Elements      =  e*/ws
 
-PreSequence   = ps::  Elements
+PreSequence   =  Elements
               |  (Quoted|Word)   ^"::" PreSequence /ws
               >  PreSequence     ^"/"      e       /ws
               |  PreSequence     ^"->"     e       /ws
@@ -51,7 +61,8 @@ NonTerminalReference = Word
 Literal              = Quoted
 Word                 = [a-zA-Z0-9_]++
 Quoted               = "\"" ((~[\"\\] | escaped)+) "\""
-                     | ""::   "\"\""
+                     | EmptyString
+                       EmptyString = "\"\""
 
 escaped    = "\n":: "\\n"
            | "\r":: "\\r"