summaryrefslogtreecommitdiff
path: root/spec/syntax.zbnf
blob: d920845e3d79fecb74f7c3b4c79f0bcdd60cf736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Unit          : Blank* ( Datum [Blank] | EOF )


Blank         : 9...13 | Comment

Datum         : OneDatum ( [JoinChar] OneDatum )*

JoinChar      : '.' | ':'


Comment       : ';' ( SkipUnit | SkipLine [LF] )

SkipUnit      : '~' Unit

SkipLine      : ( ~LF )*


OneDatum      : BareString | CladDatum

BareString    : BareChar+

CladDatum     : '|' ( PipeStrChar | '\' StringEsc )* '|'
              | '"' ( QuotStrChar | '\' StringEsc )* '"'
              | '#' HashExpr
              | '(' List ')' | '[' List ']' | '{' List '}'
              | "'" Datum | '`' Datum | ',' Datum


BareChar      : ALPHA | DIGIT
              | '!' | '$' | '%' | '*' | '+' | '-' | '.' | '/'
              | '<' | '=' | '>' | '?' | '@' | '^' | '_' | '~'


PipeStrChar   : ~( '|' | '\' )

QuotStrChar   : ~( '"' | '\' )

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}