summaryrefslogtreecommitdiff
path: root/spec/syntax.abnf
blob: a083edaafa7f4b4dd5318999a3ee1e1497971975 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
;This file follows strict ABNF rules and can be used with abnfgen.


File          = [Unit] *( Blank Unit ) *Blank [Trail]


Unit          = *Blank Datum

Blank         = HTAB / LF / %x0b / %x0c / CR / Comment

Trail         = SkipLine / SkipUnit


Comment       = SkipLine LF / SkipUnit Blank

SkipLine      = ';' [ SkipLStart *AnyButLF ]

SkipUnit      = ';' '~' Unit


SkipLStart    = %x00-09 / %x0b-7d / %x7f-ff
              ; any but LF or '~'

AnyButLF      = %x00-09 / %x0b-ff


Datum         = SingleDatum
              / JoinedDatum *( [ '.' / ':' ] JoinedDatum )


SingleDatum   = BareString / CladDatum / DottedString

JoinedDatum   = BareString / CladDatum


BareString    = BareChar *( BareChar / Numeric )

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

DottedString  = ( '.' / Numeric ) *( '.' / Numeric / BareChar )


BareChar      = '!' / '$' / '%' / '*' / '/' / '<' / '=' / '>'
              / '?' / '@' / '^' / '_' / '~' / ALPHA

Numeric       = '+' / '-' / 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] *( Blank Unit ) *Blank [Tail] [SkipUnit]

Tail          = '&' Unit *Blank


StringEsc     = '\' / '|' / '"' / *( HTAB / SP ) LF *( HTAB / SP )
              / 'a' / 'b' / 't' / 'n' / 'v' / 'f' / 'r' / 'e'
              / 'x' 1*( 2HEXDIG ) ';'
              / 'u' 1*5HEXDIG ';'
              / 'u' '0' 1*5HEXDIG ';'
              / 'u' '1' '0' 1*4HEXDIG ';'


Rune          = ALPHA *5( ALPHA / DIGIT )

Label         = 1*12( HEXDIG )