This repository has been archived by the owner on Dec 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
core_abnf.go
132 lines (114 loc) · 2.54 KB
/
core_abnf.go
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// This file is generated - do not edit.
package core
import "github.com/elimity-com/abnf/operators"
// ALPHA = %x41-5A / %x61-7A
func ALPHA() operators.Operator {
return operators.Alts(
"ALPHA",
operators.Range("%x41-5A", []byte{65}, []byte{90}),
operators.Range("%x61-7A", []byte{97}, []byte{122}),
)
}
// BIT = "0" / "1"
func BIT() operators.Operator {
return operators.Alts(
"BIT",
operators.String("0", "0"),
operators.String("1", "1"),
)
}
// CHAR = %x01-7F
func CHAR() operators.Operator {
return operators.Range("CHAR", []byte{1}, []byte{127})
}
// CR = %x0D
func CR() operators.Operator {
return operators.Terminal("CR", []byte{13})
}
// CRLF = CR LF / LF
func CRLF() operators.Operator {
return operators.Alts(
"CRLF",
operators.Concat(
"CR LF",
CR(),
LF(),
),
LF(),
)
}
// CTL = %x00-1F / %x7F
func CTL() operators.Operator {
return operators.Alts(
"CTL",
operators.Range("%x00-1F", []byte{0}, []byte{31}),
operators.Terminal("%x7F", []byte{127}),
)
}
// DIGIT = %x30-39
func DIGIT() operators.Operator {
return operators.Range("DIGIT", []byte{48}, []byte{57})
}
// DQUOTE = %x22
func DQUOTE() operators.Operator {
return operators.Terminal("DQUOTE", []byte{34})
}
// HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" / "a" / "b" / "c" / "d" / "e" / "f"
func HEXDIG() operators.Operator {
return operators.Alts(
"HEXDIG",
DIGIT(),
operators.String("A", "A"),
operators.String("B", "B"),
operators.String("C", "C"),
operators.String("D", "D"),
operators.String("E", "E"),
operators.String("F", "F"),
operators.String("a", "a"),
operators.String("b", "b"),
operators.String("c", "c"),
operators.String("d", "d"),
operators.String("e", "e"),
operators.String("f", "f"),
)
}
// HTAB = %x09
func HTAB() operators.Operator {
return operators.Terminal("HTAB", []byte{9})
}
// LF = %x0A
func LF() operators.Operator {
return operators.Terminal("LF", []byte{10})
}
// LWSP = *(WSP / CRLF WSP)
func LWSP() operators.Operator {
return operators.Repeat0Inf("LWSP", operators.Alts(
"WSP / CRLF WSP",
WSP(),
operators.Concat(
"CRLF WSP",
CRLF(),
WSP(),
),
))
}
// OCTET = %x00-FF
func OCTET() operators.Operator {
return operators.Range("OCTET", []byte{0}, []byte{255})
}
// SP = %x20
func SP() operators.Operator {
return operators.Terminal("SP", []byte{32})
}
// VCHAR = %x21-7E
func VCHAR() operators.Operator {
return operators.Range("VCHAR", []byte{33}, []byte{126})
}
// WSP = SP / HTAB
func WSP() operators.Operator {
return operators.Alts(
"WSP",
SP(),
HTAB(),
)
}