diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2025-03-29 23:45:03 +0100 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2025-03-29 23:53:26 +0100 |
| commit | fc23b42c6e2183c8ca8b6c42dc4e90d8061f835d (patch) | |
| tree | a88f496bad87f881fcecd247a489438bc0c79779 /spec | |
| parent | 451aa92846b5fd5c8a0739336de3aa26d741d750 (diff) | |
new new parser
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/parser.ebnf | 74 |
1 files changed, 30 insertions, 44 deletions
diff --git a/spec/parser.ebnf b/spec/parser.ebnf index ce7fa83..caa24f3 100644 --- a/spec/parser.ebnf +++ b/spec/parser.ebnf @@ -1,42 +1,33 @@ -unit : empty_unit | datum_unit ; - - -empty_unit : blank* EOF ; - -datum_unit : blank* datum blank? ; +unit : blank* ( datum blank? | EOF ) ; blank : 9...13 | comment ; -datum : join_data | dot_string ; +datum : one_datum ( join_char? one_datum )* ; + +join_char : '.' | ':' ; comment : ';' ( skip_unit | skip_line ) ; skip_unit : '~' unit ; -skip_line : ( ~10 )* 10? ; - - -join_data : one_datum ( join_char? one_datum )* - -join_char : '.' | ':' | '|' ; - -dot_string : '.'{2,} +skip_line : ( ~LF )* LF? ; -one_datum : ( num_string | bare_string | clad_datum ) ; +one_datum : bare_string | clad_datum ; -num_string : ( '+' | '-' )? digit ( bare_str_elt | '.' )* ; - -bare_string : bare_str_elt+ ; +bare_string : ( '.' | '+' | '-' | DIGIT ) ( bare_str_elt | '.' )* + | bare_str_elt+ + ; clad_datum : '\' bare_esc_str - | '"' quoted_str '"' + | '|' pipe_str_elt* '|' + | '"' quot_str_elt* '"' | '#' hash_expr - | '(' blank* list? ')' - | '[' blank* list? ']' - | '{' blank* list? '}' + | '(' list ')' + | '[' list ']' + | '{' list '}' | quote_expr ; @@ -46,44 +37,39 @@ bare_str_elt : bare_char | '\' bare_esc ; bare_esc_str : bare_esc bare_str_elt* ; -quoted_str : ( quoted_char | '\' quoted_esc )* ; +pipe_str_elt : ~( '|' | '\' ) | '\' pipe_esc ; + +quot_str_elt : ~( '"' | '\' ) | '\' quot_esc ; hash_expr : rune clad_datum? - | '%' label ( '%' | '=' blank* datum ) + | '%' label ( '%' | '=' datum ) | clad_datum ; -list : datum_unit+ list_tail? blank* ; +list : unit* ( '.' unit )? blank* ; -list_tail : '.' blank+ datum_unit +quote_expr : ( "'" | "`" | "," ) datum ; -quote_expr : ( "'" | "`" | "," ) blank* datum ; +bare_char : ALPHA | DIGIT | bare_punct ; -bare_char : letter | digit - | '!' | '$' | '%' | '&' | '*' | '+' | '-' | '/' +bare_punct : '!' | '$' | '%' | '&' | '*' | '+' | '-' | '/' | '<' | '=' | '>' | '?' | '@' | '^' | '_' | '~' ; bare_esc : 33...126 ; -quoted_char : ~( '"' | '\' ) ; - -quoted_esc : '\' | '"' | 'a' | 'b' | 'e' - | 'f' | 'n' | 'r' | 't' | 'v' - | 'x' hex_digit{2} - | 'u' '{' hex_digit+ '}' - ; - +pipe_esc : string_esc | '|' ; -rune : letter ( letter | digit ){0,5} ; - -label : hex_digit{1,12} ; +quot_esc : string_esc | '"' ; +string_esc : '\' | 'a' | 'b' | 'e' | 'f' | 'n' | 'r' | 't' | 'v' + | 'x' HEXDIG{2} + | 'u' '{' HEXDIG+ '}' + ; -letter : 'a'...'z' | 'A'...'Z' ; -digit : '0'...'9' ; +rune : ALPHA ( ALPHA | DIGIT ){0,5} ; -hex_digit : '0'...'9' | 'a'...'f' | 'A'...'F' ; +label : HEXDIG{1,12} ; |
