regexp_parser 0.4.13 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +15 -0
- data/lib/regexp_parser/expression.rb +43 -51
- data/lib/regexp_parser/expression/classes/alternation.rb +6 -7
- data/lib/regexp_parser/expression/classes/character_class.rb +11 -0
- data/lib/regexp_parser/expression/classes/conditional.rb +10 -18
- data/lib/regexp_parser/expression/classes/free_space.rb +1 -1
- data/lib/regexp_parser/expression/classes/group.rb +9 -21
- data/lib/regexp_parser/expression/classes/property.rb +2 -2
- data/lib/regexp_parser/expression/classes/set.rb +1 -12
- data/lib/regexp_parser/expression/methods/traverse.rb +1 -1
- data/lib/regexp_parser/expression/quantifier.rb +9 -9
- data/lib/regexp_parser/expression/sequence.rb +5 -4
- data/lib/regexp_parser/expression/subexpression.rb +16 -59
- data/lib/regexp_parser/lexer.rb +31 -27
- data/lib/regexp_parser/parser.rb +179 -179
- data/lib/regexp_parser/scanner.rb +172 -166
- data/lib/regexp_parser/scanner/scanner.rl +44 -38
- data/lib/regexp_parser/syntax.rb +2 -53
- data/lib/regexp_parser/syntax/base.rb +13 -24
- data/lib/regexp_parser/syntax/tokens/character_class.rb +16 -0
- data/lib/regexp_parser/syntax/tokens/unicode_property.rb +26 -26
- data/lib/regexp_parser/syntax/version_lookup.rb +82 -0
- data/lib/regexp_parser/syntax/versions.rb +1 -5
- data/lib/regexp_parser/syntax/versions/1.8.6.rb +30 -0
- data/lib/regexp_parser/syntax/versions/1.9.1.rb +36 -0
- data/lib/regexp_parser/syntax/versions/1.9.3.rb +11 -0
- data/lib/regexp_parser/syntax/versions/2.0.0.rb +20 -0
- data/lib/regexp_parser/syntax/versions/2.2.0.rb +10 -0
- data/lib/regexp_parser/syntax/versions/2.3.0.rb +10 -0
- data/lib/regexp_parser/syntax/versions/2.4.0.rb +10 -0
- data/lib/regexp_parser/syntax/versions/2.4.1.rb +9 -0
- data/lib/regexp_parser/syntax/versions/2.5.0.rb +10 -0
- data/lib/regexp_parser/token.rb +6 -29
- data/lib/regexp_parser/version.rb +1 -1
- data/test/expression/test_strfregexp.rb +7 -0
- data/test/expression/test_to_h.rb +6 -0
- data/test/parser/test_properties.rb +12 -4
- data/test/support/warning_extractor.rb +3 -1
- data/test/syntax/test_all.rb +1 -1
- data/test/syntax/test_syntax.rb +5 -9
- data/test/syntax/{ruby → versions}/test_1.8.rb +14 -14
- data/test/syntax/{ruby → versions}/test_1.9.1.rb +7 -8
- data/test/syntax/{ruby → versions}/test_1.9.3.rb +7 -7
- data/test/syntax/versions/test_2.0.0.rb +37 -0
- data/test/syntax/{ruby → versions}/test_2.2.0.rb +7 -7
- data/test/syntax/versions/test_aliases.rb +129 -0
- data/test/syntax/{ruby → versions}/test_all.rb +1 -1
- metadata +73 -113
- data/lib/regexp_parser/syntax/ruby/1.8.6.rb +0 -37
- data/lib/regexp_parser/syntax/ruby/1.8.7.rb +0 -14
- data/lib/regexp_parser/syntax/ruby/1.8.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/1.9.1.rb +0 -45
- data/lib/regexp_parser/syntax/ruby/1.9.2.rb +0 -9
- data/lib/regexp_parser/syntax/ruby/1.9.3.rb +0 -19
- data/lib/regexp_parser/syntax/ruby/1.9.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.0.0.rb +0 -23
- data/lib/regexp_parser/syntax/ruby/2.0.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.1.0.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.10.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.2.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.3.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.4.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.5.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.6.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.7.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.8.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.9.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.1.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.2.0.rb +0 -16
- data/lib/regexp_parser/syntax/ruby/2.2.1.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.10.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.2.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.3.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.4.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.5.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.6.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.7.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.8.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.9.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.2.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.3.0.rb +0 -16
- data/lib/regexp_parser/syntax/ruby/2.3.1.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.2.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.3.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.4.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.5.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.6.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.7.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.3.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.4.0.rb +0 -16
- data/lib/regexp_parser/syntax/ruby/2.4.1.rb +0 -15
- data/lib/regexp_parser/syntax/ruby/2.4.2.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.4.3.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.4.4.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.4.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.5.0.rb +0 -16
- data/lib/regexp_parser/syntax/ruby/2.5.1.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.5.rb +0 -8
- data/lib/regexp_parser/syntax/ruby/2.6.0.rb +0 -13
- data/lib/regexp_parser/syntax/ruby/2.6.rb +0 -8
- data/test/syntax/ruby/test_2.0.0.rb +0 -32
- data/test/syntax/ruby/test_files.rb +0 -353
@@ -0,0 +1,82 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
VERSION_FORMAT = '\Aruby/\d+\.\d+(\.\d+)?\z'
|
3
|
+
VERSION_REGEXP = /#{VERSION_FORMAT}/
|
4
|
+
VERSION_CONST_REGEXP = /\AV\d+_\d+(?:_\d+)?\z/
|
5
|
+
|
6
|
+
class InvalidVersionNameError < SyntaxError
|
7
|
+
def initialize(name)
|
8
|
+
super "Invalid version name '#{name}'. Expected format is '#{VERSION_FORMAT}'"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class UnknownSyntaxNameError < SyntaxError
|
13
|
+
def initialize(name)
|
14
|
+
super "Unknown syntax name '#{name}'."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module_function
|
19
|
+
|
20
|
+
# Loads and instantiates an instance of the syntax specification class for
|
21
|
+
# the given syntax version name. The special names 'any' and '*' return an
|
22
|
+
# instance of Syntax::Any.
|
23
|
+
def new(name)
|
24
|
+
return Regexp::Syntax::Any.new if ['*', 'any'].include?(name.to_s)
|
25
|
+
version_class(name).new
|
26
|
+
end
|
27
|
+
|
28
|
+
def supported?(name)
|
29
|
+
name =~ VERSION_REGEXP &&
|
30
|
+
comparable_version(name) >= comparable_version('1.8.6')
|
31
|
+
end
|
32
|
+
|
33
|
+
def version_class(version)
|
34
|
+
version =~ VERSION_REGEXP || raise(InvalidVersionNameError, version)
|
35
|
+
version_const_name = version_const_name(version)
|
36
|
+
const_get(version_const_name) || raise(UnknownSyntaxNameError, version)
|
37
|
+
end
|
38
|
+
|
39
|
+
def version_const_name(version_string)
|
40
|
+
"V#{version_string.to_s.scan(/\d+/).join('_')}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def const_missing(const_name)
|
44
|
+
if const_name =~ VERSION_CONST_REGEXP
|
45
|
+
return fallback_version_class(const_name)
|
46
|
+
end
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
50
|
+
def fallback_version_class(version)
|
51
|
+
sorted_versions = (specified_versions + [version])
|
52
|
+
.sort_by { |name| comparable_version(name) }
|
53
|
+
return if (version_index = sorted_versions.index(version)) < 1
|
54
|
+
|
55
|
+
next_lower_version = sorted_versions[version_index - 1]
|
56
|
+
inherit_from_version(next_lower_version, version)
|
57
|
+
end
|
58
|
+
|
59
|
+
def inherit_from_version(parent_version, new_version)
|
60
|
+
new_const = version_const_name(new_version)
|
61
|
+
parent = const_get(version_const_name(parent_version))
|
62
|
+
const_defined?(new_const) || const_set(new_const, Class.new(parent))
|
63
|
+
warn_if_future_version(new_const)
|
64
|
+
const_get(new_const)
|
65
|
+
end
|
66
|
+
|
67
|
+
def specified_versions
|
68
|
+
constants.select { |const_name| const_name =~ VERSION_CONST_REGEXP }
|
69
|
+
end
|
70
|
+
|
71
|
+
def comparable_version(name)
|
72
|
+
# add .99 to treat versions without a patch value as latest patch version
|
73
|
+
Gem::Version.new((name.to_s.scan(/\d+/) << 99).join('.'))
|
74
|
+
end
|
75
|
+
|
76
|
+
def warn_if_future_version(const_name)
|
77
|
+
return if comparable_version(const_name) < comparable_version('3.0.0')
|
78
|
+
|
79
|
+
warn('This library has only been tested up to Ruby 2.x, '\
|
80
|
+
"but you are running with #{const_get(const_name).inspect}")
|
81
|
+
end
|
82
|
+
end
|
@@ -3,8 +3,4 @@
|
|
3
3
|
#
|
4
4
|
# Aliases for the latest patch version are provided as 'ruby/n.n',
|
5
5
|
# e.g. 'ruby/1.9' refers to Ruby v1.9.3.
|
6
|
-
|
7
|
-
version_file_paths = Dir[File.expand_path('../ruby/*.rb', __FILE__)]
|
8
|
-
version_file_paths.each { |path| require path }
|
9
|
-
VERSIONS = version_file_paths.map { |path| path[%r{(ruby/[^/]+)\.rb}, 1] }
|
10
|
-
end
|
6
|
+
Dir[File.expand_path('../versions/*.rb', __FILE__)].sort.each { |f| require f }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
class V1_8_6 < Regexp::Syntax::Base
|
3
|
+
def initialize
|
4
|
+
super
|
5
|
+
|
6
|
+
implements :anchor, Anchor::All
|
7
|
+
implements :assertion, Assertion::Lookahead
|
8
|
+
implements :backref, [:number]
|
9
|
+
|
10
|
+
implements :escape,
|
11
|
+
Escape::Basic + Escape::Backreference +
|
12
|
+
Escape::ASCII + Escape::Meta + Escape::Control
|
13
|
+
|
14
|
+
implements :group, Group::All
|
15
|
+
|
16
|
+
implements :meta, Meta::Extended
|
17
|
+
|
18
|
+
implements :quantifier,
|
19
|
+
Quantifier::Greedy + Quantifier::Reluctant +
|
20
|
+
Quantifier::Interval + Quantifier::IntervalReluctant
|
21
|
+
|
22
|
+
implements :set, CharacterSet::OpenClose +
|
23
|
+
CharacterSet::Extended + CharacterSet::Types +
|
24
|
+
CharacterSet::POSIX::Standard
|
25
|
+
|
26
|
+
implements :type,
|
27
|
+
CharacterType::Extended
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
class V1_9_1 < Regexp::Syntax::V1_8_6
|
3
|
+
def initialize
|
4
|
+
super
|
5
|
+
|
6
|
+
implements :assertion, Assertion::Lookbehind +
|
7
|
+
SubexpressionCall::All
|
8
|
+
|
9
|
+
implements :backref, Backreference::All +
|
10
|
+
SubexpressionCall::All
|
11
|
+
|
12
|
+
implements :escape, Escape::Unicode + Escape::Hex + Escape::Octal
|
13
|
+
|
14
|
+
implements :type, CharacterType::Hex
|
15
|
+
|
16
|
+
implements :property,
|
17
|
+
UnicodeProperty::V1_9_0
|
18
|
+
|
19
|
+
implements :nonproperty,
|
20
|
+
UnicodeProperty::V1_9_0
|
21
|
+
|
22
|
+
implements :quantifier,
|
23
|
+
Quantifier::Possessive + Quantifier::IntervalPossessive
|
24
|
+
|
25
|
+
implements :set,
|
26
|
+
CharacterSet::POSIX::StandardNegative +
|
27
|
+
CharacterSet::POSIX::Extensions +
|
28
|
+
CharacterSet::POSIX::ExtensionsNegative +
|
29
|
+
UnicodeProperty::V1_9_0
|
30
|
+
|
31
|
+
implements :subset, CharacterSet::OpenClose +
|
32
|
+
CharacterSet::Extended + CharacterSet::Types +
|
33
|
+
CharacterSet::POSIX::Standard
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
class V1_9_3 < Regexp::Syntax::V1_9_1
|
3
|
+
def initialize
|
4
|
+
super
|
5
|
+
|
6
|
+
# these were added with update of Oniguruma to Unicode 6.0
|
7
|
+
implements :property, UnicodeProperty::V1_9_3
|
8
|
+
implements :nonproperty, UnicodeProperty::V1_9_3
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
# use the last 1.9 release as the base
|
3
|
+
class V2_0_0 < Regexp::Syntax::V1_9
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
|
7
|
+
implements :keep, Keep::All
|
8
|
+
implements :conditional, Conditional::All
|
9
|
+
implements :property, UnicodeProperty::V2_0_0
|
10
|
+
implements :nonproperty, UnicodeProperty::V2_0_0
|
11
|
+
|
12
|
+
implements :type, CharacterType::Clustered
|
13
|
+
implements :set, CharacterSet::Clustered
|
14
|
+
implements :subset, CharacterSet::Clustered
|
15
|
+
|
16
|
+
excludes :property, :newline
|
17
|
+
excludes :nonproperty, :newline
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/regexp_parser/token.rb
CHANGED
@@ -12,45 +12,22 @@ class Regexp
|
|
12
12
|
].freeze
|
13
13
|
|
14
14
|
Token = Struct.new(*TOKEN_KEYS) do
|
15
|
-
|
16
|
-
super
|
17
|
-
|
18
|
-
@previous = @next = nil
|
19
|
-
end
|
15
|
+
attr_accessor :previous, :next
|
20
16
|
|
21
17
|
def offset
|
22
|
-
[
|
18
|
+
[ts, te]
|
23
19
|
end
|
24
20
|
|
25
21
|
def length
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def next(exp = nil)
|
30
|
-
if exp
|
31
|
-
@next = exp
|
32
|
-
else
|
33
|
-
@next
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def previous(exp = nil)
|
38
|
-
if exp
|
39
|
-
@previous = exp
|
40
|
-
else
|
41
|
-
@previous
|
42
|
-
end
|
22
|
+
te - ts
|
43
23
|
end
|
44
24
|
|
45
25
|
if RUBY_VERSION < '2.0.0'
|
46
26
|
def to_h
|
47
|
-
hash
|
48
|
-
|
49
|
-
|
50
|
-
hash[member.to_sym] = self.send(member.to_sym)
|
27
|
+
members.inject({}) do |hash, member|
|
28
|
+
hash[member.to_sym] = self[member]
|
29
|
+
hash
|
51
30
|
end
|
52
|
-
|
53
|
-
hash
|
54
31
|
end
|
55
32
|
end
|
56
33
|
end
|
@@ -167,6 +167,13 @@ class Expressionstrfregexp < Test::Unit::TestCase
|
|
167
167
|
assert_equal root.strfregexp('%m %t'), root.strfregexp('%a')
|
168
168
|
end
|
169
169
|
|
170
|
+
# regression test
|
171
|
+
def test_expression_strfregexp_conditional
|
172
|
+
root = RP.parse('(?<A>a)(?(<A>)b|c)', 'ruby/2.0')
|
173
|
+
|
174
|
+
assert_nothing_raised { root.strfregexp }
|
175
|
+
end
|
176
|
+
|
170
177
|
def test_expression_strfregexp_tree
|
171
178
|
root = RP.parse(/a[b-d]*(e(f+))?/)
|
172
179
|
|
@@ -20,8 +20,6 @@ class ParserProperties < Test::Unit::TestCase
|
|
20
20
|
'Xdigit',
|
21
21
|
'XPosixPunct',
|
22
22
|
|
23
|
-
'Newline',
|
24
|
-
|
25
23
|
'Any',
|
26
24
|
'Assigned',
|
27
25
|
|
@@ -368,14 +366,14 @@ class ParserProperties < Test::Unit::TestCase
|
|
368
366
|
"Expected Script property, but got #{t.expressions[1].class.name}"
|
369
367
|
end
|
370
368
|
|
371
|
-
def
|
369
|
+
def test_parse_property_script_V1_9_3
|
372
370
|
t = RP.parse 'ab\p{Brahmi}cd', 'ruby/1.9.3'
|
373
371
|
|
374
372
|
assert t.expressions[1].is_a?(UnicodeProperty::Script),
|
375
373
|
"Expected Script property, but got #{t.expressions[1].class.name}"
|
376
374
|
end
|
377
375
|
|
378
|
-
def
|
376
|
+
def test_parse_property_script_V2_2_0
|
379
377
|
t = RP.parse 'ab\p{Caucasian_Albanian}cd', 'ruby/2.2'
|
380
378
|
|
381
379
|
assert t.expressions[1].is_a?(UnicodeProperty::Script),
|
@@ -395,4 +393,14 @@ class ParserProperties < Test::Unit::TestCase
|
|
395
393
|
assert t.expressions[2].is_a?(Literal),
|
396
394
|
"Expected Literal, but got #{t.expressions[2].class.name}"
|
397
395
|
end
|
396
|
+
|
397
|
+
def test_parse_abandoned_newline_property
|
398
|
+
t = RP.parse '\p{newline}', 'ruby/1.9'
|
399
|
+
assert t.expressions.last.is_a?(UnicodeProperty::Base),
|
400
|
+
"Expected property, but got #{t.expressions.last.class.name}"
|
401
|
+
|
402
|
+
assert_raise(Regexp::Syntax::NotImplementedError) {
|
403
|
+
RP.parse('\p{newline}', 'ruby/2.0')
|
404
|
+
}
|
405
|
+
end
|
398
406
|
end
|
data/test/syntax/test_all.rb
CHANGED
data/test/syntax/test_syntax.rb
CHANGED
@@ -9,7 +9,7 @@ class TestSyntax < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_syntax_new
|
12
|
-
assert_instance_of Regexp::Syntax::
|
12
|
+
assert_instance_of Regexp::Syntax::V1_9_3,
|
13
13
|
Regexp::Syntax.new('ruby/1.9.3')
|
14
14
|
end
|
15
15
|
|
@@ -23,10 +23,6 @@ class TestSyntax < Test::Unit::TestCase
|
|
23
23
|
assert_equal false, Regexp::Syntax.supported?('ruby/1.1.1')
|
24
24
|
assert_equal true, Regexp::Syntax.supported?('ruby/2.4.3')
|
25
25
|
assert_equal true, Regexp::Syntax.supported?('ruby/2.5')
|
26
|
-
|
27
|
-
Regexp::Syntax::VERSIONS.each do |version|
|
28
|
-
assert_equal true, Regexp::Syntax.supported?(version)
|
29
|
-
end
|
30
26
|
end
|
31
27
|
|
32
28
|
def test_syntax_invalid_version
|
@@ -40,18 +36,18 @@ class TestSyntax < Test::Unit::TestCase
|
|
40
36
|
end
|
41
37
|
|
42
38
|
def test_syntax_version_class_tiny_version
|
43
|
-
assert_equal Regexp::Syntax::
|
39
|
+
assert_equal Regexp::Syntax::V1_9_3,
|
44
40
|
Regexp::Syntax.version_class('ruby/1.9.3')
|
45
41
|
|
46
|
-
assert_equal Regexp::Syntax::
|
42
|
+
assert_equal Regexp::Syntax::V2_3_1,
|
47
43
|
Regexp::Syntax.version_class('ruby/2.3.1')
|
48
44
|
end
|
49
45
|
|
50
46
|
def test_syntax_version_class_minor_version
|
51
|
-
assert_equal Regexp::Syntax::
|
47
|
+
assert_equal Regexp::Syntax::V1_9,
|
52
48
|
Regexp::Syntax.version_class('ruby/1.9')
|
53
49
|
|
54
|
-
assert_equal Regexp::Syntax::
|
50
|
+
assert_equal Regexp::Syntax::V2_3,
|
55
51
|
Regexp::Syntax.version_class('ruby/2.3')
|
56
52
|
end
|
57
53
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path("../../../helpers", __FILE__)
|
2
2
|
|
3
|
-
class
|
3
|
+
class TestSyntaxV1_8 < Test::Unit::TestCase
|
4
4
|
include Regexp::Syntax::Token
|
5
5
|
|
6
6
|
def setup
|
@@ -8,29 +8,29 @@ class TestSyntaxRuby_V18 < Test::Unit::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
tests = {
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
11
|
+
implements: {
|
12
|
+
assertion: [Assertion::Lookahead].flatten,
|
13
|
+
backref: [:number],
|
14
|
+
escape: [Escape::All].flatten,
|
15
|
+
group: [Group::All].flatten,
|
16
|
+
quantifier: [
|
17
17
|
Quantifier::Greedy + Quantifier::Reluctant +
|
18
18
|
Quantifier::Interval + Quantifier::IntervalReluctant
|
19
19
|
].flatten,
|
20
20
|
},
|
21
21
|
|
22
|
-
:
|
23
|
-
:
|
22
|
+
excludes: {
|
23
|
+
assertion: [Assertion::Lookbehind].flatten,
|
24
24
|
|
25
|
-
:
|
25
|
+
backref: [
|
26
26
|
Backreference::All - [:number] + SubexpressionCall::All
|
27
27
|
].flatten,
|
28
28
|
|
29
|
-
:
|
29
|
+
quantifier: [
|
30
30
|
Quantifier::Possessive
|
31
31
|
].flatten,
|
32
32
|
|
33
|
-
:
|
33
|
+
subset: nil
|
34
34
|
},
|
35
35
|
}
|
36
36
|
|
@@ -39,12 +39,12 @@ class TestSyntaxRuby_V18 < Test::Unit::TestCase
|
|
39
39
|
|
40
40
|
types.each do |type, tokens|
|
41
41
|
if tokens.nil? or tokens.empty?
|
42
|
-
define_method "
|
42
|
+
define_method "test_syntax_V1_8_#{method}_#{type}" do
|
43
43
|
assert_equal expected, @syntax.implements?(type, nil)
|
44
44
|
end
|
45
45
|
else
|
46
46
|
tokens.each do |token|
|
47
|
-
define_method "
|
47
|
+
define_method "test_syntax_V1_8_#{method}_#{type}_#{token}" do
|
48
48
|
assert_equal expected, @syntax.implements?(type, token)
|
49
49
|
end
|
50
50
|
end
|