rack-mount 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/mount/analysis/splitting.rb +11 -11
- data/lib/rack/mount/generatable_regexp.rb +4 -2
- data/lib/rack/mount/utils.rb +1 -1
- data/lib/rack/mount/vendor/reginald/reginald.rb +38 -35
- data/lib/rack/mount/vendor/reginald/reginald/alternation.rb +1 -1
- data/lib/rack/mount/vendor/reginald/reginald/anchor.rb +1 -17
- data/lib/rack/mount/vendor/reginald/reginald/atom.rb +20 -0
- data/lib/rack/mount/vendor/reginald/reginald/character.rb +6 -14
- data/lib/rack/mount/vendor/reginald/reginald/character_class.rb +21 -30
- data/lib/rack/mount/vendor/reginald/reginald/expression.rb +33 -6
- data/lib/rack/mount/vendor/reginald/reginald/group.rb +7 -1
- data/lib/rack/mount/vendor/reginald/reginald/parser.rb +199 -118
- data/lib/rack/mount/vendor/reginald/reginald/tokenizer.rb +113 -17
- metadata +3 -2
@@ -62,21 +62,21 @@ module Rack::Mount
|
|
62
62
|
if part.is_a?(Reginald::Group)
|
63
63
|
if index > 0
|
64
64
|
previous = parts[index-1]
|
65
|
-
if previous.
|
66
|
-
boundaries << previous.
|
65
|
+
if previous.literal?
|
66
|
+
boundaries << previous.value
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
if inside = part[0][0]
|
71
|
-
if inside.
|
72
|
-
boundaries << inside.
|
71
|
+
if inside.literal?
|
72
|
+
boundaries << inside.value
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
if index < parts.length
|
77
77
|
following = parts[index+1]
|
78
|
-
if following.
|
79
|
-
boundaries << following.
|
78
|
+
if following.literal?
|
79
|
+
boundaries << following.value
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -99,11 +99,15 @@ module Rack::Mount
|
|
99
99
|
buf = nil
|
100
100
|
break
|
101
101
|
end
|
102
|
+
when Reginald::CharacterClass
|
103
|
+
break if separators.any? { |s| part.include?(s) }
|
104
|
+
buf = nil
|
105
|
+
segments << part.to_regexp
|
102
106
|
when Reginald::Character
|
103
107
|
if separators.any? { |s| part.include?(s) }
|
104
108
|
segments << join_buffer(buf, regexp) if buf
|
105
109
|
peek = parts[index+1]
|
106
|
-
if peek.is_a?(Reginald::Character) && separators.include?(peek)
|
110
|
+
if peek.is_a?(Reginald::Character) && separators.include?(peek.value)
|
107
111
|
segments << ''
|
108
112
|
end
|
109
113
|
buf = nil
|
@@ -126,10 +130,6 @@ module Rack::Mount
|
|
126
130
|
else
|
127
131
|
break
|
128
132
|
end
|
129
|
-
when Reginald::CharacterClass
|
130
|
-
break if separators.any? { |s| part.include?(s) }
|
131
|
-
buf = nil
|
132
|
-
segments << part.to_regexp
|
133
133
|
else
|
134
134
|
break
|
135
135
|
end
|
@@ -68,10 +68,12 @@ module Rack::Mount
|
|
68
68
|
when Reginald::Anchor
|
69
69
|
# ignore
|
70
70
|
when Reginald::Character
|
71
|
+
throw :halt unless part.literal?
|
72
|
+
|
71
73
|
if s.last.is_a?(String)
|
72
|
-
s.last << part.dup
|
74
|
+
s.last << part.value.dup
|
73
75
|
else
|
74
|
-
s << part.dup
|
76
|
+
s << part.value.dup
|
75
77
|
end
|
76
78
|
when Reginald::Group
|
77
79
|
if part.name
|
data/lib/rack/mount/utils.rb
CHANGED
@@ -1,55 +1,58 @@
|
|
1
1
|
module Reginald
|
2
2
|
autoload :Alternation, 'reginald/alternation'
|
3
3
|
autoload :Anchor, 'reginald/anchor'
|
4
|
+
autoload :Atom, 'reginald/atom'
|
4
5
|
autoload :Character, 'reginald/character'
|
5
6
|
autoload :CharacterClass, 'reginald/character_class'
|
6
7
|
autoload :Expression, 'reginald/expression'
|
7
8
|
autoload :Group, 'reginald/group'
|
8
9
|
autoload :Parser, 'reginald/parser'
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
class << self
|
12
|
+
begin
|
13
|
+
eval('/(?<foo>.*)/').named_captures
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
+
def regexp_supports_named_captures?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
rescue SyntaxError, NoMethodError
|
19
|
+
def regexp_supports_named_captures?
|
20
|
+
false
|
21
|
+
end
|
15
22
|
end
|
16
|
-
|
17
|
-
def
|
18
|
-
|
23
|
+
|
24
|
+
def parse(regexp)
|
25
|
+
regexp = strip_extended_whitespace_and_comments(regexp)
|
26
|
+
|
27
|
+
parser = Parser.new
|
28
|
+
parser.capture_index = 0
|
29
|
+
parser.capture_index_stack = []
|
30
|
+
expression = parser.scan_str(regexp.source)
|
31
|
+
|
32
|
+
expression.ignorecase = regexp.casefold?
|
33
|
+
|
34
|
+
expression
|
19
35
|
end
|
20
|
-
end
|
21
36
|
|
22
|
-
|
23
|
-
# TODO: The parser should be aware of extended expressions
|
24
|
-
# instead of having to sanitize them before.
|
25
|
-
if regexp.options & Regexp::EXTENDED != 0
|
26
|
-
source = regexp.source
|
27
|
-
source.gsub!(/#.+$/, '')
|
28
|
-
source.gsub!(/\s+/, '')
|
29
|
-
source.gsub!(/\\\//, '/')
|
37
|
+
def compile(source)
|
30
38
|
regexp = Regexp.compile(source)
|
39
|
+
expression = parse(regexp)
|
40
|
+
Regexp.compile(expression.to_s_without_options, expression.options)
|
31
41
|
end
|
32
42
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
tag_captures.call(atom)
|
46
|
-
elsif atom.is_a?(Expression)
|
47
|
-
tag_captures.call(atom)
|
43
|
+
private
|
44
|
+
# TODO: The parser should be aware of extended expressions
|
45
|
+
# instead of having to sanitize them before.
|
46
|
+
def strip_extended_whitespace_and_comments(regexp)
|
47
|
+
if regexp.options & Regexp::EXTENDED != 0
|
48
|
+
source = regexp.source
|
49
|
+
source.gsub!(/#.+$/, '')
|
50
|
+
source.gsub!(/\s+/, '')
|
51
|
+
source.gsub!(/\\\//, '/')
|
52
|
+
regexp = Regexp.compile(source)
|
53
|
+
else
|
54
|
+
regexp
|
48
55
|
end
|
49
56
|
end
|
50
|
-
end
|
51
|
-
tag_captures.call(expression)
|
52
|
-
|
53
|
-
expression
|
54
57
|
end
|
55
58
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Reginald
|
2
|
+
class Atom < Struct.new(:value)
|
3
|
+
def literal?
|
4
|
+
false
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
"#{value}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
"#<#{self.class.to_s.sub('Reginald::', '')} #{to_s.inspect}>"
|
13
|
+
end
|
14
|
+
|
15
|
+
def freeze
|
16
|
+
value.freeze
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,34 +1,25 @@
|
|
1
1
|
module Reginald
|
2
|
-
class Character <
|
2
|
+
class Character < Atom
|
3
3
|
attr_accessor :quantifier
|
4
4
|
|
5
|
-
def initialize(char)
|
6
|
-
raise ArgumentError if char.length != 1
|
7
|
-
super
|
8
|
-
end
|
9
|
-
|
10
5
|
def literal?
|
11
6
|
quantifier.nil?
|
12
7
|
end
|
13
8
|
|
14
9
|
def to_s
|
15
|
-
"#{
|
10
|
+
"#{value}#{quantifier}"
|
16
11
|
end
|
17
12
|
|
18
13
|
def to_regexp
|
19
14
|
Regexp.compile("\\A#{to_s}\\Z")
|
20
15
|
end
|
21
16
|
|
22
|
-
def inspect
|
23
|
-
to_s.inspect
|
24
|
-
end
|
25
|
-
|
26
17
|
def match(char)
|
27
18
|
to_regexp.match(char)
|
28
19
|
end
|
29
20
|
|
30
21
|
def include?(char)
|
31
|
-
|
22
|
+
value == char
|
32
23
|
end
|
33
24
|
|
34
25
|
def ==(other)
|
@@ -41,8 +32,9 @@ module Reginald
|
|
41
32
|
end
|
42
33
|
|
43
34
|
def eql?(other)
|
44
|
-
other.is_a?(self.class) &&
|
45
|
-
|
35
|
+
other.is_a?(self.class) &&
|
36
|
+
value.eql?(other.value) &&
|
37
|
+
quantifier.eql?(other.quantifier)
|
46
38
|
end
|
47
39
|
|
48
40
|
def freeze
|
@@ -1,6 +1,21 @@
|
|
1
1
|
module Reginald
|
2
|
-
class CharacterClass <
|
3
|
-
|
2
|
+
class CharacterClass < Character
|
3
|
+
ALNUM = new(':alnum:').freeze
|
4
|
+
ALPHA = new(':alpha:').freeze
|
5
|
+
ASCII = new(':ascii:').freeze
|
6
|
+
BLANK = new(':blank:').freeze
|
7
|
+
CNTRL = new(':cntrl:').freeze
|
8
|
+
DIGIT = new(':digit:').freeze
|
9
|
+
GRAPH = new(':graph:').freeze
|
10
|
+
LOWER = new(':lower:').freeze
|
11
|
+
PRINT = new(':print:').freeze
|
12
|
+
PUNCT = new(':punct:').freeze
|
13
|
+
SPACE = new(':space:').freeze
|
14
|
+
UPPER = new(':upper:').freeze
|
15
|
+
WORD = new(':word:').freeze
|
16
|
+
XDIGIT = new(':xdigit:').freeze
|
17
|
+
|
18
|
+
attr_accessor :negate
|
4
19
|
|
5
20
|
def negated?
|
6
21
|
negate ? true : false
|
@@ -11,50 +26,26 @@ module Reginald
|
|
11
26
|
end
|
12
27
|
|
13
28
|
def to_s
|
14
|
-
if value == '.' || value
|
15
|
-
|
29
|
+
if value == '.' || value =~ /^\\[dDsSwW]$/
|
30
|
+
super
|
16
31
|
else
|
17
32
|
"[#{negate && '^'}#{value}]#{quantifier}"
|
18
33
|
end
|
19
34
|
end
|
20
35
|
|
21
|
-
def to_regexp
|
22
|
-
Regexp.compile("\\A#{to_s}\\Z")
|
23
|
-
end
|
24
|
-
|
25
|
-
def inspect
|
26
|
-
to_s.inspect
|
27
|
-
end
|
28
|
-
|
29
|
-
def match(char)
|
30
|
-
to_regexp.match(char)
|
31
|
-
end
|
32
|
-
|
33
36
|
def include?(char)
|
34
37
|
re = quantifier ? to_s.sub(/#{Regexp.escape(quantifier)}$/, '') : to_s
|
35
38
|
Regexp.compile("\\A#{re}\\Z").match(char)
|
36
39
|
end
|
37
40
|
|
38
|
-
def ==(other)
|
39
|
-
case other
|
40
|
-
when String
|
41
|
-
other == to_s
|
42
|
-
else
|
43
|
-
eql?(other)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
41
|
def eql?(other)
|
48
42
|
other.is_a?(self.class) &&
|
49
|
-
|
50
|
-
|
51
|
-
self.quantifier == other.quantifier
|
43
|
+
negate == other.negate &&
|
44
|
+
super
|
52
45
|
end
|
53
46
|
|
54
47
|
def freeze
|
55
|
-
value.freeze
|
56
48
|
negate.freeze
|
57
|
-
quantifier.freeze
|
58
49
|
super
|
59
50
|
end
|
60
51
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Reginald
|
2
2
|
class Expression < Array
|
3
|
-
attr_accessor :ignorecase
|
3
|
+
attr_accessor :multiline, :ignorecase, :extended
|
4
4
|
|
5
5
|
def self.reduce(expression_or_atom, atom = nil)
|
6
6
|
if expression_or_atom.is_a?(Expression)
|
@@ -14,11 +14,12 @@ module Reginald
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def initialize(*args)
|
17
|
-
@ignorecase = false
|
17
|
+
@multiline = @ignorecase = @extended = false
|
18
18
|
|
19
|
-
if args.length == 1 && args.first.
|
19
|
+
if args.length == 1 && args.first.instance_of?(Array)
|
20
20
|
super(args.first)
|
21
21
|
else
|
22
|
+
args = args.map { |e| e.instance_of?(String) ? Character.new(e) : e }
|
22
23
|
super(args)
|
23
24
|
end
|
24
25
|
end
|
@@ -27,12 +28,36 @@ module Reginald
|
|
27
28
|
ignorecase == false && all? { |e| e.literal? }
|
28
29
|
end
|
29
30
|
|
30
|
-
def
|
31
|
+
def options
|
32
|
+
flag = 0
|
33
|
+
flag |= Regexp::MULTILINE if multiline
|
34
|
+
flag |= Regexp::IGNORECASE if ignorecase
|
35
|
+
flag |= Regexp::EXTENDED if extended
|
36
|
+
flag
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s_without_options
|
31
40
|
map { |e| e.to_s }.join
|
32
41
|
end
|
33
42
|
|
43
|
+
def to_s
|
44
|
+
if options == 0
|
45
|
+
to_s_without_options
|
46
|
+
else
|
47
|
+
with, without = [], []
|
48
|
+
multiline ? (with << 'm') : (without << 'm')
|
49
|
+
ignorecase ? (with << 'i') : (without << 'i')
|
50
|
+
extended ? (with << 'x') : (without << 'x')
|
51
|
+
|
52
|
+
with = with.join
|
53
|
+
without = without.any? ? "-#{without.join}" : ''
|
54
|
+
|
55
|
+
"(?#{with}#{without}:#{to_s_without_options})"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
34
59
|
def to_regexp
|
35
|
-
Regexp.compile("\\A#{
|
60
|
+
Regexp.compile("\\A#{to_s_without_options}\\Z", options)
|
36
61
|
end
|
37
62
|
|
38
63
|
def inspect
|
@@ -64,7 +89,9 @@ module Reginald
|
|
64
89
|
|
65
90
|
def eql?(other)
|
66
91
|
other.is_a?(self.class) && super &&
|
67
|
-
self.
|
92
|
+
self.multiline == other.multiline &&
|
93
|
+
self.ignorecase == other.ignorecase &&
|
94
|
+
self.extended == other.extended
|
68
95
|
end
|
69
96
|
|
70
97
|
def freeze
|
@@ -12,7 +12,13 @@ module Reginald
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_s
|
15
|
-
|
15
|
+
if expression.options == 0
|
16
|
+
"(#{capture ? '' : '?:'}#{expression.to_s_without_options})#{quantifier}"
|
17
|
+
elsif capture == false
|
18
|
+
"#{expression.to_s}#{quantifier}"
|
19
|
+
else
|
20
|
+
"(#{expression.to_s})#{quantifier}"
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
24
|
def to_regexp
|
@@ -7,124 +7,153 @@
|
|
7
7
|
require 'racc/parser.rb'
|
8
8
|
|
9
9
|
require 'reginald/tokenizer'
|
10
|
+
|
10
11
|
module Reginald
|
11
12
|
class Parser < Racc::Parser
|
13
|
+
|
14
|
+
attr_accessor :capture_index
|
15
|
+
attr_accessor :capture_index_stack
|
12
16
|
##### State transition tables begin ###
|
13
17
|
|
14
18
|
racc_action_table = [
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
nil,
|
23
|
-
nil,
|
24
|
-
22,
|
19
|
+
1, 17, 18, 18, 7, 8, 10, 11, 46, 18,
|
20
|
+
1, 43, 2, 4, 7, 8, 10, 11, 58, 45,
|
21
|
+
1, 53, 2, 4, 7, 8, 10, 11, 47, 18,
|
22
|
+
1, 61, 2, 4, 7, 8, 10, 11, 59, 18,
|
23
|
+
1, 27, 2, 4, 7, 8, 10, 11, 62, 15,
|
24
|
+
1, 34, 2, 4, 7, 8, 10, 11, 31, 25,
|
25
|
+
1, nil, 2, 4, 7, 8, 10, 11, nil, nil,
|
26
|
+
1, nil, 2, 4, 7, 8, 10, 11, 40, 41,
|
27
|
+
29, nil, 2, 4, 30, 20, 42, 35, 37, 39,
|
28
|
+
21, 22, 24, 20, 49, 35, 37, 39, 21, 22,
|
29
|
+
24, 13, nil, 14, 44, nil, 15, nil, 30, 56,
|
30
|
+
35, 37, 39, 35, 37, 39, 35, 37, 39, 35,
|
31
|
+
37, 39, 35, 37, 39, 35, 37, 39, 35, 37,
|
32
|
+
39 ]
|
25
33
|
|
26
34
|
racc_action_check = [
|
27
|
-
0,
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
nil,
|
35
|
-
nil,
|
36
|
-
|
35
|
+
0, 3, 26, 3, 0, 0, 0, 0, 34, 50,
|
36
|
+
47, 26, 0, 0, 47, 47, 47, 47, 50, 34,
|
37
|
+
41, 46, 47, 47, 41, 41, 41, 41, 36, 51,
|
38
|
+
5, 53, 41, 41, 5, 5, 5, 5, 51, 54,
|
39
|
+
32, 13, 5, 5, 32, 32, 32, 32, 54, 14,
|
40
|
+
11, 24, 32, 32, 11, 11, 11, 11, 17, 11,
|
41
|
+
18, nil, 11, 11, 18, 18, 18, 18, nil, nil,
|
42
|
+
40, nil, 18, 18, 40, 40, 40, 40, 25, 25,
|
43
|
+
16, nil, 40, 40, 16, 19, 25, 25, 25, 25,
|
44
|
+
19, 19, 19, 6, 38, 38, 38, 38, 6, 6,
|
45
|
+
6, 1, nil, 1, 28, nil, 1, nil, 28, 48,
|
46
|
+
48, 48, 48, 52, 52, 52, 56, 56, 56, 57,
|
47
|
+
57, 57, 60, 60, 60, 49, 49, 49, 42, 42,
|
48
|
+
42 ]
|
37
49
|
|
38
50
|
racc_action_pointer = [
|
39
|
-
-3,
|
40
|
-
47, nil, nil,
|
41
|
-
|
42
|
-
nil,
|
43
|
-
|
51
|
+
-3, 97, nil, 1, nil, 27, 81, nil, nil, nil,
|
52
|
+
nil, 47, nil, 36, 40, nil, 75, 58, 57, 73,
|
53
|
+
nil, nil, nil, nil, 42, 65, 0, nil, 99, nil,
|
54
|
+
nil, nil, 37, nil, -1, nil, 15, nil, 73, nil,
|
55
|
+
67, 17, 106, nil, nil, nil, 12, 7, 88, 103,
|
56
|
+
7, 27, 91, 11, 37, nil, 94, 97, nil, nil,
|
57
|
+
100, nil, nil, nil, nil, nil ]
|
44
58
|
|
45
59
|
racc_action_default = [
|
46
|
-
-
|
47
|
-
-
|
48
|
-
-
|
49
|
-
|
50
|
-
-
|
60
|
+
-35, -35, -21, -35, -22, -2, -6, -11, -12, -7,
|
61
|
+
-14, -35, -13, -35, -35, -16, -35, -35, -35, -4,
|
62
|
+
-25, -23, -24, -5, -35, -35, -35, -8, -35, -9,
|
63
|
+
-15, 66, -1, -3, -35, -32, -35, -33, -35, -34,
|
64
|
+
-35, -35, -35, -17, -10, -27, -35, -35, -35, -35,
|
65
|
+
-35, -35, -35, -35, -35, -31, -35, -35, -19, -20,
|
66
|
+
-35, -26, -18, -30, -29, -28 ]
|
51
67
|
|
52
68
|
racc_goto_table = [
|
53
|
-
|
54
|
-
26, nil, nil,
|
55
|
-
nil, nil, nil, nil,
|
56
|
-
nil, nil,
|
69
|
+
3, 38, 19, 16, 23, 36, 32, nil, nil, nil,
|
70
|
+
nil, 26, nil, nil, 48, nil, 28, 33, 52, nil,
|
71
|
+
nil, nil, nil, nil, 55, 57, nil, nil, 60, 19,
|
72
|
+
nil, nil, 63, 64, nil, nil, 65, nil, nil, nil,
|
73
|
+
50, 51, nil, nil, nil, nil, nil, 54 ]
|
57
74
|
|
58
75
|
racc_goto_check = [
|
59
|
-
1, 3, 6, 4, 2, nil, nil, nil,
|
60
|
-
1, nil, nil,
|
61
|
-
nil, nil, nil, nil,
|
62
|
-
nil, nil,
|
76
|
+
1, 9, 3, 6, 4, 8, 2, nil, nil, nil,
|
77
|
+
nil, 1, nil, nil, 9, nil, 6, 4, 9, nil,
|
78
|
+
nil, nil, nil, nil, 9, 9, nil, nil, 9, 3,
|
79
|
+
nil, nil, 9, 9, nil, nil, 9, nil, nil, nil,
|
80
|
+
1, 1, nil, nil, nil, nil, nil, 1 ]
|
63
81
|
|
64
82
|
racc_goto_pointer = [
|
65
|
-
nil, 0, -
|
83
|
+
nil, 0, -12, -3, -2, nil, 2, nil, -20, -24 ]
|
66
84
|
|
67
85
|
racc_goto_default = [
|
68
|
-
nil, nil,
|
86
|
+
nil, nil, 5, 6, nil, 9, nil, 12, nil, nil ]
|
69
87
|
|
70
88
|
racc_reduce_table = [
|
71
89
|
0, 0, :racc_error,
|
72
|
-
3,
|
73
|
-
1,
|
74
|
-
3,
|
75
|
-
2,
|
76
|
-
2,
|
77
|
-
1,
|
78
|
-
1,
|
79
|
-
3,
|
80
|
-
|
81
|
-
|
82
|
-
1,
|
83
|
-
1,
|
84
|
-
1,
|
85
|
-
|
86
|
-
2,
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
1,
|
95
|
-
1,
|
96
|
-
1,
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
90
|
+
3, 26, :_reduce_1,
|
91
|
+
1, 26, :_reduce_2,
|
92
|
+
3, 27, :_reduce_3,
|
93
|
+
2, 27, :_reduce_4,
|
94
|
+
2, 27, :_reduce_5,
|
95
|
+
1, 27, :_reduce_none,
|
96
|
+
1, 28, :_reduce_none,
|
97
|
+
3, 28, :_reduce_8,
|
98
|
+
3, 28, :_reduce_9,
|
99
|
+
4, 28, :_reduce_10,
|
100
|
+
1, 28, :_reduce_11,
|
101
|
+
1, 28, :_reduce_12,
|
102
|
+
1, 28, :_reduce_13,
|
103
|
+
1, 28, :_reduce_14,
|
104
|
+
2, 31, :_reduce_15,
|
105
|
+
1, 31, :_reduce_none,
|
106
|
+
3, 30, :_reduce_17,
|
107
|
+
6, 30, :_reduce_18,
|
108
|
+
5, 30, :_reduce_19,
|
109
|
+
5, 30, :_reduce_20,
|
110
|
+
1, 32, :_reduce_none,
|
111
|
+
1, 32, :_reduce_none,
|
112
|
+
1, 29, :_reduce_none,
|
113
|
+
1, 29, :_reduce_none,
|
114
|
+
1, 29, :_reduce_none,
|
115
|
+
5, 29, :_reduce_26,
|
116
|
+
3, 29, :_reduce_27,
|
117
|
+
4, 33, :_reduce_28,
|
118
|
+
4, 33, :_reduce_29,
|
119
|
+
4, 33, :_reduce_30,
|
120
|
+
3, 33, :_reduce_31,
|
121
|
+
1, 34, :_reduce_32,
|
122
|
+
1, 34, :_reduce_33,
|
123
|
+
1, 34, :_reduce_34 ]
|
124
|
+
|
125
|
+
racc_reduce_n = 35
|
126
|
+
|
127
|
+
racc_shift_n = 66
|
105
128
|
|
106
129
|
racc_token_table = {
|
107
130
|
false => 0,
|
108
131
|
:error => 1,
|
109
132
|
:BAR => 2,
|
110
133
|
:LBRACK => 3,
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
134
|
+
:LC_CTYPE => 4,
|
135
|
+
:RBRACK => 5,
|
136
|
+
:NEGATE => 6,
|
137
|
+
:CCLASS => 7,
|
138
|
+
:DOT => 8,
|
139
|
+
:CHAR => 9,
|
117
140
|
:LPAREN => 10,
|
118
141
|
:RPAREN => 11,
|
119
|
-
:
|
120
|
-
:
|
121
|
-
:
|
122
|
-
:
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
126
|
-
|
127
|
-
|
142
|
+
:QMARK => 12,
|
143
|
+
:COLON => 13,
|
144
|
+
:NAME => 14,
|
145
|
+
:L_ANCHOR => 15,
|
146
|
+
:R_ANCHOR => 16,
|
147
|
+
:STAR => 17,
|
148
|
+
:PLUS => 18,
|
149
|
+
:LCURLY => 19,
|
150
|
+
:RCURLY => 20,
|
151
|
+
:MINUS => 21,
|
152
|
+
:MULTILINE => 22,
|
153
|
+
:IGNORECASE => 23,
|
154
|
+
:EXTENDED => 24 }
|
155
|
+
|
156
|
+
racc_nt_base = 25
|
128
157
|
|
129
158
|
racc_use_result_var = true
|
130
159
|
|
@@ -149,21 +178,27 @@ Racc_token_to_s_table = [
|
|
149
178
|
"error",
|
150
179
|
"BAR",
|
151
180
|
"LBRACK",
|
181
|
+
"LC_CTYPE",
|
152
182
|
"RBRACK",
|
153
|
-
"
|
154
|
-
"
|
183
|
+
"NEGATE",
|
184
|
+
"CCLASS",
|
155
185
|
"DOT",
|
156
186
|
"CHAR",
|
157
|
-
"QMARK",
|
158
187
|
"LPAREN",
|
159
188
|
"RPAREN",
|
189
|
+
"QMARK",
|
160
190
|
"COLON",
|
161
191
|
"NAME",
|
192
|
+
"L_ANCHOR",
|
162
193
|
"R_ANCHOR",
|
163
194
|
"STAR",
|
164
195
|
"PLUS",
|
165
196
|
"LCURLY",
|
166
197
|
"RCURLY",
|
198
|
+
"MINUS",
|
199
|
+
"MULTILINE",
|
200
|
+
"IGNORECASE",
|
201
|
+
"EXTENDED",
|
167
202
|
"$start",
|
168
203
|
"expression",
|
169
204
|
"branch",
|
@@ -171,7 +206,9 @@ Racc_token_to_s_table = [
|
|
171
206
|
"quantifier",
|
172
207
|
"group",
|
173
208
|
"bracket_expression",
|
174
|
-
"anchor"
|
209
|
+
"anchor",
|
210
|
+
"options",
|
211
|
+
"modifier" ]
|
175
212
|
|
176
213
|
Racc_debug_parser = false
|
177
214
|
|
@@ -180,7 +217,7 @@ Racc_debug_parser = false
|
|
180
217
|
# reduce 0 omitted
|
181
218
|
|
182
219
|
def _reduce_1(val, _values, result)
|
183
|
-
result = Expression.new(
|
220
|
+
result = Expression.new(Alternation.reduce(val[0], val[2]))
|
184
221
|
result
|
185
222
|
end
|
186
223
|
|
@@ -213,37 +250,37 @@ end
|
|
213
250
|
# reduce 7 omitted
|
214
251
|
|
215
252
|
def _reduce_8(val, _values, result)
|
216
|
-
result =
|
253
|
+
result = val[1]
|
217
254
|
result
|
218
255
|
end
|
219
256
|
|
220
257
|
def _reduce_9(val, _values, result)
|
221
|
-
result = CharacterClass.new(val[
|
258
|
+
result = CharacterClass.new(val[1])
|
222
259
|
result
|
223
260
|
end
|
224
261
|
|
225
262
|
def _reduce_10(val, _values, result)
|
226
|
-
result = CharacterClass.new(val[
|
263
|
+
result = CharacterClass.new(val[2]); result.negate = true
|
227
264
|
result
|
228
265
|
end
|
229
266
|
|
230
267
|
def _reduce_11(val, _values, result)
|
231
|
-
result =
|
268
|
+
result = val[0]
|
232
269
|
result
|
233
270
|
end
|
234
271
|
|
235
272
|
def _reduce_12(val, _values, result)
|
236
|
-
result =
|
273
|
+
result = CharacterClass.new('.')
|
237
274
|
result
|
238
275
|
end
|
239
276
|
|
240
277
|
def _reduce_13(val, _values, result)
|
241
|
-
result =
|
278
|
+
result = Anchor.new(val[0])
|
242
279
|
result
|
243
280
|
end
|
244
281
|
|
245
282
|
def _reduce_14(val, _values, result)
|
246
|
-
result = val
|
283
|
+
result = Character.new(val[0])
|
247
284
|
result
|
248
285
|
end
|
249
286
|
|
@@ -252,49 +289,93 @@ def _reduce_15(val, _values, result)
|
|
252
289
|
result
|
253
290
|
end
|
254
291
|
|
255
|
-
|
256
|
-
|
292
|
+
# reduce 16 omitted
|
293
|
+
|
294
|
+
def _reduce_17(val, _values, result)
|
295
|
+
result = Group.new(val[1])
|
296
|
+
result.index = @capture_index_stack.pop
|
297
|
+
|
257
298
|
result
|
258
299
|
end
|
259
300
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
301
|
+
def _reduce_18(val, _values, result)
|
302
|
+
result = Group.new(val[4]);
|
303
|
+
result.capture = false;
|
304
|
+
options = val[2];
|
305
|
+
result.expression.multiline = options[:multiline];
|
306
|
+
result.expression.ignorecase = options[:ignorecase];
|
307
|
+
result.expression.extended = options[:extended];
|
308
|
+
|
268
309
|
result
|
269
310
|
end
|
270
311
|
|
271
|
-
def
|
272
|
-
|
312
|
+
def _reduce_19(val, _values, result)
|
313
|
+
result = Group.new(val[3]);
|
314
|
+
result.capture = false;
|
315
|
+
|
273
316
|
result
|
274
317
|
end
|
275
318
|
|
276
|
-
def
|
277
|
-
|
319
|
+
def _reduce_20(val, _values, result)
|
320
|
+
result = Group.new(val[3]);
|
321
|
+
result.name = val[2];
|
322
|
+
result.index = @capture_index_stack.pop
|
323
|
+
|
278
324
|
result
|
279
325
|
end
|
280
326
|
|
327
|
+
# reduce 21 omitted
|
328
|
+
|
329
|
+
# reduce 22 omitted
|
330
|
+
|
281
331
|
# reduce 23 omitted
|
282
332
|
|
283
333
|
# reduce 24 omitted
|
284
334
|
|
285
335
|
# reduce 25 omitted
|
286
336
|
|
287
|
-
|
337
|
+
def _reduce_26(val, _values, result)
|
338
|
+
result = val.join
|
339
|
+
result
|
340
|
+
end
|
288
341
|
|
289
|
-
|
342
|
+
def _reduce_27(val, _values, result)
|
343
|
+
result = val.join
|
344
|
+
result
|
345
|
+
end
|
290
346
|
|
291
347
|
def _reduce_28(val, _values, result)
|
292
|
-
result = val
|
348
|
+
result = { val[1] => false, val[2] => false, val[3] => false }
|
293
349
|
result
|
294
350
|
end
|
295
351
|
|
296
352
|
def _reduce_29(val, _values, result)
|
297
|
-
result = val
|
353
|
+
result = { val[0] => true, val[2] => false, val[3] => false }
|
354
|
+
result
|
355
|
+
end
|
356
|
+
|
357
|
+
def _reduce_30(val, _values, result)
|
358
|
+
result = { val[0] => true, val[1] => true, val[3] => false }
|
359
|
+
result
|
360
|
+
end
|
361
|
+
|
362
|
+
def _reduce_31(val, _values, result)
|
363
|
+
result = { val[0] => true, val[1] => true, val[2] => true }
|
364
|
+
result
|
365
|
+
end
|
366
|
+
|
367
|
+
def _reduce_32(val, _values, result)
|
368
|
+
result = :multiline
|
369
|
+
result
|
370
|
+
end
|
371
|
+
|
372
|
+
def _reduce_33(val, _values, result)
|
373
|
+
result = :ignorecase
|
374
|
+
result
|
375
|
+
end
|
376
|
+
|
377
|
+
def _reduce_34(val, _values, result)
|
378
|
+
result = :extended
|
298
379
|
result
|
299
380
|
end
|
300
381
|
|
@@ -51,23 +51,23 @@ class Parser < Racc::Parser
|
|
51
51
|
token = case @state
|
52
52
|
when nil
|
53
53
|
case
|
54
|
-
when (text = @ss.scan(/\\
|
55
|
-
action { [:
|
54
|
+
when (text = @ss.scan(/\\d/))
|
55
|
+
action { [:CCLASS, CharacterClass.new('\d')] }
|
56
|
+
|
57
|
+
when (text = @ss.scan(/\\D/))
|
58
|
+
action { [:CCLASS, CharacterClass.new('\D')] }
|
56
59
|
|
57
60
|
when (text = @ss.scan(/\\s/))
|
58
|
-
action { [:
|
61
|
+
action { [:CCLASS, CharacterClass.new('\s')] }
|
59
62
|
|
60
63
|
when (text = @ss.scan(/\\S/))
|
61
|
-
action { [:
|
62
|
-
|
63
|
-
when (text = @ss.scan(/\\d/))
|
64
|
-
action { [:CHAR_CLASS, text] }
|
64
|
+
action { [:CCLASS, CharacterClass.new('\S')] }
|
65
65
|
|
66
66
|
when (text = @ss.scan(/\\w/))
|
67
|
-
action { [:
|
67
|
+
action { [:CCLASS, CharacterClass.new('\w')] }
|
68
68
|
|
69
69
|
when (text = @ss.scan(/\\W/))
|
70
|
-
action { [:
|
70
|
+
action { [:CCLASS, CharacterClass.new('\W')] }
|
71
71
|
|
72
72
|
when (text = @ss.scan(/\^/))
|
73
73
|
action { [:L_ANCHOR, text] }
|
@@ -85,16 +85,19 @@ class Parser < Racc::Parser
|
|
85
85
|
action { [:NAME, @ss[1]] }
|
86
86
|
|
87
87
|
when (text = @ss.scan(/\(/))
|
88
|
-
action {
|
88
|
+
action {
|
89
|
+
@capture_index_stack << @capture_index
|
90
|
+
@capture_index += 1
|
91
|
+
@state = :OPTIONS if @ss.peek(1) == '?';
|
92
|
+
[:LPAREN, text]
|
93
|
+
}
|
94
|
+
|
89
95
|
|
90
96
|
when (text = @ss.scan(/\)/))
|
91
97
|
action { [:RPAREN, text] }
|
92
98
|
|
93
99
|
when (text = @ss.scan(/\[/))
|
94
|
-
action { [:LBRACK, text] }
|
95
|
-
|
96
|
-
when (text = @ss.scan(/\]/))
|
97
|
-
action { [:RBRACK, text] }
|
100
|
+
action { @state = :CCLASS; [:LBRACK, text] }
|
98
101
|
|
99
102
|
when (text = @ss.scan(/\{/))
|
100
103
|
action { [:LCURLY, text] }
|
@@ -117,9 +120,6 @@ class Parser < Racc::Parser
|
|
117
120
|
when (text = @ss.scan(/\*/))
|
118
121
|
action { [:STAR, text] }
|
119
122
|
|
120
|
-
when (text = @ss.scan(/\:/))
|
121
|
-
action { [:COLON, text] }
|
122
|
-
|
123
123
|
when (text = @ss.scan(/\\(.)/))
|
124
124
|
action { [:CHAR, @ss[1]] }
|
125
125
|
|
@@ -131,6 +131,102 @@ class Parser < Racc::Parser
|
|
131
131
|
raise ScanError, "can not match: '" + text + "'"
|
132
132
|
end # if
|
133
133
|
|
134
|
+
when :CCLASS
|
135
|
+
case
|
136
|
+
when (text = @ss.scan(/\]/))
|
137
|
+
action { @state = nil; [:RBRACK, text] }
|
138
|
+
|
139
|
+
when (text = @ss.scan(/\^/))
|
140
|
+
action { [:NEGATE, text] }
|
141
|
+
|
142
|
+
when (text = @ss.scan(/:alnum:/))
|
143
|
+
action { [:LC_CTYPE, CharacterClass::ALNUM] }
|
144
|
+
|
145
|
+
when (text = @ss.scan(/:alpha:/))
|
146
|
+
action { [:LC_CTYPE, CharacterClass::ALPHA] }
|
147
|
+
|
148
|
+
when (text = @ss.scan(/:ascii:/))
|
149
|
+
action { [:LC_CTYPE, CharacterClass::ASCII] }
|
150
|
+
|
151
|
+
when (text = @ss.scan(/:blank:/))
|
152
|
+
action { [:LC_CTYPE, CharacterClass::BLANK] }
|
153
|
+
|
154
|
+
when (text = @ss.scan(/:cntrl:/))
|
155
|
+
action { [:LC_CTYPE, CharacterClass::CNTRL] }
|
156
|
+
|
157
|
+
when (text = @ss.scan(/:digit:/))
|
158
|
+
action { [:LC_CTYPE, CharacterClass::DIGIT] }
|
159
|
+
|
160
|
+
when (text = @ss.scan(/:graph:/))
|
161
|
+
action { [:LC_CTYPE, CharacterClass::GRAPH] }
|
162
|
+
|
163
|
+
when (text = @ss.scan(/:lower:/))
|
164
|
+
action { [:LC_CTYPE, CharacterClass::LOWER] }
|
165
|
+
|
166
|
+
when (text = @ss.scan(/:print:/))
|
167
|
+
action { [:LC_CTYPE, CharacterClass::PRINT] }
|
168
|
+
|
169
|
+
when (text = @ss.scan(/:punct:/))
|
170
|
+
action { [:LC_CTYPE, CharacterClass::PUNCT] }
|
171
|
+
|
172
|
+
when (text = @ss.scan(/:space:/))
|
173
|
+
action { [:LC_CTYPE, CharacterClass::SPACE] }
|
174
|
+
|
175
|
+
when (text = @ss.scan(/:upper:/))
|
176
|
+
action { [:LC_CTYPE, CharacterClass::UPPER] }
|
177
|
+
|
178
|
+
when (text = @ss.scan(/:word;/))
|
179
|
+
action { [:LC_CTYPE, CharacterClass::WORD] }
|
180
|
+
|
181
|
+
when (text = @ss.scan(/:xdigit:/))
|
182
|
+
action { [:LC_CTYPE, CharacterClass::XDIGIT] }
|
183
|
+
|
184
|
+
when (text = @ss.scan(/\\(.)/))
|
185
|
+
action { [:CHAR, @ss[1]] }
|
186
|
+
|
187
|
+
when (text = @ss.scan(/./))
|
188
|
+
action { [:CHAR, text] }
|
189
|
+
|
190
|
+
else
|
191
|
+
text = @ss.string[@ss.pos .. -1]
|
192
|
+
raise ScanError, "can not match: '" + text + "'"
|
193
|
+
end # if
|
194
|
+
|
195
|
+
when :OPTIONS
|
196
|
+
case
|
197
|
+
when (text = @ss.scan(/\?/))
|
198
|
+
action {
|
199
|
+
@state = nil unless @ss.peek(1) =~ /-|m|i|x|:/
|
200
|
+
[:QMARK, text]
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
when (text = @ss.scan(/\-/))
|
205
|
+
action { [:MINUS, text] }
|
206
|
+
|
207
|
+
when (text = @ss.scan(/m/))
|
208
|
+
action { [:MULTILINE, text] }
|
209
|
+
|
210
|
+
when (text = @ss.scan(/i/))
|
211
|
+
action { [:IGNORECASE, text] }
|
212
|
+
|
213
|
+
when (text = @ss.scan(/x/))
|
214
|
+
action { [:EXTENDED, text] }
|
215
|
+
|
216
|
+
when (text = @ss.scan(/\:/))
|
217
|
+
action {
|
218
|
+
@capture_index_stack.pop
|
219
|
+
@capture_index -= 1
|
220
|
+
@state = nil;
|
221
|
+
[:COLON, text]
|
222
|
+
}
|
223
|
+
|
224
|
+
|
225
|
+
else
|
226
|
+
text = @ss.string[@ss.pos .. -1]
|
227
|
+
raise ScanError, "can not match: '" + text + "'"
|
228
|
+
end # if
|
229
|
+
|
134
230
|
else
|
135
231
|
raise ScanError, "undefined state: '" + state.to_s + "'"
|
136
232
|
end # case state
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-mount
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-22 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- lib/rack/mount/vendor/multimap/nested_multimap.rb
|
58
58
|
- lib/rack/mount/vendor/reginald/reginald/alternation.rb
|
59
59
|
- lib/rack/mount/vendor/reginald/reginald/anchor.rb
|
60
|
+
- lib/rack/mount/vendor/reginald/reginald/atom.rb
|
60
61
|
- lib/rack/mount/vendor/reginald/reginald/character.rb
|
61
62
|
- lib/rack/mount/vendor/reginald/reginald/character_class.rb
|
62
63
|
- lib/rack/mount/vendor/reginald/reginald/expression.rb
|