rack-mount 0.0.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. data/README.rdoc +12 -4
  2. data/lib/rack/mount/analysis/histogram.rb +55 -6
  3. data/lib/rack/mount/analysis/splitting.rb +103 -89
  4. data/lib/rack/mount/code_generation.rb +120 -0
  5. data/lib/rack/mount/generatable_regexp.rb +95 -48
  6. data/lib/rack/mount/multimap.rb +84 -41
  7. data/lib/rack/mount/prefix.rb +13 -8
  8. data/lib/rack/mount/regexp_with_named_groups.rb +27 -7
  9. data/lib/rack/mount/route.rb +75 -18
  10. data/lib/rack/mount/route_set.rb +308 -22
  11. data/lib/rack/mount/strexp/parser.rb +160 -0
  12. data/lib/rack/mount/strexp/tokenizer.rb +83 -0
  13. data/lib/rack/mount/strexp.rb +54 -79
  14. data/lib/rack/mount/utils.rb +65 -174
  15. data/lib/rack/mount/vendor/regin/regin/alternation.rb +40 -0
  16. data/lib/rack/mount/vendor/regin/regin/anchor.rb +4 -0
  17. data/lib/rack/mount/vendor/regin/regin/atom.rb +54 -0
  18. data/lib/rack/mount/vendor/regin/regin/character.rb +51 -0
  19. data/lib/rack/mount/vendor/regin/regin/character_class.rb +50 -0
  20. data/lib/rack/mount/vendor/regin/regin/collection.rb +77 -0
  21. data/lib/rack/mount/vendor/regin/regin/expression.rb +126 -0
  22. data/lib/rack/mount/vendor/regin/regin/group.rb +90 -0
  23. data/lib/rack/mount/vendor/regin/regin/options.rb +55 -0
  24. data/lib/rack/mount/vendor/regin/regin/parser.rb +546 -0
  25. data/lib/rack/mount/vendor/regin/regin/tokenizer.rb +255 -0
  26. data/lib/rack/mount/vendor/regin/regin/version.rb +3 -0
  27. data/lib/rack/mount/vendor/regin/regin.rb +75 -0
  28. data/lib/rack/mount/version.rb +3 -0
  29. data/lib/rack/mount.rb +13 -17
  30. metadata +88 -35
  31. data/lib/rack/mount/analysis/frequency.rb +0 -51
  32. data/lib/rack/mount/const.rb +0 -45
  33. data/lib/rack/mount/exceptions.rb +0 -3
  34. data/lib/rack/mount/generation/route.rb +0 -57
  35. data/lib/rack/mount/generation/route_set.rb +0 -163
  36. data/lib/rack/mount/meta_method.rb +0 -104
  37. data/lib/rack/mount/mixover.rb +0 -47
  38. data/lib/rack/mount/recognition/code_generation.rb +0 -99
  39. data/lib/rack/mount/recognition/route.rb +0 -59
  40. data/lib/rack/mount/recognition/route_set.rb +0 -88
  41. data/lib/rack/mount/vendor/multimap/multimap.rb +0 -466
  42. data/lib/rack/mount/vendor/multimap/multiset.rb +0 -153
  43. data/lib/rack/mount/vendor/multimap/nested_multimap.rb +0 -156
@@ -0,0 +1,546 @@
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.6
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+ module Regin
9
+ class Parser < Racc::Parser #:nodoc: all
10
+
11
+ def self.parse_regexp(regexp)
12
+ options = Options.from_int(regexp.options)
13
+
14
+ parser = new
15
+ parser.options_stack << options.to_h
16
+
17
+ expression = parser.scan_str(regexp.source)
18
+ expression = expression.dup(options.to_h) if options.any?
19
+ expression
20
+ end
21
+
22
+ attr_accessor :options_stack
23
+
24
+ def initialize
25
+ @capture_index = 0
26
+ @capture_index_stack = []
27
+ @options_stack = []
28
+ end
29
+
30
+ ##### State transition tables begin ###
31
+
32
+ racc_action_table = [
33
+ 43, 44, 46, 48, 4, 52, 17, 9, 10, 11,
34
+ 13, 30, 28, 19, 20, 21, 4, 6, 7, 9,
35
+ 10, 11, 13, 55, 45, 47, 49, 50, 4, 6,
36
+ 7, 9, 10, 11, 13, 80, 56, 47, 49, 50,
37
+ 4, 6, 7, 9, 10, 11, 13, 83, 47, 49,
38
+ 50, 81, 4, 6, 7, 9, 10, 11, 13, 74,
39
+ 47, 49, 50, 31, 4, 6, 7, 9, 10, 11,
40
+ 13, 47, 49, 50, 32, 85, 4, 6, 7, 9,
41
+ 10, 11, 13, 47, 49, 50, 86, 33, 4, 6,
42
+ 7, 9, 10, 11, 13, 47, 49, 50, 88, 89,
43
+ 4, 6, 7, 9, 10, 11, 13, 47, 49, 50,
44
+ 27, 91, 4, 6, 7, 9, 10, 11, 13, 22,
45
+ 34, 23, 36, 41, 25, 6, 7, 58, 60, 62,
46
+ 63, 64, 65, 66, 67, 68, 69, 70, 57, 59,
47
+ 61, 22, 22, 38, 22, 72, 25, 39, 95, 39,
48
+ 47, 49, 50 ]
49
+
50
+ racc_action_check = [
51
+ 28, 28, 28, 28, 13, 29, 3, 13, 13, 13,
52
+ 13, 14, 13, 3, 3, 3, 31, 13, 13, 31,
53
+ 31, 31, 31, 35, 28, 28, 28, 28, 0, 31,
54
+ 31, 0, 0, 0, 0, 51, 35, 84, 84, 84,
55
+ 80, 0, 0, 80, 80, 80, 80, 73, 73, 73,
56
+ 73, 71, 1, 80, 80, 1, 1, 1, 1, 42,
57
+ 42, 42, 42, 15, 48, 1, 1, 48, 48, 48,
58
+ 48, 83, 83, 83, 19, 75, 46, 48, 48, 46,
59
+ 46, 46, 46, 87, 87, 87, 76, 20, 30, 46,
60
+ 46, 30, 30, 30, 30, 77, 77, 77, 78, 79,
61
+ 43, 30, 30, 43, 43, 43, 43, 74, 74, 74,
62
+ 12, 81, 44, 43, 43, 44, 44, 44, 44, 4,
63
+ 21, 4, 22, 27, 4, 44, 44, 36, 36, 36,
64
+ 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
65
+ 36, 23, 24, 24, 37, 37, 23, 24, 90, 37,
66
+ 45, 45, 45 ]
67
+
68
+ racc_action_pointer = [
69
+ 25, 49, nil, -5, 116, nil, nil, nil, nil, nil,
70
+ nil, nil, 110, 1, 9, 61, nil, nil, nil, 63,
71
+ 76, 112, 108, 138, 139, nil, nil, 123, -12, -5,
72
+ 85, 13, nil, nil, nil, 15, 105, 141, nil, nil,
73
+ nil, nil, 23, 97, 109, 113, 73, nil, 61, nil,
74
+ nil, 21, nil, nil, nil, nil, nil, nil, nil, nil,
75
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
76
+ nil, 37, nil, 11, 70, 65, 76, 58, 88, 89,
77
+ 37, 107, nil, 34, 0, nil, nil, 46, nil, nil,
78
+ 138, nil, nil, nil, nil, nil ]
79
+
80
+ racc_action_default = [
81
+ -59, -5, -7, -9, -59, -10, -23, -24, -15, -13,
82
+ -14, -16, -59, -59, -1, -2, -6, -27, -8, -25,
83
+ -26, -59, -59, -59, -59, -36, -35, -59, -59, -59,
84
+ -59, -59, -28, -29, -32, -59, -59, -59, -11, -34,
85
+ -33, 96, -59, -59, -59, -59, -59, -56, -59, -57,
86
+ -58, -59, -17, -3, -4, -31, -30, -49, -38, -50,
87
+ -39, -51, -40, -41, -42, -43, -44, -45, -46, -47,
88
+ -48, -59, -12, -59, -59, -59, -59, -59, -59, -59,
89
+ -59, -59, -55, -59, -59, -18, -19, -59, -21, -22,
90
+ -59, -37, -54, -53, -52, -20 ]
91
+
92
+ racc_goto_table = [
93
+ 12, 24, 40, 35, 42, 53, 54, 16, 18, 71,
94
+ 51, nil, nil, 29, nil, 40, nil, nil, 73, nil,
95
+ 37, 77, nil, nil, nil, nil, nil, nil, nil, nil,
96
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
97
+ nil, nil, nil, 75, 76, nil, 78, nil, 79, 82,
98
+ 84, nil, nil, 87, nil, nil, nil, nil, nil, 92,
99
+ 93, nil, nil, 94, nil, nil, nil, nil, nil, nil,
100
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
101
+ 90 ]
102
+
103
+ racc_goto_check = [
104
+ 1, 9, 13, 12, 15, 3, 3, 5, 7, 14,
105
+ 11, nil, nil, 1, nil, 13, nil, nil, 15, nil,
106
+ 9, 15, nil, nil, nil, nil, nil, nil, nil, nil,
107
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
108
+ nil, nil, nil, 1, 1, nil, 1, nil, 1, 15,
109
+ 15, nil, nil, 15, nil, nil, nil, nil, nil, 15,
110
+ 15, nil, nil, 15, nil, nil, nil, nil, nil, nil,
111
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
112
+ 1 ]
113
+
114
+ racc_goto_pointer = [
115
+ nil, 0, nil, -25, nil, 6, nil, 5, nil, -3,
116
+ nil, -18, -18, -22, -27, -24 ]
117
+
118
+ racc_goto_default = [
119
+ nil, nil, 14, 15, 1, 2, 3, nil, 5, nil,
120
+ 8, nil, nil, 26, nil, nil ]
121
+
122
+ racc_reduce_table = [
123
+ 0, 0, :racc_error,
124
+ 1, 41, :_reduce_1,
125
+ 1, 41, :_reduce_none,
126
+ 3, 42, :_reduce_3,
127
+ 3, 42, :_reduce_4,
128
+ 1, 43, :_reduce_5,
129
+ 2, 44, :_reduce_6,
130
+ 1, 44, :_reduce_7,
131
+ 2, 45, :_reduce_8,
132
+ 1, 45, :_reduce_none,
133
+ 1, 46, :_reduce_none,
134
+ 3, 46, :_reduce_11,
135
+ 4, 46, :_reduce_12,
136
+ 1, 46, :_reduce_13,
137
+ 1, 46, :_reduce_14,
138
+ 1, 46, :_reduce_15,
139
+ 1, 46, :_reduce_16,
140
+ 3, 48, :_reduce_17,
141
+ 5, 48, :_reduce_18,
142
+ 5, 48, :_reduce_19,
143
+ 6, 48, :_reduce_20,
144
+ 5, 48, :_reduce_21,
145
+ 5, 48, :_reduce_22,
146
+ 1, 50, :_reduce_none,
147
+ 1, 50, :_reduce_none,
148
+ 1, 47, :_reduce_none,
149
+ 1, 47, :_reduce_none,
150
+ 1, 47, :_reduce_none,
151
+ 2, 47, :_reduce_28,
152
+ 2, 47, :_reduce_29,
153
+ 3, 47, :_reduce_30,
154
+ 2, 52, :_reduce_31,
155
+ 1, 52, :_reduce_none,
156
+ 2, 49, :_reduce_33,
157
+ 2, 49, :_reduce_34,
158
+ 1, 49, :_reduce_none,
159
+ 1, 49, :_reduce_none,
160
+ 5, 53, :_reduce_37,
161
+ 1, 54, :_reduce_none,
162
+ 1, 54, :_reduce_none,
163
+ 1, 54, :_reduce_none,
164
+ 1, 54, :_reduce_none,
165
+ 1, 54, :_reduce_none,
166
+ 1, 54, :_reduce_none,
167
+ 1, 54, :_reduce_none,
168
+ 1, 54, :_reduce_none,
169
+ 1, 54, :_reduce_none,
170
+ 1, 54, :_reduce_none,
171
+ 1, 54, :_reduce_none,
172
+ 1, 54, :_reduce_none,
173
+ 1, 54, :_reduce_none,
174
+ 1, 54, :_reduce_none,
175
+ 4, 51, :_reduce_52,
176
+ 4, 51, :_reduce_53,
177
+ 4, 51, :_reduce_54,
178
+ 3, 51, :_reduce_55,
179
+ 1, 55, :_reduce_56,
180
+ 1, 55, :_reduce_57,
181
+ 1, 55, :_reduce_58 ]
182
+
183
+ racc_reduce_n = 59
184
+
185
+ racc_shift_n = 96
186
+
187
+ racc_token_table = {
188
+ false => 0,
189
+ :error => 1,
190
+ :BAR => 2,
191
+ :LBRACK => 3,
192
+ :RBRACK => 4,
193
+ :NEGATE => 5,
194
+ :CCLASS => 6,
195
+ :DOT => 7,
196
+ :CHAR => 8,
197
+ :LPAREN => 9,
198
+ :RPAREN => 10,
199
+ :QMARK => 11,
200
+ :EQUAL => 12,
201
+ :BANG => 13,
202
+ :COLON => 14,
203
+ :NAME => 15,
204
+ :L_ANCHOR => 16,
205
+ :R_ANCHOR => 17,
206
+ :STAR => 18,
207
+ :PLUS => 19,
208
+ :LCURLY => 20,
209
+ :RCURLY => 21,
210
+ "alnum" => 22,
211
+ "alpha" => 23,
212
+ "ascii" => 24,
213
+ "blank" => 25,
214
+ "cntrl" => 26,
215
+ "digit" => 27,
216
+ "graph" => 28,
217
+ "lower" => 29,
218
+ "print" => 30,
219
+ "punct" => 31,
220
+ "space" => 32,
221
+ "upper" => 33,
222
+ "word" => 34,
223
+ "xdigit" => 35,
224
+ :MINUS => 36,
225
+ :MULTILINE => 37,
226
+ :IGNORECASE => 38,
227
+ :EXTENDED => 39 }
228
+
229
+ racc_nt_base = 40
230
+
231
+ racc_use_result_var = true
232
+
233
+ Racc_arg = [
234
+ racc_action_table,
235
+ racc_action_check,
236
+ racc_action_default,
237
+ racc_action_pointer,
238
+ racc_goto_table,
239
+ racc_goto_check,
240
+ racc_goto_default,
241
+ racc_goto_pointer,
242
+ racc_nt_base,
243
+ racc_reduce_table,
244
+ racc_token_table,
245
+ racc_shift_n,
246
+ racc_reduce_n,
247
+ racc_use_result_var ]
248
+
249
+ Racc_token_to_s_table = [
250
+ "$end",
251
+ "error",
252
+ "BAR",
253
+ "LBRACK",
254
+ "RBRACK",
255
+ "NEGATE",
256
+ "CCLASS",
257
+ "DOT",
258
+ "CHAR",
259
+ "LPAREN",
260
+ "RPAREN",
261
+ "QMARK",
262
+ "EQUAL",
263
+ "BANG",
264
+ "COLON",
265
+ "NAME",
266
+ "L_ANCHOR",
267
+ "R_ANCHOR",
268
+ "STAR",
269
+ "PLUS",
270
+ "LCURLY",
271
+ "RCURLY",
272
+ "\"alnum\"",
273
+ "\"alpha\"",
274
+ "\"ascii\"",
275
+ "\"blank\"",
276
+ "\"cntrl\"",
277
+ "\"digit\"",
278
+ "\"graph\"",
279
+ "\"lower\"",
280
+ "\"print\"",
281
+ "\"punct\"",
282
+ "\"space\"",
283
+ "\"upper\"",
284
+ "\"word\"",
285
+ "\"xdigit\"",
286
+ "MINUS",
287
+ "MULTILINE",
288
+ "IGNORECASE",
289
+ "EXTENDED",
290
+ "$start",
291
+ "expression",
292
+ "alternation",
293
+ "subexpression",
294
+ "expression_ary",
295
+ "quantified_atom",
296
+ "atom",
297
+ "quantifier",
298
+ "group",
299
+ "bracket_expression",
300
+ "anchor",
301
+ "options",
302
+ "quantifier_char",
303
+ "posix_bracket_expression",
304
+ "posix_bracket_type",
305
+ "modifier" ]
306
+
307
+ Racc_debug_parser = false
308
+
309
+ ##### State transition tables end #####
310
+
311
+ # reduce 0 omitted
312
+
313
+ def _reduce_1(val, _values, result)
314
+ result = Expression.new(val[0])
315
+ result
316
+ end
317
+
318
+ # reduce 2 omitted
319
+
320
+ def _reduce_3(val, _values, result)
321
+ result = val[0] + [val[2]]
322
+ result
323
+ end
324
+
325
+ def _reduce_4(val, _values, result)
326
+ result = Alternation.new(val[0], val[2])
327
+ result
328
+ end
329
+
330
+ def _reduce_5(val, _values, result)
331
+ result = Expression.new(val[0])
332
+ result
333
+ end
334
+
335
+ def _reduce_6(val, _values, result)
336
+ result = val[0] + [val[1]]
337
+ result
338
+ end
339
+
340
+ def _reduce_7(val, _values, result)
341
+ result = [val[0]]
342
+ result
343
+ end
344
+
345
+ def _reduce_8(val, _values, result)
346
+ result = val[0].dup(:quantifier => val[1])
347
+ result
348
+ end
349
+
350
+ # reduce 9 omitted
351
+
352
+ # reduce 10 omitted
353
+
354
+ def _reduce_11(val, _values, result)
355
+ result = CharacterClass.new(val[1])
356
+ result
357
+ end
358
+
359
+ def _reduce_12(val, _values, result)
360
+ result = CharacterClass.new(val[2], :negate => true)
361
+ result
362
+ end
363
+
364
+ def _reduce_13(val, _values, result)
365
+ result = CharacterClass.new(val[0])
366
+ result
367
+ end
368
+
369
+ def _reduce_14(val, _values, result)
370
+ result = CharacterClass.new('.')
371
+ result
372
+ end
373
+
374
+ def _reduce_15(val, _values, result)
375
+ result = Anchor.new(val[0])
376
+ result
377
+ end
378
+
379
+ def _reduce_16(val, _values, result)
380
+ result = Character.new(val[0])
381
+ result
382
+ end
383
+
384
+ def _reduce_17(val, _values, result)
385
+ result = Group.new(val[1], :index => @capture_index_stack.pop)
386
+
387
+ result
388
+ end
389
+
390
+ def _reduce_18(val, _values, result)
391
+ result = Group.new(val[3], :index => @capture_index_stack.pop, :lookahead => :postive)
392
+
393
+ result
394
+ end
395
+
396
+ def _reduce_19(val, _values, result)
397
+ result = Group.new(val[3], :index => @capture_index_stack.pop, :lookahead => :negative)
398
+
399
+ result
400
+ end
401
+
402
+ def _reduce_20(val, _values, result)
403
+ result = Group.new(val[4], val[2].merge(:capture => false))
404
+ @options_stack.pop
405
+
406
+ result
407
+ end
408
+
409
+ def _reduce_21(val, _values, result)
410
+ result = Group.new(val[3], :capture => false);
411
+
412
+ result
413
+ end
414
+
415
+ def _reduce_22(val, _values, result)
416
+ result = Group.new(val[3], :name => val[2], :index => @capture_index_stack.pop);
417
+
418
+ result
419
+ end
420
+
421
+ # reduce 23 omitted
422
+
423
+ # reduce 24 omitted
424
+
425
+ # reduce 25 omitted
426
+
427
+ # reduce 26 omitted
428
+
429
+ # reduce 27 omitted
430
+
431
+ def _reduce_28(val, _values, result)
432
+ result = val.join
433
+ result
434
+ end
435
+
436
+ def _reduce_29(val, _values, result)
437
+ result = val.join
438
+ result
439
+ end
440
+
441
+ def _reduce_30(val, _values, result)
442
+ result = val.join
443
+ result
444
+ end
445
+
446
+ def _reduce_31(val, _values, result)
447
+ result = val.join
448
+ result
449
+ end
450
+
451
+ # reduce 32 omitted
452
+
453
+ def _reduce_33(val, _values, result)
454
+ result = val.join
455
+ result
456
+ end
457
+
458
+ def _reduce_34(val, _values, result)
459
+ result = val.join
460
+ result
461
+ end
462
+
463
+ # reduce 35 omitted
464
+
465
+ # reduce 36 omitted
466
+
467
+ def _reduce_37(val, _values, result)
468
+ result = val.join
469
+ result
470
+ end
471
+
472
+ # reduce 38 omitted
473
+
474
+ # reduce 39 omitted
475
+
476
+ # reduce 40 omitted
477
+
478
+ # reduce 41 omitted
479
+
480
+ # reduce 42 omitted
481
+
482
+ # reduce 43 omitted
483
+
484
+ # reduce 44 omitted
485
+
486
+ # reduce 45 omitted
487
+
488
+ # reduce 46 omitted
489
+
490
+ # reduce 47 omitted
491
+
492
+ # reduce 48 omitted
493
+
494
+ # reduce 49 omitted
495
+
496
+ # reduce 50 omitted
497
+
498
+ # reduce 51 omitted
499
+
500
+ def _reduce_52(val, _values, result)
501
+ @options_stack << result = { val[1] => false, val[2] => false, val[3] => false }
502
+
503
+ result
504
+ end
505
+
506
+ def _reduce_53(val, _values, result)
507
+ @options_stack << result = { val[0] => true, val[2] => false, val[3] => false }
508
+
509
+ result
510
+ end
511
+
512
+ def _reduce_54(val, _values, result)
513
+ @options_stack << result = { val[0] => true, val[1] => true, val[3] => false }
514
+
515
+ result
516
+ end
517
+
518
+ def _reduce_55(val, _values, result)
519
+ @options_stack << result = { val[0] => true, val[1] => true, val[2] => true }
520
+
521
+ result
522
+ end
523
+
524
+ def _reduce_56(val, _values, result)
525
+ result = :multiline
526
+ result
527
+ end
528
+
529
+ def _reduce_57(val, _values, result)
530
+ result = :ignorecase
531
+ result
532
+ end
533
+
534
+ def _reduce_58(val, _values, result)
535
+ result = :extended
536
+ result
537
+ end
538
+
539
+ def _reduce_none(val, _values, result)
540
+ val[0]
541
+ end
542
+
543
+ end # class Parser
544
+ end # module Regin
545
+
546
+ require 'regin/tokenizer'