Module: ABNF::Parser::Controls::ABNF

Extended by:
ABNF
Included in:
ABNF
Defined in:
lib/abnf/parser/controls/abnf.rb

Instance Method Summary collapse

Instance Method Details

#alternationObject



7
8
9
# File 'lib/abnf/parser/controls/abnf.rb', line 7

def alternation
  %{#{ABNF.foo} / #{ABNF.bar} / #{ABNF.baz}}
end

#barObject



11
12
13
# File 'lib/abnf/parser/controls/abnf.rb', line 11

def bar
  '%x62.61.72'
end

#bazObject



15
16
17
# File 'lib/abnf/parser/controls/abnf.rb', line 15

def baz
  '%x62.61.7A'
end

#concatenationObject



19
20
21
# File 'lib/abnf/parser/controls/abnf.rb', line 19

def concatenation
  %{"[" #{foo} "]"}
end

#exampleObject Also known as: regexp_pattern



32
33
34
# File 'lib/abnf/parser/controls/abnf.rb', line 32

def example
  '(1*ALPHA "-" 1*ALPHA) / "~"'
end

#fooObject Also known as: terminal



23
24
25
# File 'lib/abnf/parser/controls/abnf.rb', line 23

def foo
  '%x66.6F.6F'
end

#foobarObject



28
29
30
# File 'lib/abnf/parser/controls/abnf.rb', line 28

def foobar
  '%x66.6F.6F.62.61.72'
end

#recursionObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/abnf/parser/controls/abnf.rb', line 37

def recursion
  "s0 = n0 s0 / n1 s2 / n2 s1 / \"\"\\r\ns1 = n0 s1 / n1 s0 / n2 s2\\r\ns2 = n0 s2 / n1 s1 / n2 s0\\r\nn0 = \"0\" / \"3\" / \"6\" / \"9\"\\r\nn1 = \"1\" / \"4\" / \"7\"\\r\nn2 = \"2\" / \"5\" / \"8\"\\r\n  ABNF\nend\n"

#rfc5234Object



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
# File 'lib/abnf/parser/controls/abnf.rb', line 48

def rfc5234
  @rfc5234 ||= "rulelist       =  1*( rule / (*c-wsp c-nl) )\\r\n\\r\nrule           =  rulename defined-as elements c-nl\\r\n               ; continues if next line starts\\r\n               ;  with white space\\r\n\\r\nrulename       =  ALPHA *(ALPHA / DIGIT / \"-\")\\r\n\\r\ndefined-as     =  *c-wsp (\"=\" / \"=/\") *c-wsp\\r\n               ; basic rules definition and\\r\n               ;  incremental alternatives\\r\n\\r\nelements       =  alternation *c-wsp\\r\n\\r\nc-wsp          =  WSP / (c-nl WSP)\\r\n\\r\nc-nl           =  comment / CRLF\\r\n               ; comment or newline\\r\n\\r\ncomment        =  \";\" *(WSP / VCHAR) CRLF\\r\n\\r\nalternation    =  concatenation\\r\n          *(*c-wsp \"/\" *c-wsp concatenation)\\r\n\\r\nconcatenation  =  repetition *(1*c-wsp repetition)\\r\n\\r\nrepetition     =  [repeat] element\\r\n\\r\nrepeat         =  1*DIGIT / (*DIGIT \"*\" *DIGIT)\\r\n\\r\nelement        =  rulename / group / option /\\r\n          char-val / num-val / prose-val\\r\n\\r\ngroup          =  \"(\" *c-wsp alternation *c-wsp \")\"\\r\n\\r\noption         =  \"[\" *c-wsp alternation *c-wsp \"]\"\\r\n\\r\nchar-val       =  DQUOTE *(%x20-21 / %x23-7E) DQUOTE\\r\n               ; quoted string of SP and VCHAR\\r\n               ;  without DQUOTE\\r\n\\r\nnum-val        =  \"%\" (bin-val / dec-val / hex-val)\\r\n\\r\nbin-val        =  \"b\" 1*BIT\\r\n          [ 1*(\".\" 1*BIT) / (\"-\" 1*BIT) ]\\r\n               ; series of concatenated bit values\\r\n               ;  or single ONEOF range\\r\n\\r\ndec-val        =  \"d\" 1*DIGIT\\r\n          [ 1*(\".\" 1*DIGIT) / (\"-\" 1*DIGIT) ]\\r\n\\r\nhex-val        =  \"x\" 1*HEXDIG\\r\n          [ 1*(\".\" 1*HEXDIG) / (\"-\" 1*HEXDIG) ]\\r\n\\r\nprose-val      =  \"<\" *(%x20-3D / %x3F-7E) \">\"\\r\n               ; bracketed string of SP and VCHAR\\r\n               ;  without angles\\r\n               ; prose description, to be used as\\r\n               ;  last resort\\r\n  ABNF\nend\n"

#rfc7230Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/abnf/parser/controls/abnf.rb', line 112

def rfc7230
  @rfc7230 ||= "BWS = OWS\\r\nConnection = *( \",\" OWS ) connection-option *( OWS \",\" [ OWS\\r\n connection-option ] )\\r\nContent-Length = 1*DIGIT\\r\nHTTP-message = start-line *( header-field CRLF ) CRLF [ message-body\\r\n ]\\r\nHTTP-name = %x48.54.54.50 ; HTTP\\r\nHTTP-version = HTTP-name \"/\" DIGIT \".\" DIGIT\\r\nHost = uri-host [ \":\" port ]\\r\nOWS = *( SP / HTAB )\\r\nRWS = 1*( SP / HTAB )\\r\nTE = [ ( \",\" / t-codings ) *( OWS \",\" [ OWS t-codings ] ) ]\\r\nTrailer = *( \",\" OWS ) field-name *( OWS \",\" [ OWS field-name ] )\\r\nTransfer-Encoding = *( \",\" OWS ) transfer-coding *( OWS \",\" [ OWS\\r\n transfer-coding ] )\\r\nURI-reference = <URI-reference, see [RFC3986], Section 4.1>\\r\nUpgrade = *( \",\" OWS ) protocol *( OWS \",\" [ OWS protocol ] )\\r\nVia = *( \",\" OWS ) ( received-protocol RWS received-by [ RWS comment\\r\n ] ) *( OWS \",\" [ OWS ( received-protocol RWS received-by [ RWS\\r\n comment ] ) ] )\\r\nabsolute-URI = <absolute-URI, see [RFC3986], Section 4.3>\\r\nabsolute-form = absolute-URI\\r\nabsolute-path = 1*( \"/\" segment )\\r\nasterisk-form = \"*\"\\r\nauthority = <authority, see [RFC3986], Section 3.2>\\r\nauthority-form = authority\\r\nchunk = chunk-size [ chunk-ext ] CRLF chunk-data CRLF\\r\nchunk-data = 1*OCTET\\r\nchunk-ext = *( \";\" chunk-ext-name [ \"=\" chunk-ext-val ] )\\r\nchunk-ext-name = token\\r\nchunk-ext-val = token / quoted-string\\r\nchunk-size = 1*HEXDIG\\r\nchunked-body = *chunk last-chunk trailer-part CRLF\\r\ncomment = \"(\" *( ctext / quoted-pair / comment ) \")\"\\r\nconnection-option = token\\r\nctext = HTAB / SP / %x21-27 ; '!'-'''\\r\n / %x2A-5B ; '*'-'['\\r\n / %x5D-7E ; ']'-'~'\\r\n / obs-text\\r\nfield-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\\r\nfield-name = token\\r\nfield-value = *( field-content / obs-fold )\\r\nfield-vchar = VCHAR / obs-text\\r\nfragment = <fragment, see [RFC3986], Section 3.5>\\r\nheader-field = field-name \":\" OWS field-value OWS\\r\nhttp-URI = \"http://\" authority path-abempty [ \"?\" query ] [ \"#\"\\r\n fragment ]\\r\nhttps-URI = \"https://\" authority path-abempty [ \"?\" query ] [ \"#\"\\r\n fragment ]\\r\nlast-chunk = 1*\"0\" [ chunk-ext ] CRLF\\r\nmessage-body = *OCTET\\r\nmethod = token\\r\nobs-fold = CRLF 1*( SP / HTAB )\\r\nobs-text = %x80-FF\\r\norigin-form = absolute-path [ \"?\" query ]\\r\npartial-URI = relative-part [ \"?\" query ]\\r\npath-abempty = <path-abempty, see [RFC3986], Section 3.3>\\r\nport = <port, see [RFC3986], Section 3.2.3>\\r\nprotocol = protocol-name [ \"/\" protocol-version ]\\r\nprotocol-name = token\\r\nprotocol-version = token\\r\npseudonym = token\\r\nqdtext = HTAB / SP / \"!\" / %x23-5B ; '#'-'['\\r\n / %x5D-7E ; ']'-'~'\\r\n / obs-text\\r\nquery = <query, see [RFC3986], Section 3.4>\\r\nquoted-pair = \"\\\" ( HTAB / SP / VCHAR / obs-text )\\r\nquoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE\\r\nrank = ( \"0\" [ \".\" *3DIGIT ] ) / ( \"1\" [ \".\" *3\"0\" ] )\\r\nreason-phrase = *( HTAB / SP / VCHAR / obs-text )\\r\nreceived-by = ( uri-host [ \":\" port ] ) / pseudonym\\r\nreceived-protocol = [ protocol-name \"/\" ] protocol-version\\r\nrelative-part = <relative-part, see [RFC3986], Section 4.2>\\r\nrequest-line = method SP request-target SP HTTP-version CRLF\\r\nrequest-target = origin-form / absolute-form / authority-form /\\r\n asterisk-form\\r\nscheme = <scheme, see [RFC3986], Section 3.1>\\r\nsegment = <segment, see [RFC3986], Section 3.3>\\r\nstart-line = request-line / status-line\\r\nstatus-code = 3DIGIT\\r\nstatus-line = HTTP-version SP status-code SP reason-phrase CRLF\\r\nt-codings = \"trailers\" / ( transfer-coding [ t-ranking ] )\\r\nt-ranking = OWS \";\" OWS \"q=\" rank\\r\ntchar = \"!\" / \"#\" / \"$\" / \"%\" / \"&\" / \"'\" / \"*\" / \"+\" / \"-\" / \".\" /\\r\n \"^\" / \"_\" / \"`\" / \"|\" / \"~\" / DIGIT / ALPHA\\r\ntoken = 1*tchar\\r\ntrailer-part = *( header-field CRLF )\\r\ntransfer-coding = \"chunked\" / \"compress\" / \"deflate\" / \"gzip\" /\\r\n transfer-extension\\r\ntransfer-extension = token *( OWS \";\" OWS transfer-parameter )\\r\ntransfer-parameter = token BWS \"=\" BWS ( token / quoted-string )\\r\nuri-host = <host, see [RFC3986], Section 3.2.2>\\r\nAccept = [ ( \",\" / ( media-range [ accept-params ] ) ) *( OWS \",\" [\\r\n OWS ( media-range [ accept-params ] ) ] ) ]\\r\nAccept-Charset = *( \",\" OWS ) ( ( charset / \"*\" ) [ weight ] ) *( OWS\\r\n \",\" [ OWS ( ( charset / \"*\" ) [ weight ] ) ] )\\r\nAccept-Encoding = [ ( \",\" / ( codings [ weight ] ) ) *( OWS \",\" [ OWS\\r\n ( codings [ weight ] ) ] ) ]\\r\nAccept-Language = *( \",\" OWS ) ( language-range [ weight ] ) *( OWS\\r\n \",\" [ OWS ( language-range [ weight ] ) ] )\\r\nAllow = [ ( \",\" / method ) *( OWS \",\" [ OWS method ] ) ]\\r\nContent-Encoding = *( \",\" OWS ) content-coding *( OWS \",\" [ OWS\\r\n content-coding ] )\\r\nContent-Language = *( \",\" OWS ) language-tag *( OWS \",\" [ OWS\\r\n language-tag ] )\\r\nContent-Location = absolute-URI / partial-URI\\r\nContent-Type = media-type\\r\nDate = HTTP-date\\r\nExpect = \"100-continue\"\\r\nFrom = mailbox\\r\nGMT = %x47.4D.54 ; GMT\\r\nHTTP-date = IMF-fixdate / obs-date\\r\nIMF-fixdate = day-name \",\" SP date1 SP time-of-day SP GMT\\r\nLocation = URI-reference\\r\nMax-Forwards = 1*DIGIT\\r\nReferer = absolute-URI / partial-URI\\r\nRetry-After = HTTP-date / delay-seconds\\r\nServer = product *( RWS ( product / comment ) )\\r\nUser-Agent = product *( RWS ( product / comment ) )\\r\nVary = \"*\" / ( *( \",\" OWS ) field-name *( OWS \",\" [ OWS field-name ]\\r\n ) )\\r\naccept-ext = OWS \";\" OWS token [ \"=\" ( token / quoted-string ) ]\\r\naccept-params = weight *accept-ext\\r\nasctime-date = day-name SP date3 SP time-of-day SP year\\r\ncharset = token\\r\ncodings = content-coding / \"identity\" / \"*\"\\r\ncontent-coding = token\\r\ndate1 = day SP month SP year\\r\ndate2 = day \"-\" month \"-\" 2DIGIT\\r\ndate3 = month SP ( 2DIGIT / ( SP DIGIT ) )\\r\nday = 2DIGIT\\r\nday-name = %x4D.6F.6E ; Mon\\r\n / %x54.75.65 ; Tue\\r\n / %x57.65.64 ; Wed\\r\n / %x54.68.75 ; Thu\\r\n / %x46.72.69 ; Fri\\r\n / %x53.61.74 ; Sat\\r\n / %x53.75.6E ; Sun\\r\nday-name-l = %x4D.6F.6E.64.61.79 ; Monday\\r\n / %x54.75.65.73.64.61.79 ; Tuesday\\r\n / %x57.65.64.6E.65.73.64.61.79 ; Wednesday\\r\n / %x54.68.75.72.73.64.61.79 ; Thursday\\r\n / %x46.72.69.64.61.79 ; Friday\\r\n / %x53.61.74.75.72.64.61.79 ; Saturday\\r\n / %x53.75.6E.64.61.79 ; Sunday\\r\ndelay-seconds = 1*DIGIT\\r\nhour = 2DIGIT\\r\nlanguage-range = <language-range, see [RFC4647], Section 2.1>\\r\nlanguage-tag = <Language-Tag, see [RFC5646], Section 2.1>\\r\nmailbox = <mailbox, see [RFC5322], Section 3.4>\\r\nmedia-range = ( \"*/*\" / ( type \"/*\" ) / ( type \"/\" subtype ) ) *( OWS\\r\n \";\" OWS parameter )\\r\nmedia-type = type \"/\" subtype *( OWS \";\" OWS parameter )\\r\nmethod = token\\r\nminute = 2DIGIT\\r\nmonth = %x4A.61.6E ; Jan\\r\n / %x46.65.62 ; Feb\\r\n / %x4D.61.72 ; Mar\\r\n / %x41.70.72 ; Apr\\r\n / %x4D.61.79 ; May\\r\n / %x4A.75.6E ; Jun\\r\n / %x4A.75.6C ; Jul\\r\n / %x41.75.67 ; Aug\\r\n / %x53.65.70 ; Sep\\r\n / %x4F.63.74 ; Oct\\r\n / %x4E.6F.76 ; Nov\\r\n / %x44.65.63 ; Dec\\r\nobs-date = rfc850-date / asctime-date\\r\nparameter = token \"=\" ( token / quoted-string )\\r\nproduct = token [ \"/\" product-version ]\\r\nproduct-version = token\\r\nqvalue = ( \"0\" [ \".\" *3DIGIT ] ) / ( \"1\" [ \".\" *3\"0\" ] )\\r\nrfc850-date = day-name-l \",\" SP date2 SP time-of-day SP GMT\\r\nsecond = 2DIGIT\\r\nsubtype = token\\r\ntime-of-day = hour \":\" minute \":\" second\\r\ntype = token\\r\nweight = OWS \";\" OWS \"q=\" qvalue\\r\nyear = 4DIGIT\\r\nETag = entity-tag\\r\nIf-Match = \"*\" / ( *( \",\" OWS ) entity-tag *( OWS \",\" [ OWS\\r\n entity-tag ] ) )\\r\nIf-Modified-Since = HTTP-date\\r\nIf-None-Match = \"*\" / ( *( \",\" OWS ) entity-tag *( OWS \",\" [ OWS\\r\n entity-tag ] ) )\\r\nIf-Unmodified-Since = HTTP-date\\r\nLast-Modified = HTTP-date\\r\nentity-tag = [ weak ] opaque-tag\\r\netagc = \"!\" / %x23-7E ; '#'-'~'\\r\n / obs-text\\r\nopaque-tag = DQUOTE *etagc DQUOTE\\r\nweak = %x57.2F ; W/\\r\nAccept-Ranges = acceptable-ranges\\r\nContent-Range = byte-content-range / other-content-range\\r\nIf-Range = entity-tag / HTTP-date\\r\nRange = byte-ranges-specifier / other-ranges-specifier\\r\nacceptable-ranges = ( *( \",\" OWS ) range-unit *( OWS \",\" [ OWS\\r\n range-unit ] ) ) / \"none\"\\r\nbyte-content-range = bytes-unit SP ( byte-range-resp /\\r\n unsatisfied-range )\\r\nbyte-range = first-byte-pos \"-\" last-byte-pos\\r\nbyte-range-resp = byte-range \"/\" ( complete-length / \"*\" )\\r\nbyte-range-set = *( \",\" OWS ) ( byte-range-spec /\\r\n suffix-byte-range-spec ) *( OWS \",\" [ OWS ( byte-range-spec /\\r\n suffix-byte-range-spec ) ] )\\r\nbyte-range-spec = first-byte-pos \"-\" [ last-byte-pos ]\\r\nbyte-ranges-specifier = bytes-unit \"=\" byte-range-set\\r\nbytes-unit = \"bytes\"\\r\ncomplete-length = 1*DIGIT\\r\nfirst-byte-pos = 1*DIGIT\\r\nlast-byte-pos = 1*DIGIT\\r\nother-content-range = other-range-unit SP other-range-resp\\r\nother-range-resp = *CHAR\\r\nother-range-set = 1*VCHAR\\r\nother-range-unit = token\\r\nother-ranges-specifier = other-range-unit \"=\" other-range-set\\r\nrange-unit = bytes-unit / other-range-unit\\r\nsuffix-byte-range-spec = \"-\" suffix-length\\r\nsuffix-length = 1*DIGIT\\r\nunsatisfied-range = \"*/\" complete-length\\r\nAge = delta-seconds\\r\nCache-Control = *( \",\" OWS ) cache-directive *( OWS \",\" [ OWS\\r\n cache-directive ] )\\r\nExpires = HTTP-date\\r\nPragma = *( \",\" OWS ) pragma-directive *( OWS \",\" [ OWS\\r\n pragma-directive ] )\\r\nWarning = *( \",\" OWS ) warning-value *( OWS \",\" [ OWS warning-value ]\\r\n )\\r\ncache-directive = token [ \"=\" ( token / quoted-string ) ]\\r\ndelta-seconds = 1*DIGIT\\r\nextension-pragma = token [ \"=\" ( token / quoted-string ) ]\\r\npragma-directive = \"no-cache\" / extension-pragma\\r\nwarn-agent = ( uri-host [ \":\" port ] ) / pseudonym\\r\nwarn-code = 3DIGIT\\r\nwarn-date = DQUOTE HTTP-date DQUOTE\\r\nwarn-text = quoted-string\\r\nwarning-value = warn-code SP warn-agent SP warn-text [ SP warn-date\\r\n ]\\r\nAuthorization = credentials\\r\nProxy-Authenticate = *( \",\" OWS ) challenge *( OWS \",\" [ OWS\\r\n challenge ] )\\r\nProxy-Authorization = credentials\\r\nWWW-Authenticate = *( \",\" OWS ) challenge *( OWS \",\" [ OWS challenge\\r\n ] )\\r\nauth-param = token BWS \"=\" BWS ( token / quoted-string )\\r\nauth-scheme = token\\r\nchallenge = auth-scheme [ 1*SP ( token68 / [ ( \",\" / auth-param ) *(\\r\n OWS \",\" [ OWS auth-param ] ) ] ) ]\\r\ncredentials = auth-scheme [ 1*SP ( token68 / [ ( \",\" / auth-param )\\r\n *( OWS \",\" [ OWS auth-param ] ) ] ) ]\\r\ntoken68 = 1*( ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\" / \"+\" / \"/\" )\\r\n *\"=\"\\r\n  ABNF\nend\n"

#ruleObject



369
370
371
# File 'lib/abnf/parser/controls/abnf.rb', line 369

def rule
  "some-rule = #{foo}\r\n"
end