udl 0.3.1

Parser for UDL (Universal Data Language)
Documentation
# Comments can be added anywhere whitespace can be added.


# Expression / argument
<expr> ::= <exprp>
         | <>


# Expression that must be present (cannot be empty).
<exprp> ::= <text> <expr>
          | "{" <expr> "}" <expr>
          | "{" <dictp> "}" <expr>
          | "{:" <dict> ":}" <expr>
          | "[" <seq> "]" <expr>
          | <direxpr> <expr>


<dict> ::= <dictp>
         | <>


<dictp> ::= <key> ":" <expr>
          | <key> ":" <expr> ";" <dict>
          | <key> ";" <dict>


<seq> ::= <exprp>
        | <expr> ";" <seq>
        | <>


# Directive expression
<direxpr> ::= <cmdexpr>
            | <tagexpr>


# Command expression
<cmdexpr> ::= "<" <key> <attr> ">"<cmdarg>


# Command argument
<cmdarg> ::= < >
           | ":"<key><cmdarg>
           | ":""{" <expr> "}"<cmdarg>
           | ":""{" <dictp> "}"<cmdarg>
           | ":""{:" <dict> ":}"<cmdarg>
           | ":""[" <seq> "]"<cmdarg>
           | ":""<" <key> <attr> ">"<cmdarg>
           | ":""<>"":"<cmdexpr>
           | ":""<>"


# Tag expression
<tagexpr> ::= "<+" <key> <attr> ">"<tagarg> <expr> "<-" <key> ">"
            | "<+" <key> <attr> ">"<tagarg> <expr> "<-" ">"


# Tag argument
<tagarg> ::= < >
           | ":"<key><tagarg>
           | ":""{" <expr> "}"<tagarg>
           | ":""{" <dictp> "}"<tagarg>
           | ":""{:" <dict> ":}"<tagarg>
           | ":""[" <seq> "]"<tagarg>
           | ":""<" <key> <attr> ">"<tagarg>
           | ":""<>"


# Directive attribute
<attr> ::= <>
         | <key> <attr>
         | <key> ":" <key> <attr>
         | <key> ":" "{" <expr> "}" <attr>
         | <key> ":" "{" <dictp> "}" <attr>
         | <key> ":" "{:" <dict> ":}" <attr>
         | <key> ":" "[" <seq> "]" <attr>
         | <key> ":" <cmdexpr> <attr>


<text> ::= <words>
         | <quote>


# A quote is anything enclosed within the quotes.
<quote> ::= "\"" ... "\""


<words> ::= <word> <words>
          | <>


<key> ::= <word>
        | <quote>


# A word is any sequence of glyphs that contains
# no reserved characters (except if they are escaped.)
<word> ::= ...


# No whitespace allowed
<> ::= ...