mail 2.5.5 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +5 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +170 -108
  4. data/lib/mail/attachments_list.rb +13 -10
  5. data/lib/mail/body.rb +105 -91
  6. data/lib/mail/check_delivery_params.rb +30 -22
  7. data/lib/mail/configuration.rb +3 -0
  8. data/lib/mail/constants.rb +79 -0
  9. data/lib/mail/elements/address.rb +118 -174
  10. data/lib/mail/elements/address_list.rb +16 -56
  11. data/lib/mail/elements/content_disposition_element.rb +12 -22
  12. data/lib/mail/elements/content_location_element.rb +9 -17
  13. data/lib/mail/elements/content_transfer_encoding_element.rb +8 -19
  14. data/lib/mail/elements/content_type_element.rb +20 -30
  15. data/lib/mail/elements/date_time_element.rb +10 -21
  16. data/lib/mail/elements/envelope_from_element.rb +23 -31
  17. data/lib/mail/elements/message_ids_element.rb +22 -20
  18. data/lib/mail/elements/mime_version_element.rb +10 -21
  19. data/lib/mail/elements/phrase_list.rb +13 -15
  20. data/lib/mail/elements/received_element.rb +26 -21
  21. data/lib/mail/elements.rb +1 -0
  22. data/lib/mail/encodings/7bit.rb +10 -14
  23. data/lib/mail/encodings/8bit.rb +5 -18
  24. data/lib/mail/encodings/base64.rb +15 -10
  25. data/lib/mail/encodings/binary.rb +4 -22
  26. data/lib/mail/encodings/identity.rb +24 -0
  27. data/lib/mail/encodings/quoted_printable.rb +13 -7
  28. data/lib/mail/encodings/transfer_encoding.rb +47 -28
  29. data/lib/mail/encodings/unix_to_unix.rb +20 -0
  30. data/lib/mail/encodings.rb +102 -93
  31. data/lib/mail/envelope.rb +12 -19
  32. data/lib/mail/field.rb +143 -71
  33. data/lib/mail/field_list.rb +73 -19
  34. data/lib/mail/fields/bcc_field.rb +42 -48
  35. data/lib/mail/fields/cc_field.rb +29 -50
  36. data/lib/mail/fields/comments_field.rb +28 -37
  37. data/lib/mail/fields/common_address_field.rb +170 -0
  38. data/lib/mail/fields/common_date_field.rb +58 -0
  39. data/lib/mail/fields/common_field.rb +77 -0
  40. data/lib/mail/fields/common_message_id_field.rb +42 -0
  41. data/lib/mail/fields/content_description_field.rb +8 -14
  42. data/lib/mail/fields/content_disposition_field.rb +20 -44
  43. data/lib/mail/fields/content_id_field.rb +25 -51
  44. data/lib/mail/fields/content_location_field.rb +12 -25
  45. data/lib/mail/fields/content_transfer_encoding_field.rb +31 -36
  46. data/lib/mail/fields/content_type_field.rb +51 -80
  47. data/lib/mail/fields/date_field.rb +24 -52
  48. data/lib/mail/fields/from_field.rb +29 -50
  49. data/lib/mail/fields/in_reply_to_field.rb +39 -49
  50. data/lib/mail/fields/keywords_field.rb +19 -32
  51. data/lib/mail/fields/message_id_field.rb +26 -71
  52. data/lib/mail/fields/mime_version_field.rb +20 -30
  53. data/lib/mail/fields/named_structured_field.rb +11 -0
  54. data/lib/mail/fields/named_unstructured_field.rb +11 -0
  55. data/lib/mail/fields/optional_field.rb +10 -7
  56. data/lib/mail/fields/{common/parameter_hash.rb → parameter_hash.rb} +16 -13
  57. data/lib/mail/fields/received_field.rb +44 -57
  58. data/lib/mail/fields/references_field.rb +36 -49
  59. data/lib/mail/fields/reply_to_field.rb +29 -50
  60. data/lib/mail/fields/resent_bcc_field.rb +29 -50
  61. data/lib/mail/fields/resent_cc_field.rb +29 -50
  62. data/lib/mail/fields/resent_date_field.rb +6 -30
  63. data/lib/mail/fields/resent_from_field.rb +29 -50
  64. data/lib/mail/fields/resent_message_id_field.rb +6 -29
  65. data/lib/mail/fields/resent_sender_field.rb +28 -57
  66. data/lib/mail/fields/resent_to_field.rb +29 -50
  67. data/lib/mail/fields/return_path_field.rb +51 -55
  68. data/lib/mail/fields/sender_field.rb +35 -56
  69. data/lib/mail/fields/structured_field.rb +4 -30
  70. data/lib/mail/fields/subject_field.rb +10 -11
  71. data/lib/mail/fields/to_field.rb +29 -50
  72. data/lib/mail/fields/unstructured_field.rb +43 -51
  73. data/lib/mail/fields.rb +1 -0
  74. data/lib/mail/header.rb +78 -129
  75. data/lib/mail/indifferent_hash.rb +1 -0
  76. data/lib/mail/mail.rb +18 -11
  77. data/lib/mail/matchers/attachment_matchers.rb +44 -0
  78. data/lib/mail/matchers/has_sent_mail.rb +81 -4
  79. data/lib/mail/message.rb +142 -139
  80. data/lib/mail/multibyte/chars.rb +24 -180
  81. data/lib/mail/multibyte/unicode.rb +32 -27
  82. data/lib/mail/multibyte/utils.rb +27 -43
  83. data/lib/mail/multibyte.rb +56 -16
  84. data/lib/mail/network/delivery_methods/exim.rb +6 -4
  85. data/lib/mail/network/delivery_methods/file_delivery.rb +12 -10
  86. data/lib/mail/network/delivery_methods/logger_delivery.rb +34 -0
  87. data/lib/mail/network/delivery_methods/sendmail.rb +63 -21
  88. data/lib/mail/network/delivery_methods/smtp.rb +76 -50
  89. data/lib/mail/network/delivery_methods/smtp_connection.rb +4 -4
  90. data/lib/mail/network/delivery_methods/test_mailer.rb +5 -2
  91. data/lib/mail/network/retriever_methods/base.rb +9 -8
  92. data/lib/mail/network/retriever_methods/imap.rb +37 -18
  93. data/lib/mail/network/retriever_methods/pop3.rb +6 -3
  94. data/lib/mail/network/retriever_methods/test_retriever.rb +4 -2
  95. data/lib/mail/network.rb +2 -0
  96. data/lib/mail/parser_tools.rb +15 -0
  97. data/lib/mail/parsers/address_lists_parser.rb +33242 -0
  98. data/lib/mail/parsers/address_lists_parser.rl +179 -0
  99. data/lib/mail/parsers/content_disposition_parser.rb +901 -0
  100. data/lib/mail/parsers/content_disposition_parser.rl +89 -0
  101. data/lib/mail/parsers/content_location_parser.rb +822 -0
  102. data/lib/mail/parsers/content_location_parser.rl +78 -0
  103. data/lib/mail/parsers/content_transfer_encoding_parser.rb +522 -0
  104. data/lib/mail/parsers/content_transfer_encoding_parser.rl +71 -0
  105. data/lib/mail/parsers/content_type_parser.rb +1048 -0
  106. data/lib/mail/parsers/content_type_parser.rl +90 -0
  107. data/lib/mail/parsers/date_time_parser.rb +891 -0
  108. data/lib/mail/parsers/date_time_parser.rl +69 -0
  109. data/lib/mail/parsers/envelope_from_parser.rb +3675 -0
  110. data/lib/mail/parsers/envelope_from_parser.rl +89 -0
  111. data/lib/mail/parsers/message_ids_parser.rb +5161 -0
  112. data/lib/mail/parsers/message_ids_parser.rl +93 -0
  113. data/lib/mail/parsers/mime_version_parser.rb +513 -0
  114. data/lib/mail/parsers/mime_version_parser.rl +68 -0
  115. data/lib/mail/parsers/phrase_lists_parser.rb +884 -0
  116. data/lib/mail/parsers/phrase_lists_parser.rl +90 -0
  117. data/lib/mail/parsers/received_parser.rb +8782 -0
  118. data/lib/mail/parsers/received_parser.rl +91 -0
  119. data/lib/mail/parsers/rfc2045_content_transfer_encoding.rl +13 -0
  120. data/lib/mail/parsers/rfc2045_content_type.rl +25 -0
  121. data/lib/mail/parsers/rfc2045_mime.rl +16 -0
  122. data/lib/mail/parsers/rfc2183_content_disposition.rl +15 -0
  123. data/lib/mail/parsers/rfc3629_utf8.rl +19 -0
  124. data/lib/mail/parsers/rfc5234_abnf_core_rules.rl +22 -0
  125. data/lib/mail/parsers/rfc5322.rl +74 -0
  126. data/lib/mail/parsers/rfc5322_address.rl +72 -0
  127. data/lib/mail/parsers/rfc5322_date_time.rl +37 -0
  128. data/lib/mail/parsers/rfc5322_lexical_tokens.rl +60 -0
  129. data/lib/mail/parsers.rb +13 -0
  130. data/lib/mail/part.rb +11 -12
  131. data/lib/mail/parts_list.rb +90 -14
  132. data/lib/mail/smtp_envelope.rb +57 -0
  133. data/lib/mail/utilities.rb +415 -76
  134. data/lib/mail/values/unicode_tables.dat +0 -0
  135. data/lib/mail/version.rb +8 -15
  136. data/lib/mail/yaml.rb +30 -0
  137. data/lib/mail.rb +9 -32
  138. metadata +127 -79
  139. data/CHANGELOG.rdoc +0 -742
  140. data/CONTRIBUTING.md +0 -45
  141. data/Dependencies.txt +0 -3
  142. data/Gemfile +0 -32
  143. data/Rakefile +0 -21
  144. data/TODO.rdoc +0 -9
  145. data/lib/VERSION +0 -4
  146. data/lib/load_parsers.rb +0 -35
  147. data/lib/mail/core_extensions/nil.rb +0 -19
  148. data/lib/mail/core_extensions/object.rb +0 -13
  149. data/lib/mail/core_extensions/smtp.rb +0 -24
  150. data/lib/mail/core_extensions/string/access.rb +0 -145
  151. data/lib/mail/core_extensions/string/multibyte.rb +0 -78
  152. data/lib/mail/core_extensions/string.rb +0 -33
  153. data/lib/mail/fields/common/address_container.rb +0 -16
  154. data/lib/mail/fields/common/common_address.rb +0 -140
  155. data/lib/mail/fields/common/common_date.rb +0 -42
  156. data/lib/mail/fields/common/common_field.rb +0 -57
  157. data/lib/mail/fields/common/common_message_id.rb +0 -48
  158. data/lib/mail/multibyte/exceptions.rb +0 -8
  159. data/lib/mail/parsers/address_lists.rb +0 -64
  160. data/lib/mail/parsers/address_lists.treetop +0 -19
  161. data/lib/mail/parsers/content_disposition.rb +0 -535
  162. data/lib/mail/parsers/content_disposition.treetop +0 -46
  163. data/lib/mail/parsers/content_location.rb +0 -139
  164. data/lib/mail/parsers/content_location.treetop +0 -20
  165. data/lib/mail/parsers/content_transfer_encoding.rb +0 -201
  166. data/lib/mail/parsers/content_transfer_encoding.treetop +0 -18
  167. data/lib/mail/parsers/content_type.rb +0 -971
  168. data/lib/mail/parsers/content_type.treetop +0 -68
  169. data/lib/mail/parsers/date_time.rb +0 -114
  170. data/lib/mail/parsers/date_time.treetop +0 -11
  171. data/lib/mail/parsers/envelope_from.rb +0 -194
  172. data/lib/mail/parsers/envelope_from.treetop +0 -32
  173. data/lib/mail/parsers/message_ids.rb +0 -45
  174. data/lib/mail/parsers/message_ids.treetop +0 -15
  175. data/lib/mail/parsers/mime_version.rb +0 -144
  176. data/lib/mail/parsers/mime_version.treetop +0 -19
  177. data/lib/mail/parsers/phrase_lists.rb +0 -45
  178. data/lib/mail/parsers/phrase_lists.treetop +0 -15
  179. data/lib/mail/parsers/received.rb +0 -71
  180. data/lib/mail/parsers/received.treetop +0 -11
  181. data/lib/mail/parsers/rfc2045.rb +0 -421
  182. data/lib/mail/parsers/rfc2045.treetop +0 -35
  183. data/lib/mail/parsers/rfc2822.rb +0 -5397
  184. data/lib/mail/parsers/rfc2822.treetop +0 -408
  185. data/lib/mail/parsers/rfc2822_obsolete.rb +0 -3768
  186. data/lib/mail/parsers/rfc2822_obsolete.treetop +0 -241
  187. data/lib/mail/patterns.rb +0 -35
  188. data/lib/mail/version_specific/ruby_1_8.rb +0 -119
  189. data/lib/mail/version_specific/ruby_1_9.rb +0 -147
  190. data/lib/tasks/corpus.rake +0 -125
  191. data/lib/tasks/treetop.rake +0 -10
@@ -1,971 +0,0 @@
1
- # Autogenerated from a Treetop grammar. Edits may be lost.
2
-
3
-
4
- module Mail
5
- module ContentType
6
- include Treetop::Runtime
7
-
8
- def root
9
- @root ||= :content_type
10
- end
11
-
12
- include RFC2822
13
-
14
- include RFC2045
15
-
16
- module ContentType0
17
- def CFWS1
18
- elements[0]
19
- end
20
-
21
- def parameter
22
- elements[2]
23
- end
24
-
25
- def CFWS2
26
- elements[3]
27
- end
28
- end
29
-
30
- module ContentType1
31
- def main_type
32
- elements[0]
33
- end
34
-
35
- def sub_type
36
- elements[2]
37
- end
38
-
39
- def param_hashes
40
- elements[3]
41
- end
42
- end
43
-
44
- module ContentType2
45
- def parameters
46
- param_hashes.elements.map do |param|
47
- param.parameter.param_hash
48
- end
49
- end
50
- end
51
-
52
- def _nt_content_type
53
- start_index = index
54
- if node_cache[:content_type].has_key?(index)
55
- cached = node_cache[:content_type][index]
56
- if cached
57
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
58
- @index = cached.interval.end
59
- end
60
- return cached
61
- end
62
-
63
- i0, s0 = index, []
64
- r1 = _nt_main_type
65
- s0 << r1
66
- if r1
67
- if has_terminal?("/", false, index)
68
- r2 = instantiate_node(SyntaxNode,input, index...(index + 1))
69
- @index += 1
70
- else
71
- terminal_parse_failure("/")
72
- r2 = nil
73
- end
74
- s0 << r2
75
- if r2
76
- r3 = _nt_sub_type
77
- s0 << r3
78
- if r3
79
- s4, i4 = [], index
80
- loop do
81
- i5, s5 = index, []
82
- r6 = _nt_CFWS
83
- s5 << r6
84
- if r6
85
- s7, i7 = [], index
86
- loop do
87
- if has_terminal?(";", false, index)
88
- r8 = instantiate_node(SyntaxNode,input, index...(index + 1))
89
- @index += 1
90
- else
91
- terminal_parse_failure(";")
92
- r8 = nil
93
- end
94
- if r8
95
- s7 << r8
96
- else
97
- break
98
- end
99
- end
100
- r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
101
- s5 << r7
102
- if r7
103
- r9 = _nt_parameter
104
- s5 << r9
105
- if r9
106
- r10 = _nt_CFWS
107
- s5 << r10
108
- end
109
- end
110
- end
111
- if s5.last
112
- r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
113
- r5.extend(ContentType0)
114
- else
115
- @index = i5
116
- r5 = nil
117
- end
118
- if r5
119
- s4 << r5
120
- else
121
- break
122
- end
123
- end
124
- r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
125
- s0 << r4
126
- end
127
- end
128
- end
129
- if s0.last
130
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
131
- r0.extend(ContentType1)
132
- r0.extend(ContentType2)
133
- else
134
- @index = i0
135
- r0 = nil
136
- end
137
-
138
- node_cache[:content_type][start_index] = r0
139
-
140
- r0
141
- end
142
-
143
- def _nt_main_type
144
- start_index = index
145
- if node_cache[:main_type].has_key?(index)
146
- cached = node_cache[:main_type][index]
147
- if cached
148
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
149
- @index = cached.interval.end
150
- end
151
- return cached
152
- end
153
-
154
- i0 = index
155
- r1 = _nt_discrete_type
156
- if r1
157
- r0 = r1
158
- else
159
- r2 = _nt_composite_type
160
- if r2
161
- r0 = r2
162
- else
163
- @index = i0
164
- r0 = nil
165
- end
166
- end
167
-
168
- node_cache[:main_type][start_index] = r0
169
-
170
- r0
171
- end
172
-
173
- module DiscreteType0
174
- end
175
-
176
- module DiscreteType1
177
- end
178
-
179
- module DiscreteType2
180
- end
181
-
182
- module DiscreteType3
183
- end
184
-
185
- module DiscreteType4
186
- end
187
-
188
- def _nt_discrete_type
189
- start_index = index
190
- if node_cache[:discrete_type].has_key?(index)
191
- cached = node_cache[:discrete_type][index]
192
- if cached
193
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
194
- @index = cached.interval.end
195
- end
196
- return cached
197
- end
198
-
199
- i0 = index
200
- i1, s1 = index, []
201
- if has_terminal?('\G[tT]', true, index)
202
- r2 = true
203
- @index += 1
204
- else
205
- r2 = nil
206
- end
207
- s1 << r2
208
- if r2
209
- if has_terminal?('\G[eE]', true, index)
210
- r3 = true
211
- @index += 1
212
- else
213
- r3 = nil
214
- end
215
- s1 << r3
216
- if r3
217
- if has_terminal?('\G[xX]', true, index)
218
- r4 = true
219
- @index += 1
220
- else
221
- r4 = nil
222
- end
223
- s1 << r4
224
- if r4
225
- if has_terminal?('\G[tT]', true, index)
226
- r5 = true
227
- @index += 1
228
- else
229
- r5 = nil
230
- end
231
- s1 << r5
232
- end
233
- end
234
- end
235
- if s1.last
236
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
237
- r1.extend(DiscreteType0)
238
- else
239
- @index = i1
240
- r1 = nil
241
- end
242
- if r1
243
- r0 = r1
244
- else
245
- i6, s6 = index, []
246
- if has_terminal?('\G[iI]', true, index)
247
- r7 = true
248
- @index += 1
249
- else
250
- r7 = nil
251
- end
252
- s6 << r7
253
- if r7
254
- if has_terminal?('\G[mM]', true, index)
255
- r8 = true
256
- @index += 1
257
- else
258
- r8 = nil
259
- end
260
- s6 << r8
261
- if r8
262
- if has_terminal?('\G[aA]', true, index)
263
- r9 = true
264
- @index += 1
265
- else
266
- r9 = nil
267
- end
268
- s6 << r9
269
- if r9
270
- if has_terminal?('\G[gG]', true, index)
271
- r10 = true
272
- @index += 1
273
- else
274
- r10 = nil
275
- end
276
- s6 << r10
277
- if r10
278
- if has_terminal?('\G[eE]', true, index)
279
- r11 = true
280
- @index += 1
281
- else
282
- r11 = nil
283
- end
284
- s6 << r11
285
- end
286
- end
287
- end
288
- end
289
- if s6.last
290
- r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
291
- r6.extend(DiscreteType1)
292
- else
293
- @index = i6
294
- r6 = nil
295
- end
296
- if r6
297
- r0 = r6
298
- else
299
- i12, s12 = index, []
300
- if has_terminal?('\G[aA]', true, index)
301
- r13 = true
302
- @index += 1
303
- else
304
- r13 = nil
305
- end
306
- s12 << r13
307
- if r13
308
- if has_terminal?('\G[uU]', true, index)
309
- r14 = true
310
- @index += 1
311
- else
312
- r14 = nil
313
- end
314
- s12 << r14
315
- if r14
316
- if has_terminal?('\G[dD]', true, index)
317
- r15 = true
318
- @index += 1
319
- else
320
- r15 = nil
321
- end
322
- s12 << r15
323
- if r15
324
- if has_terminal?('\G[iI]', true, index)
325
- r16 = true
326
- @index += 1
327
- else
328
- r16 = nil
329
- end
330
- s12 << r16
331
- if r16
332
- if has_terminal?('\G[oO]', true, index)
333
- r17 = true
334
- @index += 1
335
- else
336
- r17 = nil
337
- end
338
- s12 << r17
339
- end
340
- end
341
- end
342
- end
343
- if s12.last
344
- r12 = instantiate_node(SyntaxNode,input, i12...index, s12)
345
- r12.extend(DiscreteType2)
346
- else
347
- @index = i12
348
- r12 = nil
349
- end
350
- if r12
351
- r0 = r12
352
- else
353
- i18, s18 = index, []
354
- if has_terminal?('\G[vV]', true, index)
355
- r19 = true
356
- @index += 1
357
- else
358
- r19 = nil
359
- end
360
- s18 << r19
361
- if r19
362
- if has_terminal?('\G[iI]', true, index)
363
- r20 = true
364
- @index += 1
365
- else
366
- r20 = nil
367
- end
368
- s18 << r20
369
- if r20
370
- if has_terminal?('\G[dD]', true, index)
371
- r21 = true
372
- @index += 1
373
- else
374
- r21 = nil
375
- end
376
- s18 << r21
377
- if r21
378
- if has_terminal?('\G[eE]', true, index)
379
- r22 = true
380
- @index += 1
381
- else
382
- r22 = nil
383
- end
384
- s18 << r22
385
- if r22
386
- if has_terminal?('\G[oO]', true, index)
387
- r23 = true
388
- @index += 1
389
- else
390
- r23 = nil
391
- end
392
- s18 << r23
393
- end
394
- end
395
- end
396
- end
397
- if s18.last
398
- r18 = instantiate_node(SyntaxNode,input, i18...index, s18)
399
- r18.extend(DiscreteType3)
400
- else
401
- @index = i18
402
- r18 = nil
403
- end
404
- if r18
405
- r0 = r18
406
- else
407
- i24, s24 = index, []
408
- if has_terminal?('\G[aA]', true, index)
409
- r25 = true
410
- @index += 1
411
- else
412
- r25 = nil
413
- end
414
- s24 << r25
415
- if r25
416
- if has_terminal?('\G[pP]', true, index)
417
- r26 = true
418
- @index += 1
419
- else
420
- r26 = nil
421
- end
422
- s24 << r26
423
- if r26
424
- if has_terminal?('\G[pP]', true, index)
425
- r27 = true
426
- @index += 1
427
- else
428
- r27 = nil
429
- end
430
- s24 << r27
431
- if r27
432
- if has_terminal?('\G[lL]', true, index)
433
- r28 = true
434
- @index += 1
435
- else
436
- r28 = nil
437
- end
438
- s24 << r28
439
- if r28
440
- if has_terminal?('\G[iI]', true, index)
441
- r29 = true
442
- @index += 1
443
- else
444
- r29 = nil
445
- end
446
- s24 << r29
447
- if r29
448
- if has_terminal?('\G[cC]', true, index)
449
- r30 = true
450
- @index += 1
451
- else
452
- r30 = nil
453
- end
454
- s24 << r30
455
- if r30
456
- if has_terminal?('\G[aA]', true, index)
457
- r31 = true
458
- @index += 1
459
- else
460
- r31 = nil
461
- end
462
- s24 << r31
463
- if r31
464
- if has_terminal?('\G[tT]', true, index)
465
- r32 = true
466
- @index += 1
467
- else
468
- r32 = nil
469
- end
470
- s24 << r32
471
- if r32
472
- if has_terminal?('\G[iI]', true, index)
473
- r33 = true
474
- @index += 1
475
- else
476
- r33 = nil
477
- end
478
- s24 << r33
479
- if r33
480
- if has_terminal?('\G[oO]', true, index)
481
- r34 = true
482
- @index += 1
483
- else
484
- r34 = nil
485
- end
486
- s24 << r34
487
- if r34
488
- if has_terminal?('\G[nN]', true, index)
489
- r35 = true
490
- @index += 1
491
- else
492
- r35 = nil
493
- end
494
- s24 << r35
495
- end
496
- end
497
- end
498
- end
499
- end
500
- end
501
- end
502
- end
503
- end
504
- end
505
- if s24.last
506
- r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
507
- r24.extend(DiscreteType4)
508
- else
509
- @index = i24
510
- r24 = nil
511
- end
512
- if r24
513
- r0 = r24
514
- else
515
- r36 = _nt_extension_token
516
- if r36
517
- r0 = r36
518
- else
519
- @index = i0
520
- r0 = nil
521
- end
522
- end
523
- end
524
- end
525
- end
526
- end
527
-
528
- node_cache[:discrete_type][start_index] = r0
529
-
530
- r0
531
- end
532
-
533
- module CompositeType0
534
- end
535
-
536
- module CompositeType1
537
- end
538
-
539
- def _nt_composite_type
540
- start_index = index
541
- if node_cache[:composite_type].has_key?(index)
542
- cached = node_cache[:composite_type][index]
543
- if cached
544
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
545
- @index = cached.interval.end
546
- end
547
- return cached
548
- end
549
-
550
- i0 = index
551
- i1, s1 = index, []
552
- if has_terminal?('\G[mM]', true, index)
553
- r2 = true
554
- @index += 1
555
- else
556
- r2 = nil
557
- end
558
- s1 << r2
559
- if r2
560
- if has_terminal?('\G[eE]', true, index)
561
- r3 = true
562
- @index += 1
563
- else
564
- r3 = nil
565
- end
566
- s1 << r3
567
- if r3
568
- if has_terminal?('\G[sS]', true, index)
569
- r4 = true
570
- @index += 1
571
- else
572
- r4 = nil
573
- end
574
- s1 << r4
575
- if r4
576
- if has_terminal?('\G[sS]', true, index)
577
- r5 = true
578
- @index += 1
579
- else
580
- r5 = nil
581
- end
582
- s1 << r5
583
- if r5
584
- if has_terminal?('\G[aA]', true, index)
585
- r6 = true
586
- @index += 1
587
- else
588
- r6 = nil
589
- end
590
- s1 << r6
591
- if r6
592
- if has_terminal?('\G[gG]', true, index)
593
- r7 = true
594
- @index += 1
595
- else
596
- r7 = nil
597
- end
598
- s1 << r7
599
- if r7
600
- if has_terminal?('\G[eE]', true, index)
601
- r8 = true
602
- @index += 1
603
- else
604
- r8 = nil
605
- end
606
- s1 << r8
607
- end
608
- end
609
- end
610
- end
611
- end
612
- end
613
- if s1.last
614
- r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
615
- r1.extend(CompositeType0)
616
- else
617
- @index = i1
618
- r1 = nil
619
- end
620
- if r1
621
- r0 = r1
622
- else
623
- i9, s9 = index, []
624
- if has_terminal?('\G[mM]', true, index)
625
- r10 = true
626
- @index += 1
627
- else
628
- r10 = nil
629
- end
630
- s9 << r10
631
- if r10
632
- if has_terminal?('\G[uU]', true, index)
633
- r11 = true
634
- @index += 1
635
- else
636
- r11 = nil
637
- end
638
- s9 << r11
639
- if r11
640
- if has_terminal?('\G[lL]', true, index)
641
- r12 = true
642
- @index += 1
643
- else
644
- r12 = nil
645
- end
646
- s9 << r12
647
- if r12
648
- if has_terminal?('\G[tT]', true, index)
649
- r13 = true
650
- @index += 1
651
- else
652
- r13 = nil
653
- end
654
- s9 << r13
655
- if r13
656
- if has_terminal?('\G[iI]', true, index)
657
- r14 = true
658
- @index += 1
659
- else
660
- r14 = nil
661
- end
662
- s9 << r14
663
- if r14
664
- if has_terminal?('\G[pP]', true, index)
665
- r15 = true
666
- @index += 1
667
- else
668
- r15 = nil
669
- end
670
- s9 << r15
671
- if r15
672
- if has_terminal?('\G[aA]', true, index)
673
- r16 = true
674
- @index += 1
675
- else
676
- r16 = nil
677
- end
678
- s9 << r16
679
- if r16
680
- if has_terminal?('\G[rR]', true, index)
681
- r17 = true
682
- @index += 1
683
- else
684
- r17 = nil
685
- end
686
- s9 << r17
687
- if r17
688
- if has_terminal?('\G[tT]', true, index)
689
- r18 = true
690
- @index += 1
691
- else
692
- r18 = nil
693
- end
694
- s9 << r18
695
- end
696
- end
697
- end
698
- end
699
- end
700
- end
701
- end
702
- end
703
- if s9.last
704
- r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
705
- r9.extend(CompositeType1)
706
- else
707
- @index = i9
708
- r9 = nil
709
- end
710
- if r9
711
- r0 = r9
712
- else
713
- r19 = _nt_extension_token
714
- if r19
715
- r0 = r19
716
- else
717
- @index = i0
718
- r0 = nil
719
- end
720
- end
721
- end
722
-
723
- node_cache[:composite_type][start_index] = r0
724
-
725
- r0
726
- end
727
-
728
- def _nt_extension_token
729
- start_index = index
730
- if node_cache[:extension_token].has_key?(index)
731
- cached = node_cache[:extension_token][index]
732
- if cached
733
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
734
- @index = cached.interval.end
735
- end
736
- return cached
737
- end
738
-
739
- i0 = index
740
- r1 = _nt_ietf_token
741
- if r1
742
- r0 = r1
743
- else
744
- r2 = _nt_custom_x_token
745
- if r2
746
- r0 = r2
747
- else
748
- @index = i0
749
- r0 = nil
750
- end
751
- end
752
-
753
- node_cache[:extension_token][start_index] = r0
754
-
755
- r0
756
- end
757
-
758
- def _nt_sub_type
759
- start_index = index
760
- if node_cache[:sub_type].has_key?(index)
761
- cached = node_cache[:sub_type][index]
762
- if cached
763
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
764
- @index = cached.interval.end
765
- end
766
- return cached
767
- end
768
-
769
- i0 = index
770
- r1 = _nt_extension_token
771
- if r1
772
- r0 = r1
773
- else
774
- r2 = _nt_iana_token
775
- if r2
776
- r0 = r2
777
- else
778
- @index = i0
779
- r0 = nil
780
- end
781
- end
782
-
783
- node_cache[:sub_type][start_index] = r0
784
-
785
- r0
786
- end
787
-
788
- module Parameter0
789
- def attr
790
- elements[1]
791
- end
792
-
793
- def val
794
- elements[3]
795
- end
796
-
797
- end
798
-
799
- module Parameter1
800
- def param_hash
801
- {attr.text_value => val.text_value}
802
- end
803
- end
804
-
805
- def _nt_parameter
806
- start_index = index
807
- if node_cache[:parameter].has_key?(index)
808
- cached = node_cache[:parameter][index]
809
- if cached
810
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
811
- @index = cached.interval.end
812
- end
813
- return cached
814
- end
815
-
816
- i0, s0 = index, []
817
- r2 = _nt_CFWS
818
- if r2
819
- r1 = r2
820
- else
821
- r1 = instantiate_node(SyntaxNode,input, index...index)
822
- end
823
- s0 << r1
824
- if r1
825
- r3 = _nt_attribute
826
- s0 << r3
827
- if r3
828
- if has_terminal?("=", false, index)
829
- r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
830
- @index += 1
831
- else
832
- terminal_parse_failure("=")
833
- r4 = nil
834
- end
835
- s0 << r4
836
- if r4
837
- r5 = _nt_value
838
- s0 << r5
839
- if r5
840
- r7 = _nt_CFWS
841
- if r7
842
- r6 = r7
843
- else
844
- r6 = instantiate_node(SyntaxNode,input, index...index)
845
- end
846
- s0 << r6
847
- end
848
- end
849
- end
850
- end
851
- if s0.last
852
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
853
- r0.extend(Parameter0)
854
- r0.extend(Parameter1)
855
- else
856
- @index = i0
857
- r0 = nil
858
- end
859
-
860
- node_cache[:parameter][start_index] = r0
861
-
862
- r0
863
- end
864
-
865
- def _nt_attribute
866
- start_index = index
867
- if node_cache[:attribute].has_key?(index)
868
- cached = node_cache[:attribute][index]
869
- if cached
870
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
871
- @index = cached.interval.end
872
- end
873
- return cached
874
- end
875
-
876
- s0, i0 = [], index
877
- loop do
878
- r1 = _nt_token
879
- if r1
880
- s0 << r1
881
- else
882
- break
883
- end
884
- end
885
- if s0.empty?
886
- @index = i0
887
- r0 = nil
888
- else
889
- r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
890
- end
891
-
892
- node_cache[:attribute][start_index] = r0
893
-
894
- r0
895
- end
896
-
897
- module Value0
898
- def text_value
899
- quoted_content.text_value
900
- end
901
- end
902
-
903
- def _nt_value
904
- start_index = index
905
- if node_cache[:value].has_key?(index)
906
- cached = node_cache[:value][index]
907
- if cached
908
- cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
909
- @index = cached.interval.end
910
- end
911
- return cached
912
- end
913
-
914
- i0 = index
915
- r1 = _nt_quoted_string
916
- r1.extend(Value0)
917
- if r1
918
- r0 = r1
919
- else
920
- s2, i2 = [], index
921
- loop do
922
- i3 = index
923
- r4 = _nt_token
924
- if r4
925
- r3 = r4
926
- else
927
- if has_terminal?('\G[\\x3d]', true, index)
928
- r5 = true
929
- @index += 1
930
- else
931
- r5 = nil
932
- end
933
- if r5
934
- r3 = r5
935
- else
936
- @index = i3
937
- r3 = nil
938
- end
939
- end
940
- if r3
941
- s2 << r3
942
- else
943
- break
944
- end
945
- end
946
- if s2.empty?
947
- @index = i2
948
- r2 = nil
949
- else
950
- r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
951
- end
952
- if r2
953
- r0 = r2
954
- else
955
- @index = i0
956
- r0 = nil
957
- end
958
- end
959
-
960
- node_cache[:value][start_index] = r0
961
-
962
- r0
963
- end
964
-
965
- end
966
-
967
- class ContentTypeParser < Treetop::Runtime::CompiledParser
968
- include ContentType
969
- end
970
-
971
- end