diff options
Diffstat (limited to 'spec/parser.ebnf')
| -rw-r--r-- | spec/parser.ebnf | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/parser.ebnf b/spec/parser.ebnf new file mode 100644 index 0000000..9e02fba --- /dev/null +++ b/spec/parser.ebnf @@ -0,0 +1,75 @@ +unit : blank* ( datum blank? | EOF ) ; + + +blank : 9...13 | comment ; + +datum : one_datum ( join_char? one_datum )* ; + +join_char : '.' | ':' | '|' ; + + +comment : ';' ( skip_unit | skip_line ) ; + +skip_unit : '~' unit ; + +skip_line : ( ~LF )* LF? ; + + +one_datum : ( bare_str | clad_datum ) ; + +bare_str : bare_str_elt+ ; + +clad_datum : '\' bare_esc_str + | '"' quoted_str '"' + | '#' hash_expr + | '(' blank* list? ')' + | '[' blank* list? ']' + | '{' blank* list? '}' + | quote_expr + ; + + +bare_str_elt : bare_char | '\' bare_esc ; + + +bare_esc_str : bare_esc bare_str_elt* ; + +quoted_str : ( quoted_char | '\' quoted_esc )* ; + +hash_expr : rune clad_datum? + | '%' label ( '%' | '=' unit ) + | clad_datum + ; + +list : unit+ ( '.' blank+ unit )? blank* ; + +quote_expr : ( "'" | "`" | "," ) datum ; + + +bare_char : letter | digit + | '!' | '$' | '%' | '&' | '*' | '+' | '-' | '/' + | '<' | '=' | '>' | '?' | '@' | '^' | '_' | '~' + ; + +bare_esc : 33...126 ; + + +quoted_char : ~( '"' | '\' ) ; + +quoted_esc : '\' | '"' | 'a' | 'b' | 'e' + | 'f' | 'n' | 'r' | 't' | 'v' + | 'x' hex_digit{2} + | 'u' '{' hex_digit+ '}' + ; + + +rune : letter ( letter | digit ){0,5} ; + +label : hex_digit{1,12} ; + + +letter : 'a'...'z' | 'A'...'Z' ; + +digit : '0'...'9' ; + +hex_digit : '0'...'9' | 'a'...'f' | 'A'...'F' ; |
