regexp_parser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +16 -1
- data/Rakefile +50 -23
- data/lib/regexp_parser/lexer.rb +1 -1
- data/lib/regexp_parser/parser.rb +1 -1
- data/lib/regexp_parser/syntax/ruby/1.8.6.rb +26 -3
- data/lib/regexp_parser/syntax/ruby/1.8.7.rb +2 -2
- data/lib/regexp_parser/syntax/ruby/1.8.rb +3 -29
- data/lib/regexp_parser/syntax/ruby/1.9.1.rb +5 -1
- data/lib/regexp_parser/syntax/ruby/1.9.2.rb +0 -1
- data/lib/regexp_parser/syntax/tokens.rb +5 -3
- data/test/lexer/test_refcalls.rb +1 -1
- data/test/parser/test_alternation.rb +1 -1
- data/test/parser/test_expression.rb +3 -3
- data/test/parser/test_groups.rb +6 -6
- data/test/parser/test_properties.rb +7 -7
- data/test/parser/test_quantifiers.rb +7 -7
- data/test/parser/test_refcalls.rb +16 -16
- data/test/syntax/ruby/test_1.8.rb +3 -1
- metadata +11 -10
data/ChangeLog
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
+
Tue Nov 23 11:35:56 2010 Ammar Ali <ammarabuali@gmail.com>
|
1
2
|
|
2
|
-
|
3
|
+
* Made ruby 1.8.6 the base for all 1.8 syntax, and the 1.8 name a pointer
|
4
|
+
to the latest (1.8.7 at this time)
|
5
|
+
|
6
|
+
* Removed look-behind assertions (positive and negative) from 1.8 syntax
|
7
|
+
|
8
|
+
* Added control (\cc and \C-c) and meta (\M-c) escapes to 1.8 syntax
|
9
|
+
|
10
|
+
* The default syntax is now the one of the running ruby version in both the
|
11
|
+
lexer and the parser.
|
12
|
+
|
13
|
+
Sun Nov 21 03:36:42 2010 Ammar Ali <ammarabuali@gmail.com>
|
14
|
+
|
15
|
+
* Released version 0.1.0
|
16
|
+
|
17
|
+
Sat Nov 20 16:40:10 2010 Ammar Ali <ammarabuali@gmail.com>
|
3
18
|
|
4
19
|
* Initial version bump to 0.1.0
|
data/Rakefile
CHANGED
@@ -1,14 +1,26 @@
|
|
1
1
|
require 'rake'
|
2
|
+
require 'yaml'
|
2
3
|
require 'rake/testtask'
|
3
4
|
require 'rake/gempackagetask'
|
4
5
|
|
5
6
|
task :default => [:test]
|
6
7
|
|
8
|
+
|
7
9
|
RAGEL_SOURCE_DIR = File.expand_path '../lib/regexp_parser/scanner', __FILE__
|
8
10
|
RAGEL_OUTPUT_DIR = File.expand_path '../lib/regexp_parser', __FILE__
|
9
11
|
|
10
12
|
RAGEL_SOURCE_FILES = %w{scanner}
|
11
13
|
|
14
|
+
RP_ROOT = File.expand_path '../', __FILE__
|
15
|
+
|
16
|
+
def regexp_parser_version
|
17
|
+
v = YAML.load(File.read("#{RP_ROOT}/VERSION.yml"))
|
18
|
+
v[:build] ? "#{v[:major]}.#{v[:minor]}.#{v[:patch]}.#{v[:build]}" :
|
19
|
+
"#{v[:major]}.#{v[:minor]}.#{v[:patch]}"
|
20
|
+
end
|
21
|
+
|
22
|
+
RP_VERSION = regexp_parser_version
|
23
|
+
|
12
24
|
desc "Find and run all unit tests under test/ directory"
|
13
25
|
Rake::TestTask.new("test") do |t|
|
14
26
|
t.libs << "test"
|
@@ -60,32 +72,47 @@ namespace :ragel do
|
|
60
72
|
end
|
61
73
|
end
|
62
74
|
|
63
|
-
spec = Gem::Specification.new do |
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
75
|
+
spec = Gem::Specification.new do |gem|
|
76
|
+
gem.name = 'regexp_parser'
|
77
|
+
gem.version = '0.1.1'
|
78
|
+
gem.date = '2010-11-23'
|
79
|
+
|
80
|
+
gem.license = 'MIT'
|
81
|
+
gem.summary = %q{Scanner, lexer, parser for ruby's regular expressions}
|
82
|
+
gem.description = %q{A library for tokenizing, lexing, and parsing Ruby regular expressions.}
|
83
|
+
gem.homepage = %q{http://github.com/ammar/regexp_parser}
|
84
|
+
|
85
|
+
gem.authors = ["Ammar Ali"]
|
86
|
+
gem.email = 'ammarabuali@gmail.com'
|
87
|
+
|
88
|
+
gem.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
89
|
+
gem.extra_rdoc_files = ["ChangeLog", "LICENSE", "README.rdoc"]
|
90
|
+
|
91
|
+
gem.require_paths = ["lib"]
|
92
|
+
|
93
|
+
gem.files = Dir.glob("{lib,test}/**/*.rb") + Dir.glob("lib/**/*.rl") +
|
94
|
+
%w(Rakefile LICENSE README.rdoc ChangeLog)
|
95
|
+
|
96
|
+
gem.test_files = Dir.glob("test/**/*.rb")
|
97
|
+
|
98
|
+
gem.required_rubygems_version = Gem::Requirement.new(">= 0") if
|
99
|
+
gem.respond_to? :required_rubygems_version=
|
84
100
|
end
|
85
101
|
|
86
102
|
Rake::GemPackageTask.new(spec) do |pkg|
|
87
|
-
Rake::Task['ragel:rb'].execute
|
88
|
-
|
89
103
|
pkg.need_zip = true
|
90
104
|
pkg.need_tar = true
|
91
105
|
end
|
106
|
+
|
107
|
+
namespace :gem do
|
108
|
+
desc "Release the gem to rubygems.org"
|
109
|
+
task :release do |t|
|
110
|
+
Rake::Task['ragel:rb'].execute
|
111
|
+
|
112
|
+
Rake::Task['gem'].invoke("#{RP_ROOT}/pkg/regexp_parser-#{RP_VERSION}")
|
113
|
+
|
114
|
+
Rake::Task['repackage'].execute
|
115
|
+
|
116
|
+
sh "gem push #{RP_ROOT}/pkg/regexp_parser-#{RP_VERSION}.gem"
|
117
|
+
end
|
118
|
+
end
|
data/lib/regexp_parser/lexer.rb
CHANGED
data/lib/regexp_parser/parser.rb
CHANGED
@@ -1,11 +1,34 @@
|
|
1
|
-
require File.expand_path('../1.8', __FILE__)
|
2
|
-
|
3
1
|
module Regexp::Syntax
|
4
2
|
|
5
3
|
module Ruby
|
6
|
-
class V186 < Regexp::Syntax::
|
4
|
+
class V186 < Regexp::Syntax::Base
|
5
|
+
include Regexp::Syntax::Token
|
6
|
+
|
7
7
|
def initialize
|
8
8
|
super
|
9
|
+
|
10
|
+
implements :anchor, Anchor::All
|
11
|
+
implements :assertion, Group::Assertion::Lookahead
|
12
|
+
implements :backref, [:number]
|
13
|
+
|
14
|
+
implements :escape,
|
15
|
+
Escape::Basic + Escape::Backreference +
|
16
|
+
Escape::ASCII + Escape::Meta + Escape::Control
|
17
|
+
|
18
|
+
implements :group, Group::All
|
19
|
+
|
20
|
+
implements :meta, Meta::Extended
|
21
|
+
|
22
|
+
implements :quantifier,
|
23
|
+
Quantifier::Greedy + Quantifier::Reluctant +
|
24
|
+
Quantifier::Interval + Quantifier::IntervalReluctant
|
25
|
+
|
26
|
+
implements :set, CharacterSet::OpenClose +
|
27
|
+
CharacterSet::Extended + CharacterSet::Types +
|
28
|
+
CharacterSet::POSIX::Standard
|
29
|
+
|
30
|
+
implements :type,
|
31
|
+
CharacterType::Extended
|
9
32
|
end
|
10
33
|
|
11
34
|
end
|
@@ -1,37 +1,11 @@
|
|
1
|
+
require File.expand_path('../1.8.7', __FILE__)
|
2
|
+
|
1
3
|
module Regexp::Syntax
|
2
4
|
|
3
5
|
module Ruby
|
4
|
-
class V18 < Regexp::Syntax::
|
5
|
-
include Regexp::Syntax::Token
|
6
|
-
|
6
|
+
class V18 < Regexp::Syntax::Ruby::V187
|
7
7
|
def initialize
|
8
8
|
super
|
9
|
-
|
10
|
-
|
11
|
-
implements :anchor, Anchor::All
|
12
|
-
implements :assertion, Group::Assertion::All
|
13
|
-
implements :backref, [:number]
|
14
|
-
|
15
|
-
implements :escape,
|
16
|
-
Escape::Basic + Escape::Backreference +
|
17
|
-
Escape::ASCII + Escape::Meta
|
18
|
-
|
19
|
-
implements :group, Group::All
|
20
|
-
|
21
|
-
implements :meta, Meta::Extended
|
22
|
-
|
23
|
-
implements :quantifier,
|
24
|
-
Quantifier::Greedy + Quantifier::Reluctant +
|
25
|
-
Quantifier::Interval + Quantifier::IntervalReluctant
|
26
|
-
|
27
|
-
implements :set, CharacterSet::OpenClose +
|
28
|
-
CharacterSet::Extended + CharacterSet::Types +
|
29
|
-
CharacterSet::POSIX::Standard
|
30
|
-
|
31
|
-
implements :type,
|
32
|
-
CharacterType::Extended
|
33
|
-
|
34
|
-
|
35
9
|
end
|
36
10
|
end
|
37
11
|
end
|
@@ -9,6 +9,9 @@ module Regexp::Syntax
|
|
9
9
|
def initialize
|
10
10
|
super
|
11
11
|
|
12
|
+
implements :assertion, Group::Assertion::Lookbehind +
|
13
|
+
Group::SubexpressionCall::All
|
14
|
+
|
12
15
|
implements :backref, Group::Backreference::All +
|
13
16
|
Group::SubexpressionCall::All
|
14
17
|
|
@@ -26,7 +29,8 @@ module Regexp::Syntax
|
|
26
29
|
implements :set,
|
27
30
|
CharacterSet::POSIX::StandardNegative +
|
28
31
|
CharacterSet::POSIX::Extensions +
|
29
|
-
CharacterSet::POSIX::ExtensionsNegative
|
32
|
+
CharacterSet::POSIX::ExtensionsNegative +
|
33
|
+
UnicodeProperty::All
|
30
34
|
|
31
35
|
implements :subset, CharacterSet::OpenClose +
|
32
36
|
CharacterSet::Extended + CharacterSet::Types +
|
@@ -66,6 +66,8 @@ module Regexp::Syntax
|
|
66
66
|
|
67
67
|
Backreference = [:digit]
|
68
68
|
|
69
|
+
Control = [:control, :meta_sequence]
|
70
|
+
|
69
71
|
ASCII = [:bell, :backspace, :escape, :form_feed, :newline, :carriage,
|
70
72
|
:space, :tab, :vertical_tab]
|
71
73
|
|
@@ -88,10 +90,10 @@ module Regexp::Syntax
|
|
88
90
|
Comment = [:comment]
|
89
91
|
|
90
92
|
module Assertion
|
91
|
-
|
92
|
-
|
93
|
+
Lookahead = [:lookahead, :nlookahead]
|
94
|
+
Lookbehind = [:lookbehind, :nlookbehind]
|
93
95
|
|
94
|
-
All =
|
96
|
+
All = Lookahead + Lookbehind
|
95
97
|
end
|
96
98
|
|
97
99
|
module Backreference
|
data/test/lexer/test_refcalls.rb
CHANGED
@@ -35,7 +35,7 @@ class LexerRefCalls < Test::Unit::TestCase
|
|
35
35
|
tests.each do |pattern, test|
|
36
36
|
define_method "test_lexer_#{test[1]}_#{test[2]}_#{count+=1}" do
|
37
37
|
|
38
|
-
tokens = RL.scan(pattern)
|
38
|
+
tokens = RL.scan(pattern, 'ruby/1.9')
|
39
39
|
assert_equal( test[1,7], tokens[test[0]].to_a)
|
40
40
|
assert_equal( test[3], pattern[tokens[test[0]][3], tokens[test[0]][4]])
|
41
41
|
|
@@ -19,17 +19,17 @@ class ParserExpression < Test::Unit::TestCase
|
|
19
19
|
|
20
20
|
def test_parse_expression_to_s_property_sets
|
21
21
|
pattern = '[\a\b\p{Lu}\P{Z}\c\d]+'
|
22
|
-
assert_equal( pattern, RP.parse(pattern).to_s )
|
22
|
+
assert_equal( pattern, RP.parse(pattern, 'ruby/1.9').to_s )
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_parse_expression_to_s_groups
|
26
26
|
pattern = "(a(?>b(?:c(?<n>d(?'N'e)??f)+g)*+h)*i)++"
|
27
|
-
assert_equal( pattern, RP.parse(pattern).to_s )
|
27
|
+
assert_equal( pattern, RP.parse(pattern, 'ruby/1.9').to_s )
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_parse_expression_to_s_assertions
|
31
31
|
pattern = '(a+(?=b+(?!c+(?<=d+(?<!e+)?f+)?g+)?h+)?i+)?'
|
32
|
-
assert_equal( pattern, RP.parse(pattern).to_s )
|
32
|
+
assert_equal( pattern, RP.parse(pattern, 'ruby/1.9').to_s )
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_parse_expression_to_s_comments
|
data/test/parser/test_groups.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path("../../helpers", __FILE__)
|
|
3
3
|
class TestParserGroups < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def test_parse_root_options_mi
|
6
|
-
t = RP.parse((/[abc]/mi).to_s)
|
6
|
+
t = RP.parse((/[abc]/mi).to_s, 'ruby/1.8')
|
7
7
|
|
8
8
|
assert_equal( true, t.m? )
|
9
9
|
assert_equal( true, t.i? )
|
@@ -11,7 +11,7 @@ class TestParserGroups < Test::Unit::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_parse_nested_options_m
|
14
|
-
t = RP.parse('(?xi-m:a(?m-ix:b))')
|
14
|
+
t = RP.parse('(?xi-m:a(?m-ix:b))', 'ruby/1.8')
|
15
15
|
|
16
16
|
assert_equal( true, t.expressions[0].expressions[1].m? )
|
17
17
|
assert_equal( false, t.expressions[0].expressions[1].i? )
|
@@ -19,7 +19,7 @@ class TestParserGroups < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_parse_nested_options_xm
|
22
|
-
t = RP.parse(/(?i-xm:a(?mx-i:b))/)
|
22
|
+
t = RP.parse(/(?i-xm:a(?mx-i:b))/, 'ruby/1.8')
|
23
23
|
|
24
24
|
assert_equal( true, t.expressions[0].expressions[1].m? )
|
25
25
|
assert_equal( false, t.expressions[0].expressions[1].i? )
|
@@ -27,7 +27,7 @@ class TestParserGroups < Test::Unit::TestCase
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_parse_nested_options_im
|
30
|
-
t = RP.parse(/(?x-mi:a(?mi-x:b))/)
|
30
|
+
t = RP.parse(/(?x-mi:a(?mi-x:b))/, 'ruby/1.8')
|
31
31
|
|
32
32
|
assert_equal( true, t.expressions[0].expressions[1].m? )
|
33
33
|
assert_equal( true, t.expressions[0].expressions[1].i? )
|
@@ -35,7 +35,7 @@ class TestParserGroups < Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_parse_lookahead
|
38
|
-
t = RP.parse('(?=abc)(?!def)')
|
38
|
+
t = RP.parse('(?=abc)(?!def)', 'ruby/1.8')
|
39
39
|
|
40
40
|
assert( t.expressions[0].is_a?(Assertion::Lookahead),
|
41
41
|
"Expected lookahead, but got #{t.expressions[0].class.name}")
|
@@ -45,7 +45,7 @@ class TestParserGroups < Test::Unit::TestCase
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_parse_lookbehind
|
48
|
-
t = RP.parse('(?<=abc)(?<!def)')
|
48
|
+
t = RP.parse('(?<=abc)(?<!def)', 'ruby/1.9')
|
49
49
|
|
50
50
|
assert( t.expressions[0].is_a?(Assertion::Lookbehind),
|
51
51
|
"Expected lookbehind, but got #{t.expressions[0].class.name}")
|
@@ -295,7 +295,7 @@ class ParserProperties < Test::Unit::TestCase
|
|
295
295
|
|
296
296
|
props.each do |property|
|
297
297
|
define_method "test_parse_#{token_type}_#{property}" do
|
298
|
-
t = RP.parse "ab\\#{mode}{#{property}}"
|
298
|
+
t = RP.parse "ab\\#{mode}{#{property}}", 'ruby/1.9'
|
299
299
|
|
300
300
|
assert( t.expressions.last.is_a?(UnicodeProperty::Base),
|
301
301
|
"Expected property, but got #{t.expressions.last.class.name}")
|
@@ -307,38 +307,38 @@ class ParserProperties < Test::Unit::TestCase
|
|
307
307
|
end
|
308
308
|
|
309
309
|
def test_parse_property_negative
|
310
|
-
t = RP.parse 'ab\p{L}cd'
|
310
|
+
t = RP.parse 'ab\p{L}cd', 'ruby/1.9'
|
311
311
|
assert_equal( false, t.expressions[1].negative? )
|
312
312
|
end
|
313
313
|
|
314
314
|
def test_parse_nonproperty_negative
|
315
|
-
t = RP.parse 'ab\P{L}cd'
|
315
|
+
t = RP.parse 'ab\P{L}cd', 'ruby/1.9'
|
316
316
|
assert_equal( true, t.expressions[1].negative? )
|
317
317
|
end
|
318
318
|
|
319
319
|
def test_parse_property_age
|
320
|
-
t = RP.parse 'ab\p{age=5.2}cd'
|
320
|
+
t = RP.parse 'ab\p{age=5.2}cd', 'ruby/1.9'
|
321
321
|
|
322
322
|
assert( t.expressions[1].is_a?(UnicodeProperty::Age),
|
323
323
|
"Expected Age property, but got #{t.expressions[1].class.name}")
|
324
324
|
end
|
325
325
|
|
326
326
|
def test_parse_property_derived
|
327
|
-
t = RP.parse 'ab\p{Math}cd'
|
327
|
+
t = RP.parse 'ab\p{Math}cd', 'ruby/1.9'
|
328
328
|
|
329
329
|
assert( t.expressions[1].is_a?(UnicodeProperty::Derived),
|
330
330
|
"Expected Derived property, but got #{t.expressions[1].class.name}")
|
331
331
|
end
|
332
332
|
|
333
333
|
def test_parse_property_script
|
334
|
-
t = RP.parse 'ab\p{Hiragana}cd'
|
334
|
+
t = RP.parse 'ab\p{Hiragana}cd', 'ruby/1.9'
|
335
335
|
|
336
336
|
assert( t.expressions[1].is_a?(UnicodeProperty::Script),
|
337
337
|
"Expected Script property, but got #{t.expressions[1].class.name}")
|
338
338
|
end
|
339
339
|
|
340
340
|
def test_parse_property_following_literal
|
341
|
-
t = RP.parse 'ab\p{Lu}cd'
|
341
|
+
t = RP.parse 'ab\p{Lu}cd', 'ruby/1.9'
|
342
342
|
|
343
343
|
assert( t.expressions[2].is_a?(Literal),
|
344
344
|
"Expected Literal, but got #{t.expressions[2].class.name}")
|
@@ -25,7 +25,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_parse_zero_or_one_possessive
|
28
|
-
t = RP.parse('a?+bc')
|
28
|
+
t = RP.parse('a?+bc', 'ruby/1.9')
|
29
29
|
|
30
30
|
assert_equal( true, t.expressions.first.quantified? )
|
31
31
|
assert_equal( :zero_or_one, t.expressions.first.quantifier.token )
|
@@ -58,7 +58,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_parse_zero_or_more_possessive
|
61
|
-
t = RP.parse('a*+bc')
|
61
|
+
t = RP.parse('a*+bc', 'ruby/1.9')
|
62
62
|
|
63
63
|
assert_equal( true, t.expressions.first.quantified? )
|
64
64
|
assert_equal( :zero_or_more, t.expressions.first.quantifier.token )
|
@@ -91,7 +91,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def test_parse_one_or_more_possessive
|
94
|
-
t = RP.parse('a++bc')
|
94
|
+
t = RP.parse('a++bc', 'ruby/1.9')
|
95
95
|
|
96
96
|
assert_equal( true, t.expressions.first.quantified? )
|
97
97
|
assert_equal( :one_or_more, t.expressions.first.quantifier.token )
|
@@ -124,7 +124,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def test_parse_intervals_min_max_possessive
|
127
|
-
t = RP.parse('a{2,4}+bc')
|
127
|
+
t = RP.parse('a{2,4}+bc', 'ruby/1.9')
|
128
128
|
|
129
129
|
assert_equal( true, t.expressions.first.quantified? )
|
130
130
|
assert_equal( :interval, t.expressions.first.quantifier.token )
|
@@ -157,7 +157,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
157
157
|
end
|
158
158
|
|
159
159
|
def test_parse_intervals_min_only_possessive
|
160
|
-
t = RP.parse('a{3,}+bc')
|
160
|
+
t = RP.parse('a{3,}+bc', 'ruby/1.9')
|
161
161
|
|
162
162
|
assert_equal( true, t.expressions.first.quantified? )
|
163
163
|
assert_equal( :interval, t.expressions.first.quantifier.token )
|
@@ -190,7 +190,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def test_parse_intervals_max_only_possessive
|
193
|
-
t = RP.parse('a{,3}+bc')
|
193
|
+
t = RP.parse('a{,3}+bc', 'ruby/1.9')
|
194
194
|
|
195
195
|
assert_equal( true, t.expressions.first.quantified? )
|
196
196
|
assert_equal( :interval, t.expressions.first.quantifier.token )
|
@@ -223,7 +223,7 @@ class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
|
223
223
|
end
|
224
224
|
|
225
225
|
def test_parse_intervals_exact_possessive
|
226
|
-
t = RP.parse('a{3}+bc')
|
226
|
+
t = RP.parse('a{3}+bc', 'ruby/1.9')
|
227
227
|
|
228
228
|
assert_equal( true, t.expressions.first.quantified? )
|
229
229
|
assert_equal( :interval, t.expressions.first.quantifier.token )
|
@@ -3,97 +3,97 @@ require File.expand_path("../../helpers", __FILE__)
|
|
3
3
|
class TestParserGroups < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def test_parse_backref_named_ab
|
6
|
-
t = RP.parse('(?<X>abc)\k<X>')[1]
|
6
|
+
t = RP.parse('(?<X>abc)\k<X>', 'ruby/1.9')[1]
|
7
7
|
|
8
8
|
assert_equal( true, t.is_a?(Backreference::Name) )
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_parse_backref_named_sq
|
12
|
-
t = RP.parse("(?<X>abc)\\k'X'")[1]
|
12
|
+
t = RP.parse("(?<X>abc)\\k'X'", 'ruby/1.9')[1]
|
13
13
|
|
14
14
|
assert_equal( true, t.is_a?(Backreference::Name) )
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_parse_backref_number_ab
|
18
|
-
t = RP.parse('(abc)\k<1>')[1]
|
18
|
+
t = RP.parse('(abc)\k<1>', 'ruby/1.9')[1]
|
19
19
|
|
20
20
|
assert_equal( true, t.is_a?(Backreference::Number) )
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_parse_backref_number_sq
|
24
|
-
t = RP.parse("(abc)\\k'1'")[1]
|
24
|
+
t = RP.parse("(abc)\\k'1'", 'ruby/1.9')[1]
|
25
25
|
|
26
26
|
assert_equal( true, t.is_a?(Backreference::Number) )
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_parse_backref_number_relative_ab
|
30
|
-
t = RP.parse('(abc)\k<-1>')[1]
|
30
|
+
t = RP.parse('(abc)\k<-1>', 'ruby/1.9')[1]
|
31
31
|
|
32
32
|
assert_equal( true, t.is_a?(Backreference::NumberRelative) )
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_parse_backref_number_relative_sq
|
36
|
-
t = RP.parse("(abc)\\k'-1'")[1]
|
36
|
+
t = RP.parse("(abc)\\k'-1'", 'ruby/1.9')[1]
|
37
37
|
|
38
38
|
assert_equal( true, t.is_a?(Backreference::NumberRelative) )
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_parse_backref_name_call_ab
|
42
|
-
t = RP.parse('(?<X>abc)\g<X>')[1]
|
42
|
+
t = RP.parse('(?<X>abc)\g<X>', 'ruby/1.9')[1]
|
43
43
|
|
44
44
|
assert_equal( true, t.is_a?(Backreference::NameCall) )
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_parse_backref_name_call_sq
|
48
|
-
t = RP.parse("(?<X>abc)\\g'X'")[1]
|
48
|
+
t = RP.parse("(?<X>abc)\\g'X'", 'ruby/1.9')[1]
|
49
49
|
|
50
50
|
assert_equal( true, t.is_a?(Backreference::NameCall) )
|
51
51
|
end
|
52
52
|
|
53
53
|
def test_parse_backref_number_call_ab
|
54
|
-
t = RP.parse('(abc)\g<1>')[1]
|
54
|
+
t = RP.parse('(abc)\g<1>', 'ruby/1.9')[1]
|
55
55
|
|
56
56
|
assert_equal( true, t.is_a?(Backreference::NumberCall) )
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_parse_backref_number_call_sq
|
60
|
-
t = RP.parse("(abc)\\g'1'")[1]
|
60
|
+
t = RP.parse("(abc)\\g'1'", 'ruby/1.9')[1]
|
61
61
|
|
62
62
|
assert_equal( true, t.is_a?(Backreference::NumberCall) )
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_parse_backref_number_relative_call_ab
|
66
|
-
t = RP.parse('(abc)\g<-1>')[1]
|
66
|
+
t = RP.parse('(abc)\g<-1>', 'ruby/1.9')[1]
|
67
67
|
|
68
68
|
assert_equal( true, t.is_a?(Backreference::NumberCallRelative) )
|
69
69
|
end
|
70
70
|
|
71
71
|
def test_parse_backref_number_relative_call_sq
|
72
|
-
t = RP.parse("(abc)\\g'-1'")[1]
|
72
|
+
t = RP.parse("(abc)\\g'-1'", 'ruby/1.9')[1]
|
73
73
|
|
74
74
|
assert_equal( true, t.is_a?(Backreference::NumberCallRelative) )
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_parse_backref_name_nest_level_ab
|
78
|
-
t = RP.parse('(?<X>abc)\k<X-0>')[1]
|
78
|
+
t = RP.parse('(?<X>abc)\k<X-0>', 'ruby/1.9')[1]
|
79
79
|
|
80
80
|
assert_equal( true, t.is_a?(Backreference::NameNestLevel) )
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_parse_backref_name_nest_level_sq
|
84
|
-
t = RP.parse("(?<X>abc)\\k'X-0'")[1]
|
84
|
+
t = RP.parse("(?<X>abc)\\k'X-0'", 'ruby/1.9')[1]
|
85
85
|
|
86
86
|
assert_equal( true, t.is_a?(Backreference::NameNestLevel) )
|
87
87
|
end
|
88
88
|
|
89
89
|
def test_parse_backref_number_nest_level_ab
|
90
|
-
t = RP.parse('(abc)\k<1-0>')[1]
|
90
|
+
t = RP.parse('(abc)\k<1-0>', 'ruby/1.9')[1]
|
91
91
|
|
92
92
|
assert_equal( true, t.is_a?(Backreference::NumberNestLevel) )
|
93
93
|
end
|
94
94
|
|
95
95
|
def test_parse_backref_number_nest_level_sq
|
96
|
-
t = RP.parse("(abc)\\k'1-0'")[1]
|
96
|
+
t = RP.parse("(abc)\\k'1-0'", 'ruby/1.9')[1]
|
97
97
|
|
98
98
|
assert_equal( true, t.is_a?(Backreference::NumberNestLevel) )
|
99
99
|
end
|
@@ -9,10 +9,10 @@ class TestSyntaxRuby_V18 < Test::Unit::TestCase
|
|
9
9
|
|
10
10
|
tests = {
|
11
11
|
:implements => {
|
12
|
+
:assertion => [Group::Assertion::Lookahead].flatten,
|
12
13
|
:backref => [:number],
|
13
14
|
:escape => [Escape::All].flatten,
|
14
15
|
:group => [Group::All].flatten,
|
15
|
-
:assertion => [Group::Assertion::All].flatten,
|
16
16
|
:quantifier => [
|
17
17
|
Quantifier::Greedy + Quantifier::Reluctant +
|
18
18
|
Quantifier::Interval + Quantifier::IntervalReluctant
|
@@ -20,6 +20,8 @@ class TestSyntaxRuby_V18 < Test::Unit::TestCase
|
|
20
20
|
},
|
21
21
|
|
22
22
|
:excludes => {
|
23
|
+
:assertion => [Group::Assertion::Lookbehind].flatten,
|
24
|
+
|
23
25
|
:backref => [
|
24
26
|
Group::Backreference::All + Group::SubexpressionCall::All
|
25
27
|
].flatten,
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexp_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ammar Ali
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-11-23 00:00:00 +02:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -89,8 +90,8 @@ files:
|
|
89
90
|
- ChangeLog
|
90
91
|
has_rdoc: true
|
91
92
|
homepage: http://github.com/ammar/regexp_parser
|
92
|
-
licenses:
|
93
|
-
|
93
|
+
licenses:
|
94
|
+
- MIT
|
94
95
|
post_install_message:
|
95
96
|
rdoc_options:
|
96
97
|
- --inline-source
|
@@ -102,6 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
103
|
requirements:
|
103
104
|
- - ">="
|
104
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
105
107
|
segments:
|
106
108
|
- 0
|
107
109
|
version: "0"
|
@@ -110,14 +112,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
112
|
requirements:
|
111
113
|
- - ">="
|
112
114
|
- !ruby/object:Gem::Version
|
115
|
+
hash: 3
|
113
116
|
segments:
|
114
|
-
-
|
115
|
-
|
116
|
-
- 7
|
117
|
-
version: 1.3.7
|
117
|
+
- 0
|
118
|
+
version: "0"
|
118
119
|
requirements: []
|
119
120
|
|
120
|
-
rubyforge_project:
|
121
|
+
rubyforge_project:
|
121
122
|
rubygems_version: 1.3.7
|
122
123
|
signing_key:
|
123
124
|
specification_version: 3
|