regexp_parser 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ChangeLog +8 -0
- data/README.md +1 -0
- data/lib/regexp_parser/expression/classes/group.rb +1 -0
- data/lib/regexp_parser/lexer.rb +1 -1
- data/lib/regexp_parser/parser.rb +2 -0
- data/lib/regexp_parser/scanner.rb +613 -611
- data/lib/regexp_parser/scanner/scanner.rl +4 -1
- data/lib/regexp_parser/syntax/ruby/2.3.4.rb +13 -0
- data/lib/regexp_parser/syntax/ruby/2.3.rb +2 -2
- data/lib/regexp_parser/syntax/ruby/2.4.1.rb +2 -0
- data/lib/regexp_parser/syntax/tokens/group.rb +2 -0
- data/lib/regexp_parser/syntax/versions.rb +1 -0
- data/lib/regexp_parser/version.rb +1 -1
- data/test/parser/test_groups.rb +13 -0
- data/test/scanner/test_groups.rb +7 -0
- data/test/support/warning_extractor.rb +1 -0
- data/test/syntax/ruby/test_files.rb +8 -1
- metadata +3 -2
@@ -82,6 +82,7 @@
|
|
82
82
|
|
83
83
|
group_atomic = '?>';
|
84
84
|
group_passive = '?:';
|
85
|
+
group_absence = '?~';
|
85
86
|
|
86
87
|
assertion_lookahead = '?=';
|
87
88
|
assertion_nlookahead = '?!';
|
@@ -107,7 +108,7 @@
|
|
107
108
|
group_number_ref = group_ref . (('<' . group_number . group_level? '>') |
|
108
109
|
("'" . group_number . group_level? "'"));
|
109
110
|
|
110
|
-
group_type = group_atomic | group_passive | group_named;
|
111
|
+
group_type = group_atomic | group_passive | group_absence | group_named;
|
111
112
|
|
112
113
|
|
113
114
|
assertion_type = assertion_lookahead | assertion_nlookahead |
|
@@ -573,6 +574,7 @@
|
|
573
574
|
# Groups
|
574
575
|
# (?:subexp) passive (non-captured) group
|
575
576
|
# (?>subexp) atomic group, don't backtrack in subexp.
|
577
|
+
# (?~subexp) absence group, matches anything that is not subexp
|
576
578
|
# (?<name>subexp) named group
|
577
579
|
# (?'name'subexp) named group (single quoted version)
|
578
580
|
# (subexp) captured group
|
@@ -581,6 +583,7 @@
|
|
581
583
|
case text = text(data, ts, te).first
|
582
584
|
when '(?:'; emit(:group, :passive, text, ts, te)
|
583
585
|
when '(?>'; emit(:group, :atomic, text, ts, te)
|
586
|
+
when '(?~'; emit(:group, :absence, text, ts, te)
|
584
587
|
|
585
588
|
when /^\(\?<(\w*)>/
|
586
589
|
empty_name_error(:group, 'named group (ab)') if $1.empty?
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require File.expand_path('../2.3.
|
1
|
+
require File.expand_path('../2.3.4', __FILE__)
|
2
2
|
|
3
3
|
module Regexp::Syntax
|
4
4
|
module Ruby
|
5
5
|
# uses the latest 2.3 release
|
6
|
-
class V23 < Regexp::Syntax::Ruby::
|
6
|
+
class V23 < Regexp::Syntax::Ruby::V234; end
|
7
7
|
end
|
8
8
|
end
|
data/test/parser/test_groups.rb
CHANGED
@@ -106,4 +106,17 @@ class TestParserGroups < Test::Unit::TestCase
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
if RUBY_VERSION >= '2.4.1'
|
110
|
+
def test_parse_absence_group
|
111
|
+
t = RP.parse('a(?~b)c(?~d)e')
|
112
|
+
|
113
|
+
[1,3].each do |i|
|
114
|
+
assert t.expressions[i].is_a?(Group::Absence),
|
115
|
+
"Expected absence group, but got #{t.expressions[i].class.name}"
|
116
|
+
|
117
|
+
assert_equal :group, t.expressions[i].type
|
118
|
+
assert_equal :absence, t.expressions[i].token
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
109
122
|
end
|
data/test/scanner/test_groups.rb
CHANGED
@@ -55,6 +55,13 @@ class ScannerGroups < Test::Unit::TestCase
|
|
55
55
|
})
|
56
56
|
end
|
57
57
|
|
58
|
+
if RUBY_VERSION >= '2.4.1'
|
59
|
+
tests.merge!({
|
60
|
+
# New absence operator
|
61
|
+
'(?~abc)' => [0, :group, :absence, '(?~', 0, 3],
|
62
|
+
})
|
63
|
+
end
|
64
|
+
|
58
65
|
tests.each_with_index do |(pattern, (index, type, token, text, ts, te)), count|
|
59
66
|
define_method "test_scanner_#{type}_#{token}_#{count}" do
|
60
67
|
tokens = RS.scan(pattern)
|
@@ -212,10 +212,17 @@ class TestSyntaxFiles < Test::Unit::TestCase
|
|
212
212
|
assert syntax.kind_of?(Regexp::Syntax::Ruby::V233)
|
213
213
|
end
|
214
214
|
|
215
|
+
def test_syntax_file_2_3_4
|
216
|
+
syntax = Regexp::Syntax.new 'ruby/2.3.4'
|
217
|
+
|
218
|
+
assert syntax.kind_of?(Regexp::Syntax::Ruby::V233)
|
219
|
+
assert syntax.kind_of?(Regexp::Syntax::Ruby::V234)
|
220
|
+
end
|
221
|
+
|
215
222
|
def test_syntax_file_2_3_alias
|
216
223
|
syntax = Regexp::Syntax.new 'ruby/2.3'
|
217
224
|
|
218
|
-
assert syntax.kind_of?(Regexp::Syntax::Ruby::
|
225
|
+
assert syntax.kind_of?(Regexp::Syntax::Ruby::V234)
|
219
226
|
end
|
220
227
|
|
221
228
|
# 2.4 syntax files
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexp_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ammar Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
|
14
14
|
email:
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/regexp_parser/syntax/ruby/2.3.1.rb
|
84
84
|
- lib/regexp_parser/syntax/ruby/2.3.2.rb
|
85
85
|
- lib/regexp_parser/syntax/ruby/2.3.3.rb
|
86
|
+
- lib/regexp_parser/syntax/ruby/2.3.4.rb
|
86
87
|
- lib/regexp_parser/syntax/ruby/2.3.rb
|
87
88
|
- lib/regexp_parser/syntax/ruby/2.4.0.rb
|
88
89
|
- lib/regexp_parser/syntax/ruby/2.4.1.rb
|