-
Notifications
You must be signed in to change notification settings - Fork 1
/
cddl.abnf
80 lines (59 loc) · 1.77 KB
/
cddl.abnf
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
80
cddl = S 1*rule
rule = typename [genericparm] S assign S type S
/ groupname [genericparm] S assign S grpent S
typename = id
groupname = id
assign = "=" / "/=" / "//="
genericparm = "<" S id S *("," S id S ) ">"
genericarg = "<" S type1 S *("," S type1 S ) ">"
type = type1 S *("/" S type1 S)
type1 = type2 [S (rangeop / annotator) S type2]
/ "#" "6" ["." uint] "(" S type S ")" ; note no space!
/ "#" DIGIT ["." uint] ; major/ai
/ "#" ; any
/ "{" S group S "}"
/ "[" S group S "]"
/ "&" S "(" S group S ")"
/ "&" S groupname [genericarg]
type2 = value
/ typename [genericarg]
/ "(" type ")"
rangeop = "..." / ".."
annotator = "." id
group = grpchoice S *("//" S grpchoice S)
grpchoice = *grpent
grpent = [occur S] [memberkey S] type optcom
/ [occur S] groupname [genericarg] optcom ; preempted by above
/ [occur S] "(" S group S ")" optcom
memberkey = type1 S "=>"
/ bareword S ":"
/ value S ":"
bareword = id
optcom = S ["," S]
occur = [uint] "*" [uint]
/ "+"
/ "?"
uint = ["0x" / "0b"] "0"
/ ["0x" / "0b"] DIGIT1 *DIGIT
value = number
/ string
int = ["-"] uint
; This is a float if it has fraction or exponent; int otherwise
number = int ["." fraction] ["e" exponent ]
fraction = 1*DIGIT
exponent = int
string = %x22 *SCHAR %x22
SCHAR = %x20-21 / %x23-7E / SESC
SESC = "\" %x20-7E
id = EALPHA *(*("-" / ".") (EALPHA / DIGIT))
ALPHA = %x41-5A / %x61-7A
EALPHA = %x41-5A / %x61-7A / "@" / "_" / "$"
DIGIT = %x30-39
DIGIT1 = %x31-39
S = *WS
WS = SP / NL
SP = %x20
NL = COMMENT / CRLF
COMMENT = ";" *(SP / VCHAR) CRLF
VCHAR = %x21-7E
CRLF = %x0A / %x0D.0A