+// use 'a'-'z' or 'a-z' instead of [a-z]?
+// EOF token?
+// #include (with renaming?)
+
s = ws! Grammar ws!
Grammar = NonTerminal +/ ws
-NonTerminal = Word "=" RHS /ws
-
-// use 'a'-'z' or 'a-z' instead of [a-z]?
-// EOF token?
-// #include (with renaming?)
-// ANTLR uses ! and ^ suffixes
-
+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
- | (Quoted|Word) ^"::" PreSequence /ws
- > PreSequence ^"/" e /ws
- | PreSequence ^"->" e /ws
+PreSequence = Elements
+ | (Quoted|Word) ^"::" PreSequence /ws
+ > PreSequence ^"/" e /ws
+ | PreSequence ^"->" e /ws
Sequence = psx:: PreSequence
| Sequence ^"&" Elements /ws
| e ^"!"
| e ^"?" /ws
| ^"^" Quoted
- | Quoted ^"^"
> ^"(" RHS ")" /ws
| ^"~" e
Literal = Quoted
Word = [a-zA-Z0-9_]++
Quoted = "\"" ((~[\"\\] | escaped)+) "\""
- | "":: "\"\""
+ | EmptyString
+ EmptyString = "\"\""
escaped = "\n":: "\\n"
| "\r":: "\\r"