checkpoint
[sbp.git] / tests / tibdoc.g
index 8b18175..e77d53b 100644 (file)
@@ -20,38 +20,41 @@ nw       ::= ~[\r\n\ ]
 
 //////////////////////////////////////////////////////////////////////////////
 
-s                 ::= {Doc} => top
+s                 ::= Doc => top
 
-Doc               ::= Header Body                         /ws => doc
-Header            ::= "header" { kv */ ws }               /ws => header
+Doc               ::= {Header} Body                   /ws => doc
+Header            ::= "header" { kv */ ws }           /ws => header
 Body              ::= Section*/ws                             => body
-Section           ::= SectionHeader Paragraph*/ws         /ws => section
+Section           ::= { SectionHeader Paragraph* /ws => section }
 SectionHeader     ::= "==" SectionHeaderBody "=="
 SectionHeaderBody ::=  "=" SectionHeaderBody "="
                     >      ws text ws
 
+sp    !::= " "**
+blank  ::= sp "\n" sp "\n" ws
+
 kv         ::= word "=" text /ws => kv1
 
 num !::= [0-9]++
-Paragraph  ::= { "\"\"" ws text }        => "blockquote"
-             > { "*" " " ws text }       => "ul"
-             > { "#" " " ws text }       => "ol"
-             > { num " " ws text }       => "ol"
-             > { "---" "-"* }            => "hr"
-             > { text }                  => "p"
-
-text       ::= item => "t"
-itemx      ::= ws item => "w" | ()
-item       ::= blockquote => "b"
-             > pre         itemx => "a"
-             > structured  itemx => "1"
-             > structuredx itemx => "2"
-             > styled      itemx => "3"
-             > qtext       itemx => "4"
-             > alphanum++  itemx => "5"
-             > symbol      itemx => "6"
-//             > sym++       itemx => []
-             > Paragraph   itemx => "7"
+Paragraph  ::= { "\"\"" ws text  }  => "blockquote"
+             > { "*" " " ws text }  => "ul"
+             > { "#" " " ws text }  => "ol"
+             > { num " " ws text }  => "ol"
+             > { "---" "-"*      }  => "hr"
+             > { text }             => "p"
+
+text       ::= Item
+Itemx      ::= ws Item | ()
+Item       ::= blockquote
+             > pre         Itemx => []
+             > structured  Itemx => []
+             > structuredx Itemx => []
+             > styled      Itemx => []
+             > qtext       Itemx => []
+             > (alphanum++ => stringify) Itemx => []
+             > symbol      Itemx => []
+//             > sym++       Itemx => []
+             > Paragraph   Itemx => []
 
 symbol     ::= sym++
 
@@ -63,8 +66,8 @@ pre        ::= "[verbatim]" { ~[]+ } /ws => "verbatim"   // FIXME doesn't work
 
 styled     ::= "__" text "__"      => ul
              | "((" text "))"      => footnote
-             | ( "[[" text "]]"      => tt
-               >  "[" word "]"       => citation
+             | ( "[[" text "]]"    => tt
+               >  "[" word "]"     => citation
                )
              | "!!" text "!!"      => strikethrough
              | "^^" (word|block)   => superscript
@@ -114,7 +117,7 @@ host       ::= [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
 
 // Tokens ///////////////////////////////////////////////////////////////////
 
-word     ::= alphanum++
+word     ::= alphanum++ => stringify
            | quoted
 
 quoted   ::= "\"" ((~[\"\\] | escaped)+) "\""