rack-mount 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/mount/analysis/frequency.rb +8 -2
- data/lib/rack/mount/analysis/splitting.rb +3 -4
- data/lib/rack/mount/regexp_with_named_groups.rb +3 -13
- data/lib/rack/mount/strexp/parser.rb +13 -13
- data/lib/rack/mount/utils.rb +1 -1
- data/lib/rack/mount/vendor/reginald/reginald/alternation.rb +5 -18
- data/lib/rack/mount/vendor/reginald/reginald/atom.rb +27 -1
- data/lib/rack/mount/vendor/reginald/reginald/character.rb +12 -15
- data/lib/rack/mount/vendor/reginald/reginald/character_class.rb +19 -7
- data/lib/rack/mount/vendor/reginald/reginald/collection.rb +40 -0
- data/lib/rack/mount/vendor/reginald/reginald/expression.rb +27 -42
- data/lib/rack/mount/vendor/reginald/reginald/group.rb +6 -2
- data/lib/rack/mount/vendor/reginald/reginald/parser.rb +297 -144
- data/lib/rack/mount/vendor/reginald/reginald/tokenizer.rb +39 -59
- data/lib/rack/mount/vendor/reginald/reginald.rb +3 -26
- metadata +3 -2
@@ -35,8 +35,8 @@ module Rack::Mount
|
|
35
35
|
|
36
36
|
def process_key(requirements, method, requirement)
|
37
37
|
if requirement.is_a?(Regexp)
|
38
|
-
expression =
|
39
|
-
expression.reject
|
38
|
+
expression = parse_regexp(requirement)
|
39
|
+
expression = expression.reject { |e| e.is_a?(Reginald::Anchor) }
|
40
40
|
|
41
41
|
if expression.is_a?(Reginald::Expression) && expression.literal?
|
42
42
|
return requirements[method] = expression.to_s
|
@@ -53,6 +53,12 @@ module Rack::Mount
|
|
53
53
|
@key_frequency.select_upper
|
54
54
|
end
|
55
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def parse_regexp(regexp)
|
59
|
+
@parse_regexp_cache ||= {}
|
60
|
+
@parse_regexp_cache[regexp] ||= Utils.parse_regexp(regexp).freeze
|
61
|
+
end
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
@@ -57,7 +57,7 @@ module Rack::Mount
|
|
57
57
|
def analyze_capture_boundaries(regexp, boundaries) #:nodoc:
|
58
58
|
return boundaries unless regexp.is_a?(Regexp)
|
59
59
|
|
60
|
-
parts =
|
60
|
+
parts = parse_regexp(regexp)
|
61
61
|
parts.each_with_index do |part, index|
|
62
62
|
if part.is_a?(Reginald::Group)
|
63
63
|
if index > 0
|
@@ -88,8 +88,7 @@ module Rack::Mount
|
|
88
88
|
def generate_split_keys(regexp, separators) #:nodoc:
|
89
89
|
segments = []
|
90
90
|
buf = nil
|
91
|
-
|
92
|
-
parts = Utils.parse_regexp(regexp)
|
91
|
+
parts = parse_regexp(regexp)
|
93
92
|
parts.each_with_index do |part, index|
|
94
93
|
case part
|
95
94
|
when Reginald::Anchor
|
@@ -151,7 +150,7 @@ module Rack::Mount
|
|
151
150
|
end
|
152
151
|
|
153
152
|
def join_buffer(parts, regexp)
|
154
|
-
if parts.literal?
|
153
|
+
if parts.literal?
|
155
154
|
parts.to_s
|
156
155
|
else
|
157
156
|
parts.to_regexp
|
@@ -1,13 +1,7 @@
|
|
1
1
|
module Rack::Mount
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
class RegexpWithNamedGroups < Regexp
|
6
|
-
def self.supports_named_captures?
|
7
|
-
true
|
8
|
-
end
|
9
|
-
end
|
10
|
-
rescue SyntaxError, NoMethodError
|
2
|
+
if Reginald.regexp_supports_named_captures?
|
3
|
+
RegexpWithNamedGroups = Regexp
|
4
|
+
else
|
11
5
|
require 'strscan'
|
12
6
|
|
13
7
|
# A wrapper that adds shim named capture support to older
|
@@ -24,10 +18,6 @@ module Rack::Mount
|
|
24
18
|
#
|
25
19
|
# /(?:<foo>[a-z]+)/
|
26
20
|
class RegexpWithNamedGroups < Regexp
|
27
|
-
def self.supports_named_captures?
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
21
|
def self.new(regexp) #:nodoc:
|
32
22
|
if regexp.is_a?(RegexpWithNamedGroups)
|
33
23
|
regexp
|
@@ -13,7 +13,7 @@ module Rack
|
|
13
13
|
class StrexpParser < Racc::Parser
|
14
14
|
|
15
15
|
|
16
|
-
if
|
16
|
+
if Reginald.regexp_supports_named_captures?
|
17
17
|
REGEXP_NAMED_CAPTURE = '(?<%s>%s)'.freeze
|
18
18
|
else
|
19
19
|
REGEXP_NAMED_CAPTURE = '(?:<%s>%s)'.freeze
|
@@ -23,32 +23,32 @@ attr_accessor :requirements
|
|
23
23
|
##### State transition tables begin ###
|
24
24
|
|
25
25
|
racc_action_table = [
|
26
|
-
|
27
|
-
|
26
|
+
1, 2, 3, 9, 4, 1, 2, 3, 12, 4,
|
27
|
+
1, 2, 3, 11, 4, 1, 2, 3, nil, 4 ]
|
28
28
|
|
29
29
|
racc_action_check = [
|
30
|
-
0, 0, 0,
|
31
|
-
|
30
|
+
0, 0, 0, 5, 0, 3, 3, 3, 9, 3,
|
31
|
+
8, 8, 8, 8, 8, 6, 6, 6, nil, 6 ]
|
32
32
|
|
33
33
|
racc_action_pointer = [
|
34
|
-
-2,
|
35
|
-
|
34
|
+
-2, nil, nil, 3, nil, 3, 13, nil, 8, 8,
|
35
|
+
nil, nil, nil ]
|
36
36
|
|
37
37
|
racc_action_default = [
|
38
|
-
-8, -
|
39
|
-
-
|
38
|
+
-8, -4, -5, -8, -7, -8, -1, -3, -8, -8,
|
39
|
+
-2, -6, 13 ]
|
40
40
|
|
41
41
|
racc_goto_table = [
|
42
|
-
|
42
|
+
6, 5, 10, 8, 10 ]
|
43
43
|
|
44
44
|
racc_goto_check = [
|
45
|
-
|
45
|
+
2, 1, 3, 2, 3 ]
|
46
46
|
|
47
47
|
racc_goto_pointer = [
|
48
|
-
nil,
|
48
|
+
nil, 1, 0, -4 ]
|
49
49
|
|
50
50
|
racc_goto_default = [
|
51
|
-
nil, nil, nil,
|
51
|
+
nil, nil, nil, 7 ]
|
52
52
|
|
53
53
|
racc_reduce_table = [
|
54
54
|
0, 0, :racc_error,
|
data/lib/rack/mount/utils.rb
CHANGED
@@ -105,7 +105,7 @@ module Rack::Mount
|
|
105
105
|
|
106
106
|
expression = Reginald.parse(regexp)
|
107
107
|
|
108
|
-
unless
|
108
|
+
unless Reginald.regexp_supports_named_captures?
|
109
109
|
tag_captures = Proc.new do |group|
|
110
110
|
group.each do |child|
|
111
111
|
if child.is_a?(Reginald::Group)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Reginald
|
2
|
-
class Alternation <
|
2
|
+
class Alternation < Collection
|
3
3
|
def self.reduce(alternation_or_expression, expression)
|
4
4
|
if alternation_or_expression.first.is_a?(Alternation)
|
5
5
|
alternation_or_expression = alternation_or_expression.first
|
@@ -22,29 +22,16 @@ module Reginald
|
|
22
22
|
false
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
25
|
+
def options
|
26
|
+
0
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
29
|
+
def to_s(parent = false)
|
30
|
+
map { |e| e.to_s(parent) }.join('|')
|
31
31
|
end
|
32
32
|
|
33
33
|
def inspect
|
34
34
|
to_s.inspect
|
35
35
|
end
|
36
|
-
|
37
|
-
def match(char)
|
38
|
-
to_regexp.match(char)
|
39
|
-
end
|
40
|
-
|
41
|
-
def include?(char)
|
42
|
-
any? { |e| e.include?(char) }
|
43
|
-
end
|
44
|
-
|
45
|
-
def freeze
|
46
|
-
each { |e| e.freeze }
|
47
|
-
super
|
48
|
-
end
|
49
36
|
end
|
50
37
|
end
|
@@ -1,10 +1,21 @@
|
|
1
1
|
module Reginald
|
2
2
|
class Atom < Struct.new(:value)
|
3
|
+
attr_accessor :ignorecase
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
@ignorecase = nil
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
3
10
|
def literal?
|
4
11
|
false
|
5
12
|
end
|
6
13
|
|
7
|
-
def
|
14
|
+
def casefold?
|
15
|
+
ignorecase ? true : false
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s(parent = false)
|
8
19
|
"#{value}"
|
9
20
|
end
|
10
21
|
|
@@ -12,6 +23,21 @@ module Reginald
|
|
12
23
|
"#<#{self.class.to_s.sub('Reginald::', '')} #{to_s.inspect}>"
|
13
24
|
end
|
14
25
|
|
26
|
+
def ==(other)
|
27
|
+
case other
|
28
|
+
when String
|
29
|
+
other == to_s
|
30
|
+
else
|
31
|
+
eql?(other)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def eql?(other)
|
36
|
+
other.instance_of?(self.class) &&
|
37
|
+
self.value.eql?(other.value) &&
|
38
|
+
(!!self.ignorecase).eql?(!!other.ignorecase)
|
39
|
+
end
|
40
|
+
|
15
41
|
def freeze
|
16
42
|
value.freeze
|
17
43
|
super
|
@@ -3,15 +3,19 @@ module Reginald
|
|
3
3
|
attr_accessor :quantifier
|
4
4
|
|
5
5
|
def literal?
|
6
|
-
quantifier.nil?
|
6
|
+
quantifier.nil? && !ignorecase
|
7
7
|
end
|
8
8
|
|
9
|
-
def to_s
|
10
|
-
|
9
|
+
def to_s(parent = false)
|
10
|
+
if !parent && ignorecase
|
11
|
+
"(?i-mx:#{value})#{quantifier}"
|
12
|
+
else
|
13
|
+
"#{value}#{quantifier}"
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
def to_regexp
|
14
|
-
Regexp.compile("\\A#{to_s}\\Z")
|
18
|
+
Regexp.compile("\\A#{to_s(true)}\\Z", ignorecase)
|
15
19
|
end
|
16
20
|
|
17
21
|
def match(char)
|
@@ -19,22 +23,15 @@ module Reginald
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def include?(char)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def ==(other)
|
26
|
-
case other
|
27
|
-
when String
|
28
|
-
other == to_s
|
26
|
+
if ignorecase
|
27
|
+
value.downcase == char.downcase
|
29
28
|
else
|
30
|
-
|
29
|
+
value == char
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
33
|
def eql?(other)
|
35
|
-
|
36
|
-
value.eql?(other.value) &&
|
37
|
-
quantifier.eql?(other.quantifier)
|
34
|
+
super && quantifier.eql?(other.quantifier)
|
38
35
|
end
|
39
36
|
|
40
37
|
def freeze
|
@@ -15,6 +15,12 @@ module Reginald
|
|
15
15
|
WORD = new(':word:').freeze
|
16
16
|
XDIGIT = new(':xdigit:').freeze
|
17
17
|
|
18
|
+
def ignorecase=(ignorecase)
|
19
|
+
if to_s !~ /\A\[:.*:\]\Z/
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
18
24
|
attr_accessor :negate
|
19
25
|
|
20
26
|
def negated?
|
@@ -25,11 +31,19 @@ module Reginald
|
|
25
31
|
false
|
26
32
|
end
|
27
33
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
34
|
+
def bracketed?
|
35
|
+
value != '.' && value !~ /^\\[dDsSwW]$/
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s(parent = false)
|
39
|
+
if bracketed?
|
40
|
+
if !parent && ignorecase
|
41
|
+
"(?i-mx:[#{negate && '^'}#{value}])#{quantifier}"
|
42
|
+
else
|
43
|
+
"[#{negate && '^'}#{value}]#{quantifier}"
|
44
|
+
end
|
31
45
|
else
|
32
|
-
|
46
|
+
super
|
33
47
|
end
|
34
48
|
end
|
35
49
|
|
@@ -39,9 +53,7 @@ module Reginald
|
|
39
53
|
end
|
40
54
|
|
41
55
|
def eql?(other)
|
42
|
-
other.
|
43
|
-
negate == other.negate &&
|
44
|
-
super
|
56
|
+
super && negate == other.negate
|
45
57
|
end
|
46
58
|
|
47
59
|
def freeze
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Reginald
|
2
|
+
class Collection < Array
|
3
|
+
def ignorecase=(ignorecase)
|
4
|
+
each { |e| e.ignorecase = ignorecase }
|
5
|
+
ignorecase
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_regexp
|
9
|
+
Regexp.compile("\\A#{to_s(true)}\\Z", options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def match(char)
|
13
|
+
to_regexp.match(char)
|
14
|
+
end
|
15
|
+
|
16
|
+
def include?(char)
|
17
|
+
any? { |e| e.include?(char) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def ==(other)
|
21
|
+
case other
|
22
|
+
when String
|
23
|
+
other == to_s
|
24
|
+
when Array
|
25
|
+
super
|
26
|
+
else
|
27
|
+
eql?(other)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def eql?(other)
|
32
|
+
other.instance_of?(self.class) && super
|
33
|
+
end
|
34
|
+
|
35
|
+
def freeze
|
36
|
+
each { |e| e.freeze }
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Reginald
|
2
|
-
class Expression <
|
3
|
-
|
2
|
+
class Expression < Collection
|
3
|
+
attr_reader :ignorecase
|
4
|
+
attr_accessor :multiline, :extended
|
4
5
|
|
5
6
|
def self.reduce(expression_or_atom, atom = nil)
|
6
7
|
if expression_or_atom.is_a?(Expression)
|
@@ -14,7 +15,7 @@ module Reginald
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def initialize(*args)
|
17
|
-
@multiline = @ignorecase = @extended =
|
18
|
+
@multiline = @ignorecase = @extended = nil
|
18
19
|
|
19
20
|
if args.length == 1 && args.first.instance_of?(Array)
|
20
21
|
super(args.first)
|
@@ -24,8 +25,17 @@ module Reginald
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
def ignorecase=(ignorecase)
|
29
|
+
if @ignorecase.nil?
|
30
|
+
super
|
31
|
+
@ignorecase = ignorecase
|
32
|
+
else
|
33
|
+
false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
27
37
|
def literal?
|
28
|
-
ignorecase
|
38
|
+
!ignorecase && all? { |e| e.literal? }
|
29
39
|
end
|
30
40
|
|
31
41
|
def options
|
@@ -36,13 +46,16 @@ module Reginald
|
|
36
46
|
flag
|
37
47
|
end
|
38
48
|
|
39
|
-
def
|
40
|
-
|
49
|
+
def options=(flag)
|
50
|
+
self.multiline = flag & Regexp::MULTILINE != 0
|
51
|
+
self.ignorecase = flag & Regexp::IGNORECASE != 0
|
52
|
+
self.extended = flag & Regexp::EXTENDED != 0
|
53
|
+
nil
|
41
54
|
end
|
42
55
|
|
43
|
-
def to_s
|
44
|
-
if options == 0
|
45
|
-
|
56
|
+
def to_s(parent = false)
|
57
|
+
if parent || options == 0
|
58
|
+
map { |e| e.to_s(parent) }.join
|
46
59
|
else
|
47
60
|
with, without = [], []
|
48
61
|
multiline ? (with << 'm') : (without << 'm')
|
@@ -52,51 +65,23 @@ module Reginald
|
|
52
65
|
with = with.join
|
53
66
|
without = without.any? ? "-#{without.join}" : ''
|
54
67
|
|
55
|
-
"(?#{with}#{without}:#{
|
68
|
+
"(?#{with}#{without}:#{map { |e| e.to_s(true) }.join})"
|
56
69
|
end
|
57
70
|
end
|
58
71
|
|
59
|
-
def to_regexp
|
60
|
-
Regexp.compile("\\A#{to_s_without_options}\\Z", options)
|
61
|
-
end
|
62
|
-
|
63
72
|
def inspect
|
64
73
|
"#<Expression #{to_s.inspect}>"
|
65
74
|
end
|
66
75
|
|
67
|
-
def match(char)
|
68
|
-
to_regexp.match(char)
|
69
|
-
end
|
70
|
-
|
71
|
-
def include?(char)
|
72
|
-
any? { |e| e.include?(char) }
|
73
|
-
end
|
74
|
-
|
75
76
|
def casefold?
|
76
77
|
ignorecase
|
77
78
|
end
|
78
79
|
|
79
|
-
def ==(other)
|
80
|
-
case other
|
81
|
-
when String
|
82
|
-
other == to_s
|
83
|
-
when Array
|
84
|
-
super
|
85
|
-
else
|
86
|
-
eql?(other)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
80
|
def eql?(other)
|
91
|
-
|
92
|
-
self.multiline == other.multiline &&
|
93
|
-
self.ignorecase == other.ignorecase &&
|
94
|
-
self.extended == other.extended
|
95
|
-
end
|
96
|
-
|
97
|
-
def freeze
|
98
|
-
each { |e| e.freeze }
|
99
|
-
super
|
81
|
+
super &&
|
82
|
+
!!self.multiline == !!other.multiline &&
|
83
|
+
!!self.ignorecase == !!other.ignorecase &&
|
84
|
+
!!self.extended == !!other.extended
|
100
85
|
end
|
101
86
|
end
|
102
87
|
end
|
@@ -7,13 +7,17 @@ module Reginald
|
|
7
7
|
super
|
8
8
|
end
|
9
9
|
|
10
|
+
def ignorecase=(ignorecase)
|
11
|
+
expression.ignorecase = ignorecase
|
12
|
+
end
|
13
|
+
|
10
14
|
def literal?
|
11
15
|
quantifier.nil? && expression.literal?
|
12
16
|
end
|
13
17
|
|
14
|
-
def to_s
|
18
|
+
def to_s(parent = false)
|
15
19
|
if expression.options == 0
|
16
|
-
"(#{capture ? '' : '?:'}#{expression.
|
20
|
+
"(#{capture ? '' : '?:'}#{expression.to_s(parent)})#{quantifier}"
|
17
21
|
elsif capture == false
|
18
22
|
"#{expression.to_s}#{quantifier}"
|
19
23
|
else
|
@@ -8,150 +8,207 @@ require 'racc/parser.rb'
|
|
8
8
|
module Reginald
|
9
9
|
class Parser < Racc::Parser
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
def self.parse_regexp(regexp)
|
12
|
+
parser = new
|
13
|
+
parser.options_stack << {
|
14
|
+
:multiline => (regexp.options & Regexp::MULTILINE != 0),
|
15
|
+
:ignorecase => (regexp.options & Regexp::IGNORECASE != 0),
|
16
|
+
:extended => (regexp.options & Regexp::EXTENDED != 0)
|
17
|
+
}
|
18
|
+
|
19
|
+
expression = parser.scan_str(regexp.source)
|
20
|
+
expression.options = regexp.options
|
21
|
+
expression
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_accessor :options_stack
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@capture_index = 0
|
28
|
+
@capture_index_stack = []
|
29
|
+
@options_stack = []
|
30
|
+
end
|
13
31
|
|
14
32
|
##### State transition tables begin ###
|
15
33
|
|
16
34
|
racc_action_table = [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
35
|
+
22, 62, 32, 26, 66, 32, 32, 52, 54, 31,
|
36
|
+
71, 32, 61, 72, 59, 28, 30, 14, 16, 18,
|
37
|
+
19, 20, 21, 23, 24, 25, 27, 29, 13, 51,
|
38
|
+
53, 55, 57, 3, 32, 77, 5, 7, 9, 11,
|
39
|
+
41, 39, 79, 3, 2, 4, 5, 7, 9, 11,
|
40
|
+
53, 55, 57, 3, 2, 4, 5, 7, 9, 11,
|
41
|
+
53, 55, 57, 3, 2, 4, 5, 7, 9, 11,
|
42
|
+
53, 55, 57, 3, 2, 4, 5, 7, 9, 11,
|
43
|
+
53, 55, 57, 3, 2, 4, 5, 7, 9, 11,
|
44
|
+
53, 55, 57, 3, 2, 4, 5, 7, 9, 11,
|
45
|
+
53, 55, 57, 3, 2, 4, 5, 7, 9, 11,
|
46
|
+
46, 34, 47, 26, 2, 4, 35, 36, 37, 34,
|
47
|
+
67, 53, 55, 57, 35, 36, 37, 42, 43, 60,
|
48
|
+
43, 44, 50, 44, 75, 53, 55, 57, 69 ]
|
31
49
|
|
32
50
|
racc_action_check = [
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
51
|
+
3, 50, 64, 3, 56, 65, 40, 39, 39, 6,
|
52
|
+
64, 6, 50, 65, 40, 3, 3, 3, 3, 3,
|
53
|
+
3, 3, 3, 3, 3, 3, 3, 3, 3, 39,
|
54
|
+
39, 39, 39, 11, 73, 69, 11, 11, 11, 11,
|
55
|
+
15, 11, 73, 8, 11, 11, 8, 8, 8, 8,
|
56
|
+
70, 70, 70, 54, 8, 8, 54, 54, 54, 54,
|
57
|
+
67, 67, 67, 66, 54, 54, 66, 66, 66, 66,
|
58
|
+
63, 63, 63, 52, 66, 66, 52, 52, 52, 52,
|
59
|
+
51, 51, 51, 32, 52, 52, 32, 32, 32, 32,
|
60
|
+
74, 74, 74, 48, 32, 32, 48, 48, 48, 48,
|
61
|
+
75, 75, 75, 0, 48, 48, 0, 0, 0, 0,
|
62
|
+
22, 10, 31, 22, 0, 0, 10, 10, 10, 33,
|
63
|
+
58, 58, 58, 58, 33, 33, 33, 17, 17, 45,
|
64
|
+
45, 17, 37, 45, 68, 68, 68, 68, 62 ]
|
47
65
|
|
48
66
|
racc_action_pointer = [
|
49
|
-
|
50
|
-
|
51
|
-
nil, nil, nil, nil,
|
52
|
-
nil,
|
53
|
-
|
54
|
-
|
55
|
-
|
67
|
+
100, nil, nil, -5, nil, nil, 9, nil, 40, nil,
|
68
|
+
100, 30, nil, nil, nil, 36, nil, 123, nil, nil,
|
69
|
+
nil, nil, 105, nil, nil, nil, nil, nil, nil, nil,
|
70
|
+
nil, 112, 80, 108, nil, nil, nil, 124, nil, -5,
|
71
|
+
4, nil, nil, nil, nil, 125, nil, nil, 90, nil,
|
72
|
+
-7, 45, 70, nil, 50, nil, -8, nil, 86, nil,
|
73
|
+
nil, nil, 130, 35, 0, 3, 60, 25, 100, 16,
|
74
|
+
15, nil, nil, 32, 55, 65, nil, nil, nil, nil,
|
75
|
+
nil, nil ]
|
56
76
|
|
57
77
|
racc_action_default = [
|
58
|
-
-
|
59
|
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
-
|
78
|
+
-51, -13, -19, -51, -20, -11, -51, -12, -2, -14,
|
79
|
+
-6, -51, -7, -43, -32, -51, -33, -51, -34, -35,
|
80
|
+
-36, -37, -29, -38, -39, -40, -28, -41, -30, -42,
|
81
|
+
-31, -51, -51, -4, -23, -21, -22, -51, -5, -51,
|
82
|
+
-51, -8, -9, -27, -26, -51, -29, 82, -1, -3,
|
83
|
+
-51, -51, -51, -48, -51, -49, -51, -50, -51, -15,
|
84
|
+
-10, -25, -51, -51, -51, -51, -51, -51, -51, -51,
|
85
|
+
-51, -17, -18, -51, -51, -51, -47, -24, -44, -16,
|
86
|
+
-45, -46 ]
|
65
87
|
|
66
88
|
racc_goto_table = [
|
67
|
-
|
68
|
-
nil,
|
69
|
-
nil, nil, nil, nil,
|
70
|
-
|
71
|
-
|
89
|
+
6, 33, 58, 17, 38, 48, 56, 15, nil, nil,
|
90
|
+
nil, 40, nil, nil, 63, nil, nil, nil, nil, nil,
|
91
|
+
nil, 68, 45, nil, nil, nil, 70, 49, nil, nil,
|
92
|
+
74, 76, nil, 78, nil, nil, nil, 80, 81, nil,
|
93
|
+
nil, 33, nil, nil, nil, nil, nil, nil, nil, nil,
|
94
|
+
nil, nil, 64, nil, 65, nil, nil, nil, nil, nil,
|
95
|
+
nil, nil, nil, nil, nil, nil, 73 ]
|
72
96
|
|
73
97
|
racc_goto_check = [
|
74
|
-
1,
|
75
|
-
nil, 1, nil, nil,
|
76
|
-
nil, nil, nil, nil,
|
77
|
-
|
78
|
-
|
98
|
+
1, 3, 10, 7, 4, 2, 9, 6, nil, nil,
|
99
|
+
nil, 1, nil, nil, 10, nil, nil, nil, nil, nil,
|
100
|
+
nil, 10, 7, nil, nil, nil, 10, 4, nil, nil,
|
101
|
+
10, 10, nil, 10, nil, nil, nil, 10, 10, nil,
|
102
|
+
nil, 3, nil, nil, nil, nil, nil, nil, nil, nil,
|
103
|
+
nil, nil, 1, nil, 1, nil, nil, nil, nil, nil,
|
104
|
+
nil, nil, nil, nil, nil, nil, 1 ]
|
79
105
|
|
80
106
|
racc_goto_pointer = [
|
81
|
-
nil, 0, -
|
107
|
+
nil, 0, -27, -7, -6, nil, 4, 0, nil, -33,
|
108
|
+
-37 ]
|
82
109
|
|
83
110
|
racc_goto_default = [
|
84
|
-
nil, nil,
|
111
|
+
nil, nil, 8, 10, nil, 12, nil, nil, 1, nil,
|
112
|
+
nil ]
|
85
113
|
|
86
114
|
racc_reduce_table = [
|
87
115
|
0, 0, :racc_error,
|
88
|
-
3,
|
89
|
-
1,
|
90
|
-
3,
|
91
|
-
2,
|
92
|
-
2,
|
93
|
-
1,
|
94
|
-
1,
|
95
|
-
3,
|
96
|
-
3,
|
97
|
-
4,
|
98
|
-
1,
|
99
|
-
1,
|
100
|
-
1,
|
101
|
-
1,
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
1,
|
109
|
-
1,
|
110
|
-
1,
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
1,
|
120
|
-
1,
|
121
|
-
1,
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
116
|
+
3, 39, :_reduce_1,
|
117
|
+
1, 39, :_reduce_2,
|
118
|
+
3, 40, :_reduce_3,
|
119
|
+
2, 40, :_reduce_4,
|
120
|
+
2, 40, :_reduce_5,
|
121
|
+
1, 40, :_reduce_none,
|
122
|
+
1, 41, :_reduce_none,
|
123
|
+
3, 41, :_reduce_8,
|
124
|
+
3, 41, :_reduce_9,
|
125
|
+
4, 41, :_reduce_10,
|
126
|
+
1, 41, :_reduce_11,
|
127
|
+
1, 41, :_reduce_12,
|
128
|
+
1, 41, :_reduce_13,
|
129
|
+
1, 41, :_reduce_14,
|
130
|
+
3, 43, :_reduce_15,
|
131
|
+
6, 43, :_reduce_16,
|
132
|
+
5, 43, :_reduce_17,
|
133
|
+
5, 43, :_reduce_18,
|
134
|
+
1, 46, :_reduce_none,
|
135
|
+
1, 46, :_reduce_none,
|
136
|
+
1, 42, :_reduce_none,
|
137
|
+
1, 42, :_reduce_none,
|
138
|
+
1, 42, :_reduce_none,
|
139
|
+
5, 42, :_reduce_24,
|
140
|
+
3, 42, :_reduce_25,
|
141
|
+
2, 45, :_reduce_26,
|
142
|
+
2, 45, :_reduce_27,
|
143
|
+
1, 45, :_reduce_none,
|
144
|
+
1, 45, :_reduce_none,
|
145
|
+
1, 44, :_reduce_30,
|
146
|
+
1, 44, :_reduce_31,
|
147
|
+
1, 44, :_reduce_32,
|
148
|
+
1, 44, :_reduce_33,
|
149
|
+
1, 44, :_reduce_34,
|
150
|
+
1, 44, :_reduce_35,
|
151
|
+
1, 44, :_reduce_36,
|
152
|
+
1, 44, :_reduce_37,
|
153
|
+
1, 44, :_reduce_38,
|
154
|
+
1, 44, :_reduce_39,
|
155
|
+
1, 44, :_reduce_40,
|
156
|
+
1, 44, :_reduce_41,
|
157
|
+
1, 44, :_reduce_42,
|
158
|
+
1, 44, :_reduce_43,
|
159
|
+
4, 47, :_reduce_44,
|
160
|
+
4, 47, :_reduce_45,
|
161
|
+
4, 47, :_reduce_46,
|
162
|
+
3, 47, :_reduce_47,
|
163
|
+
1, 48, :_reduce_48,
|
164
|
+
1, 48, :_reduce_49,
|
165
|
+
1, 48, :_reduce_50 ]
|
166
|
+
|
167
|
+
racc_reduce_n = 51
|
168
|
+
|
169
|
+
racc_shift_n = 82
|
126
170
|
|
127
171
|
racc_token_table = {
|
128
172
|
false => 0,
|
129
173
|
:error => 1,
|
130
174
|
:BAR => 2,
|
131
175
|
:LBRACK => 3,
|
132
|
-
:
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
137
|
-
:
|
138
|
-
:
|
139
|
-
:
|
140
|
-
:
|
141
|
-
:
|
142
|
-
:
|
143
|
-
:
|
144
|
-
:
|
145
|
-
:
|
146
|
-
:
|
147
|
-
:
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
176
|
+
:RBRACK => 4,
|
177
|
+
:NEGATE => 5,
|
178
|
+
:CCLASS => 6,
|
179
|
+
:DOT => 7,
|
180
|
+
:CHAR => 8,
|
181
|
+
:LPAREN => 9,
|
182
|
+
:RPAREN => 10,
|
183
|
+
:QMARK => 11,
|
184
|
+
:COLON => 12,
|
185
|
+
:NAME => 13,
|
186
|
+
:L_ANCHOR => 14,
|
187
|
+
:R_ANCHOR => 15,
|
188
|
+
:STAR => 16,
|
189
|
+
:PLUS => 17,
|
190
|
+
:LCURLY => 18,
|
191
|
+
:RCURLY => 19,
|
192
|
+
"alnum" => 20,
|
193
|
+
"alpha" => 21,
|
194
|
+
"ascii" => 22,
|
195
|
+
"blank" => 23,
|
196
|
+
"cntrl" => 24,
|
197
|
+
"digit" => 25,
|
198
|
+
"graph" => 26,
|
199
|
+
"lower" => 27,
|
200
|
+
"print" => 28,
|
201
|
+
"punct" => 29,
|
202
|
+
"space" => 30,
|
203
|
+
"upper" => 31,
|
204
|
+
"word" => 32,
|
205
|
+
"xdigit" => 33,
|
206
|
+
:MINUS => 34,
|
207
|
+
:MULTILINE => 35,
|
208
|
+
:IGNORECASE => 36,
|
209
|
+
:EXTENDED => 37 }
|
210
|
+
|
211
|
+
racc_nt_base = 38
|
155
212
|
|
156
213
|
racc_use_result_var = true
|
157
214
|
|
@@ -176,7 +233,6 @@ Racc_token_to_s_table = [
|
|
176
233
|
"error",
|
177
234
|
"BAR",
|
178
235
|
"LBRACK",
|
179
|
-
"LC_CTYPE",
|
180
236
|
"RBRACK",
|
181
237
|
"NEGATE",
|
182
238
|
"CCLASS",
|
@@ -193,6 +249,20 @@ Racc_token_to_s_table = [
|
|
193
249
|
"PLUS",
|
194
250
|
"LCURLY",
|
195
251
|
"RCURLY",
|
252
|
+
"\"alnum\"",
|
253
|
+
"\"alpha\"",
|
254
|
+
"\"ascii\"",
|
255
|
+
"\"blank\"",
|
256
|
+
"\"cntrl\"",
|
257
|
+
"\"digit\"",
|
258
|
+
"\"graph\"",
|
259
|
+
"\"lower\"",
|
260
|
+
"\"print\"",
|
261
|
+
"\"punct\"",
|
262
|
+
"\"space\"",
|
263
|
+
"\"upper\"",
|
264
|
+
"\"word\"",
|
265
|
+
"\"xdigit\"",
|
196
266
|
"MINUS",
|
197
267
|
"MULTILINE",
|
198
268
|
"IGNORECASE",
|
@@ -203,6 +273,7 @@ Racc_token_to_s_table = [
|
|
203
273
|
"atom",
|
204
274
|
"quantifier",
|
205
275
|
"group",
|
276
|
+
"ctype",
|
206
277
|
"bracket_expression",
|
207
278
|
"anchor",
|
208
279
|
"options",
|
@@ -263,7 +334,7 @@ def _reduce_10(val, _values, result)
|
|
263
334
|
end
|
264
335
|
|
265
336
|
def _reduce_11(val, _values, result)
|
266
|
-
result = val[0]
|
337
|
+
result = CharacterClass.new(val[0])
|
267
338
|
result
|
268
339
|
end
|
269
340
|
|
@@ -283,38 +354,32 @@ def _reduce_14(val, _values, result)
|
|
283
354
|
end
|
284
355
|
|
285
356
|
def _reduce_15(val, _values, result)
|
286
|
-
result = val.join
|
287
|
-
result
|
288
|
-
end
|
289
|
-
|
290
|
-
# reduce 16 omitted
|
291
|
-
|
292
|
-
def _reduce_17(val, _values, result)
|
293
357
|
result = Group.new(val[1])
|
294
358
|
result.index = @capture_index_stack.pop
|
295
359
|
|
296
360
|
result
|
297
361
|
end
|
298
362
|
|
299
|
-
def
|
363
|
+
def _reduce_16(val, _values, result)
|
300
364
|
result = Group.new(val[4]);
|
301
365
|
result.capture = false;
|
302
366
|
options = val[2];
|
303
|
-
result.expression.multiline
|
367
|
+
result.expression.multiline = options[:multiline];
|
304
368
|
result.expression.ignorecase = options[:ignorecase];
|
305
|
-
result.expression.extended
|
369
|
+
result.expression.extended = options[:extended];
|
370
|
+
@options_stack.pop
|
306
371
|
|
307
372
|
result
|
308
373
|
end
|
309
374
|
|
310
|
-
def
|
375
|
+
def _reduce_17(val, _values, result)
|
311
376
|
result = Group.new(val[3]);
|
312
377
|
result.capture = false;
|
313
378
|
|
314
379
|
result
|
315
380
|
end
|
316
381
|
|
317
|
-
def
|
382
|
+
def _reduce_18(val, _values, result)
|
318
383
|
result = Group.new(val[3]);
|
319
384
|
result.name = val[2];
|
320
385
|
result.index = @capture_index_stack.pop
|
@@ -322,15 +387,25 @@ def _reduce_20(val, _values, result)
|
|
322
387
|
result
|
323
388
|
end
|
324
389
|
|
390
|
+
# reduce 19 omitted
|
391
|
+
|
392
|
+
# reduce 20 omitted
|
393
|
+
|
325
394
|
# reduce 21 omitted
|
326
395
|
|
327
396
|
# reduce 22 omitted
|
328
397
|
|
329
398
|
# reduce 23 omitted
|
330
399
|
|
331
|
-
|
400
|
+
def _reduce_24(val, _values, result)
|
401
|
+
result = val.join
|
402
|
+
result
|
403
|
+
end
|
332
404
|
|
333
|
-
|
405
|
+
def _reduce_25(val, _values, result)
|
406
|
+
result = val.join
|
407
|
+
result
|
408
|
+
end
|
334
409
|
|
335
410
|
def _reduce_26(val, _values, result)
|
336
411
|
result = val.join
|
@@ -342,37 +417,115 @@ def _reduce_27(val, _values, result)
|
|
342
417
|
result
|
343
418
|
end
|
344
419
|
|
345
|
-
|
346
|
-
|
420
|
+
# reduce 28 omitted
|
421
|
+
|
422
|
+
# reduce 29 omitted
|
423
|
+
|
424
|
+
def _reduce_30(val, _values, result)
|
425
|
+
result = CharacterClass::ALNUM
|
347
426
|
result
|
348
427
|
end
|
349
428
|
|
350
|
-
def
|
351
|
-
result =
|
429
|
+
def _reduce_31(val, _values, result)
|
430
|
+
result = CharacterClass::ALPHA
|
352
431
|
result
|
353
432
|
end
|
354
433
|
|
355
|
-
def
|
356
|
-
result =
|
434
|
+
def _reduce_32(val, _values, result)
|
435
|
+
result = CharacterClass::ASCII
|
357
436
|
result
|
358
437
|
end
|
359
438
|
|
360
|
-
def
|
361
|
-
result =
|
439
|
+
def _reduce_33(val, _values, result)
|
440
|
+
result = CharacterClass::BLANK
|
362
441
|
result
|
363
442
|
end
|
364
443
|
|
365
|
-
def
|
444
|
+
def _reduce_34(val, _values, result)
|
445
|
+
result = CharacterClass::CNTRL
|
446
|
+
result
|
447
|
+
end
|
448
|
+
|
449
|
+
def _reduce_35(val, _values, result)
|
450
|
+
result = CharacterClass::DIGIT
|
451
|
+
result
|
452
|
+
end
|
453
|
+
|
454
|
+
def _reduce_36(val, _values, result)
|
455
|
+
result = CharacterClass::GRAPH
|
456
|
+
result
|
457
|
+
end
|
458
|
+
|
459
|
+
def _reduce_37(val, _values, result)
|
460
|
+
result = CharacterClass::LOWER
|
461
|
+
result
|
462
|
+
end
|
463
|
+
|
464
|
+
def _reduce_38(val, _values, result)
|
465
|
+
result = CharacterClass::PRINT
|
466
|
+
result
|
467
|
+
end
|
468
|
+
|
469
|
+
def _reduce_39(val, _values, result)
|
470
|
+
result = CharacterClass::PUNCT
|
471
|
+
result
|
472
|
+
end
|
473
|
+
|
474
|
+
def _reduce_40(val, _values, result)
|
475
|
+
result = CharacterClass::SPACE
|
476
|
+
result
|
477
|
+
end
|
478
|
+
|
479
|
+
def _reduce_41(val, _values, result)
|
480
|
+
result = CharacterClass::UPPER
|
481
|
+
result
|
482
|
+
end
|
483
|
+
|
484
|
+
def _reduce_42(val, _values, result)
|
485
|
+
result = CharacterClass::WORD
|
486
|
+
result
|
487
|
+
end
|
488
|
+
|
489
|
+
def _reduce_43(val, _values, result)
|
490
|
+
result = CharacterClass::XDIGIT
|
491
|
+
result
|
492
|
+
end
|
493
|
+
|
494
|
+
def _reduce_44(val, _values, result)
|
495
|
+
@options_stack << result = { val[1] => false, val[2] => false, val[3] => false }
|
496
|
+
|
497
|
+
result
|
498
|
+
end
|
499
|
+
|
500
|
+
def _reduce_45(val, _values, result)
|
501
|
+
@options_stack << result = { val[0] => true, val[2] => false, val[3] => false }
|
502
|
+
|
503
|
+
result
|
504
|
+
end
|
505
|
+
|
506
|
+
def _reduce_46(val, _values, result)
|
507
|
+
@options_stack << result = { val[0] => true, val[1] => true, val[3] => false }
|
508
|
+
|
509
|
+
result
|
510
|
+
end
|
511
|
+
|
512
|
+
def _reduce_47(val, _values, result)
|
513
|
+
@options_stack << result = { val[0] => true, val[1] => true, val[2] => true }
|
514
|
+
|
515
|
+
result
|
516
|
+
end
|
517
|
+
|
518
|
+
def _reduce_48(val, _values, result)
|
366
519
|
result = :multiline
|
367
520
|
result
|
368
521
|
end
|
369
522
|
|
370
|
-
def
|
523
|
+
def _reduce_49(val, _values, result)
|
371
524
|
result = :ignorecase
|
372
525
|
result
|
373
526
|
end
|
374
527
|
|
375
|
-
def
|
528
|
+
def _reduce_50(val, _values, result)
|
376
529
|
result = :extended
|
377
530
|
result
|
378
531
|
end
|
@@ -51,23 +51,8 @@ class Parser < Racc::Parser
|
|
51
51
|
token = case @state
|
52
52
|
when nil
|
53
53
|
case
|
54
|
-
when (text = @ss.scan(/\\
|
55
|
-
action { [:CCLASS,
|
56
|
-
|
57
|
-
when (text = @ss.scan(/\\D/))
|
58
|
-
action { [:CCLASS, CharacterClass.new('\D')] }
|
59
|
-
|
60
|
-
when (text = @ss.scan(/\\s/))
|
61
|
-
action { [:CCLASS, CharacterClass.new('\s')] }
|
62
|
-
|
63
|
-
when (text = @ss.scan(/\\S/))
|
64
|
-
action { [:CCLASS, CharacterClass.new('\S')] }
|
65
|
-
|
66
|
-
when (text = @ss.scan(/\\w/))
|
67
|
-
action { [:CCLASS, CharacterClass.new('\w')] }
|
68
|
-
|
69
|
-
when (text = @ss.scan(/\\W/))
|
70
|
-
action { [:CCLASS, CharacterClass.new('\W')] }
|
54
|
+
when (text = @ss.scan(/\\[dDsSwW]/))
|
55
|
+
action { [:CCLASS, text] }
|
71
56
|
|
72
57
|
when (text = @ss.scan(/\^/))
|
73
58
|
action { [:L_ANCHOR, text] }
|
@@ -120,6 +105,27 @@ class Parser < Racc::Parser
|
|
120
105
|
when (text = @ss.scan(/\*/))
|
121
106
|
action { [:STAR, text] }
|
122
107
|
|
108
|
+
when (text = @ss.scan(/\#/))
|
109
|
+
action {
|
110
|
+
if @options_stack[-1][:extended]
|
111
|
+
@state = :COMMENT;
|
112
|
+
next_token
|
113
|
+
else
|
114
|
+
[:CHAR, text]
|
115
|
+
end
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
when (text = @ss.scan(/\s|\n/))
|
120
|
+
action {
|
121
|
+
if @options_stack[-1][:extended]
|
122
|
+
next_token
|
123
|
+
else
|
124
|
+
[:CHAR, text]
|
125
|
+
end
|
126
|
+
}
|
127
|
+
|
128
|
+
|
123
129
|
when (text = @ss.scan(/\\(.)/))
|
124
130
|
action { [:CHAR, @ss[1]] }
|
125
131
|
|
@@ -139,53 +145,14 @@ class Parser < Racc::Parser
|
|
139
145
|
when (text = @ss.scan(/\^/))
|
140
146
|
action { [:NEGATE, text] }
|
141
147
|
|
142
|
-
when (text = @ss.scan(/:alnum:/))
|
143
|
-
action { [
|
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] }
|
148
|
+
when (text = @ss.scan(/:(alnum|alpha|ascii|blank|cntrl|digit|graph|lower|print|punct|space|upper|word|xdigit):/))
|
149
|
+
action { [@ss[1], text] }
|
183
150
|
|
184
151
|
when (text = @ss.scan(/\\(.)/))
|
185
152
|
action { [:CHAR, @ss[1]] }
|
186
153
|
|
187
154
|
when (text = @ss.scan(/./))
|
188
|
-
action { [:CHAR,
|
155
|
+
action { [:CHAR, text] }
|
189
156
|
|
190
157
|
else
|
191
158
|
text = @ss.string[@ss.pos .. -1]
|
@@ -227,6 +194,19 @@ class Parser < Racc::Parser
|
|
227
194
|
raise ScanError, "can not match: '" + text + "'"
|
228
195
|
end # if
|
229
196
|
|
197
|
+
when :COMMENT
|
198
|
+
case
|
199
|
+
when (text = @ss.scan(/\n/))
|
200
|
+
action { @state = nil; next_token }
|
201
|
+
|
202
|
+
when (text = @ss.scan(/./))
|
203
|
+
action { next_token }
|
204
|
+
|
205
|
+
else
|
206
|
+
text = @ss.string[@ss.pos .. -1]
|
207
|
+
raise ScanError, "can not match: '" + text + "'"
|
208
|
+
end # if
|
209
|
+
|
230
210
|
else
|
231
211
|
raise ScanError, "undefined state: '" + state.to_s + "'"
|
232
212
|
end # case state
|
@@ -4,6 +4,7 @@ module Reginald
|
|
4
4
|
autoload :Atom, 'reginald/atom'
|
5
5
|
autoload :Character, 'reginald/character'
|
6
6
|
autoload :CharacterClass, 'reginald/character_class'
|
7
|
+
autoload :Collection, 'reginald/collection'
|
7
8
|
autoload :Expression, 'reginald/expression'
|
8
9
|
autoload :Group, 'reginald/group'
|
9
10
|
autoload :Parser, 'reginald/parser'
|
@@ -22,37 +23,13 @@ module Reginald
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def parse(regexp)
|
25
|
-
|
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
|
26
|
+
Parser.parse_regexp(regexp)
|
35
27
|
end
|
36
28
|
|
37
29
|
def compile(source)
|
38
30
|
regexp = Regexp.compile(source)
|
39
31
|
expression = parse(regexp)
|
40
|
-
Regexp.compile(expression.
|
32
|
+
Regexp.compile(expression.to_s(true), expression.options)
|
41
33
|
end
|
42
|
-
|
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
|
55
|
-
end
|
56
|
-
end
|
57
34
|
end
|
58
35
|
end
|
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.3.
|
4
|
+
version: 0.3.2
|
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-12-
|
12
|
+
date: 2009-12-05 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/rack/mount/vendor/reginald/reginald/atom.rb
|
61
61
|
- lib/rack/mount/vendor/reginald/reginald/character.rb
|
62
62
|
- lib/rack/mount/vendor/reginald/reginald/character_class.rb
|
63
|
+
- lib/rack/mount/vendor/reginald/reginald/collection.rb
|
63
64
|
- lib/rack/mount/vendor/reginald/reginald/expression.rb
|
64
65
|
- lib/rack/mount/vendor/reginald/reginald/group.rb
|
65
66
|
- lib/rack/mount/vendor/reginald/reginald/parser.rb
|