summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/parser.bnf70
-rw-r--r--spec/syntax.abnf55
-rw-r--r--spec/syntax.zbnf55
3 files changed, 110 insertions, 70 deletions
diff --git a/spec/parser.bnf b/spec/parser.bnf
deleted file mode 100644
index 338dc10..0000000
--- a/spec/parser.bnf
+++ /dev/null
@@ -1,70 +0,0 @@
-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_string | clad_datum ;
-
-bare_string : ( '.' | '+' | '-' | DIGIT ) ( bare_char | '.' )*
- | bare_char+
- ;
-
-clad_datum : '\' bare_string
- | '|' pipe_str_elt* '|'
- | '"' quot_str_elt* '"'
- | '#' hash_expr
- | '(' list ')'
- | '[' list ']'
- | '{' list '}'
- | quote_expr
- ;
-
-
-bare_char : ALPHA | DIGIT | bare_punct ;
-
-bare_punct : '!' | '$' | '%' | '&' | '*' | '+' | '-' | '/'
- | '<' | '=' | '>' | '?' | '@' | '^' | '_' | '~'
- ;
-
-
-pipe_str_elt : ~( '|' | '\' ) | '\' pipe_esc ;
-
-quot_str_elt : ~( '"' | '\' ) | '\' quot_esc ;
-
-hash_expr : rune clad_datum?
- | rune '\' bare_string
- | '\' bare_string
- | '%' label ( '%' | '=' datum )
- | clad_datum
- ;
-
-list : unit* ( '.' unit )? blank* ;
-
-quote_expr : ( "'" | "`" | "," ) datum ;
-
-
-pipe_esc : string_esc | '|' ;
-
-quot_esc : string_esc | '"' ;
-
-string_esc : '\' | 'a' | 'b' | 'e' | 'f' | 'n' | 'r' | 't' | 'v'
- | 'x' HEXDIG{2}
- | 'u' '{' HEXDIG+ '}'
- ;
-
-
-rune : ALPHA ( ALPHA | DIGIT ){0,5} ;
-
-label : HEXDIG{1,12} ;
diff --git a/spec/syntax.abnf b/spec/syntax.abnf
new file mode 100644
index 0000000..a3c4ab9
--- /dev/null
+++ b/spec/syntax.abnf
@@ -0,0 +1,55 @@
+Unit = *Blank Datum [ ';' SkipLine ]
+
+
+Blank = HTAB / LF / %x0b / %x0c / CR / Comment
+
+Datum = OneDatum *( [JoinChar] OneDatum )
+
+JoinChar = '.' / ':'
+
+
+Comment = ';' ( SkipUnit / SkipLine LF )
+
+SkipUnit = '~' Unit
+
+SkipLine = *( %x00-09 / %x0b-ff ) ; any but LF
+
+
+OneDatum = BareString / CladDatum
+
+BareString = ( '.' / '+' / '-' / DIGIT ) *( BareChar / '.' )
+ / 1*BareChar
+
+CladDatum = '|' *( PipeStrChar / '\' StringEsc ) '|'
+ / '"' *( QuotStrChar / '\' StringEsc ) '"'
+ / '#' HashExpr
+ / '(' List ')' / '[' List ']' / '{' List '}'
+ / "'" Datum / '`' Datum / ',' Datum
+
+
+BareChar = ALPHA / DIGIT
+ / '!' / '$' / '%' / '&' / '*' / '+' / '-' / '/'
+ / '<' / '=' / '>' / '?' / '@' / '^' / '_' / '~'
+
+
+PipeStrChar = %x00-5b / %x5d-7b / %x7d-ff ; any but | or \
+
+QuotStrChar = %x00-21 / %x23-5b / %x5d-ff ; any but " or \
+
+HashExpr = rune ( '\' BareString / [CladDatum] )
+ / '\' BareString
+ / '%' Label ( '%' / '=' Datum )
+ / CladDatum
+
+List = *Unit [ '.' Unit ] *Blank
+
+
+StringEsc = '\' / '|' / '"' / *( HTAB / SP ) LF *( HTAB / SP )
+ / 'a' / 'b' / 't' / 'n' / 'v' / 'f' / 'r' / 'e'
+ / 'x' 1*( 2*HEXDIG ) ';'
+ / 'u' 1*6( HEXDIG ) ';'
+
+
+Rune = ALPHA *5( ALPHA / DIGIT )
+
+Label = 1*12( HEXDIG )
diff --git a/spec/syntax.zbnf b/spec/syntax.zbnf
new file mode 100644
index 0000000..5656864
--- /dev/null
+++ b/spec/syntax.zbnf
@@ -0,0 +1,55 @@
+Unit : Blank* ( Datum [Blank] | EOF )
+
+
+Blank : 9...13 | Comment
+
+Datum : OneDatum ( [JoinChar] OneDatum )*
+
+JoinChar : '.' | ':'
+
+
+Comment : ';' ( SkipUnit | SkipLine )
+
+SkipUnit : '~' Unit
+
+SkipLine : ( ~LF )* [LF]
+
+
+OneDatum : BareString | CladDatum
+
+BareString : ( '.' | '+' | '-' | DIGIT ) ( BareChar | '.' )*
+ | BareChar+
+
+CladDatum : '|' PipeStrElt* '|'
+ | '"' QuotStrElt* '"'
+ | '#' HashExpr
+ | '(' List ')' | '[' List ']' | '{' List '}'
+ | "'" Datum | '`' Datum | ',' Datum
+
+
+BareChar : ALPHA | DIGIT
+ | '!' | '$' | '%' | '&' | '*' | '+' | '-' | '/'
+ | '<' | '=' | '>' | '?' | '@' | '^' | '_' | '~'
+
+
+PipeStrElt : ~( '|' | '\' ) | '\' StringEsc
+
+QuotStrElt : ~( '"' | '\' ) | '\' StringEsc
+
+HashExpr : Rune [ '\' BareString | CladDatum ]
+ | '\' BareString
+ | '%' Label ( '%' | '=' Datum )
+ | CladDatum
+
+List : Unit* [ '.' Unit ] Blank*
+
+
+StringEsc : '\' | '|' | '"' | ( HTAB | SP )* LF ( HTAB | SP )*
+ | 'a' | 'b' | 't' | 'n' | 'v' | 'f' | 'r' | 'e'
+ | 'x' ( HEXDIG{2} )+ ';'
+ | 'u' HEXDIG{1,6} ';'
+
+
+Rune : ALPHA ( ALPHA | DIGIT ){0,5}
+
+Label : HEXDIG{1,12}