regexp_parser 0.4.1 → 0.4.2
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 +11 -0
- data/lib/regexp_parser/scanner.rb +327 -299
- data/lib/regexp_parser/scanner/scanner.rl +1 -1
- data/lib/regexp_parser/syntax/ruby/2.4.0.rb +13 -0
- data/lib/regexp_parser/syntax/ruby/2.4.rb +8 -0
- data/lib/regexp_parser/syntax/tokens/escape.rb +1 -1
- data/lib/regexp_parser/syntax/versions.rb +6 -0
- data/lib/regexp_parser/version.rb +1 -1
- data/regexp_parser.gemspec +1 -1
- data/test/expression/test_conditionals.rb +2 -2
- data/test/expression/test_traverse.rb +1 -1
- data/test/parser/test_conditionals.rb +1 -1
- data/test/parser/test_escapes.rb +2 -1
- data/test/scanner/test_conditionals.rb +16 -16
- data/test/scanner/test_escapes.rb +1 -1
- data/test/syntax/ruby/test_files.rb +14 -0
- metadata +6 -4
@@ -53,7 +53,7 @@
|
|
53
53
|
wide_hex_seq_empty = 'x' . '{' . (space+)? . '}';
|
54
54
|
|
55
55
|
codepoint_single = 'u' . xdigit{4};
|
56
|
-
codepoint_list = 'u{' .
|
56
|
+
codepoint_list = 'u{' . xdigit{1,5} . (space . xdigit{1,5})* . '}';
|
57
57
|
codepoint_sequence = codepoint_single | codepoint_list;
|
58
58
|
|
59
59
|
control_sequence = ('c' | 'C-');
|
@@ -11,7 +11,7 @@ module Regexp::Syntax
|
|
11
11
|
ASCII = [:bell, :backspace, :escape, :form_feed, :newline, :carriage,
|
12
12
|
:space, :tab, :vertical_tab]
|
13
13
|
|
14
|
-
Unicode = [:codepoint_list]
|
14
|
+
Unicode = [:codepoint, :codepoint_list]
|
15
15
|
|
16
16
|
Meta = [:dot, :alternation,
|
17
17
|
:zero_or_one, :zero_or_more, :one_or_more,
|
data/regexp_parser.gemspec
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path("../../helpers", __FILE__)
|
|
3
3
|
class ExpressionConditionals < Test::Unit::TestCase
|
4
4
|
|
5
5
|
def setup
|
6
|
-
@root = RP.parse(/^a(b(?(1)c|(?(2)d|(?(3)e|f)))g)$/)
|
6
|
+
@root = RP.parse(/^(a(b))(b(?(1)c|(?(2)d|(?(3)e|f)))g)$/)
|
7
7
|
|
8
8
|
@cond_1 = @root[2][1]
|
9
9
|
@cond_2 = @root[2][1][2][0]
|
@@ -19,7 +19,7 @@ class ExpressionConditionals < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_expression_conditional_root_level
|
22
|
-
%w{^ a (b(?(1)c|(?(2)d|(?(3)e|f)))g) $}.each_with_index do |t, i|
|
22
|
+
%w{^ (a(b)) (b(?(1)c|(?(2)d|(?(3)e|f)))g) $}.each_with_index do |t, i|
|
23
23
|
assert_equal 0, @root[i].conditional_level
|
24
24
|
assert_equal t, @root[i].to_s
|
25
25
|
end
|
@@ -98,7 +98,7 @@ class SubexpressionTraverse < Test::Unit::TestCase
|
|
98
98
|
assert_equal Array, item.class
|
99
99
|
assert_equal 2, item.length
|
100
100
|
assert_equal true, item.first.is_a?(Regexp::Expression::Base)
|
101
|
-
assert_equal true, item.last.is_a?(
|
101
|
+
assert_equal true, item.last.is_a?(Integer)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -71,7 +71,7 @@ class TestParserConditionals < Test::Unit::TestCase
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_parse_conditional_nested
|
74
|
-
regexp = /(a(b(c)))(?(1)(?(2)d|(?(3)e|f))|(?(4)(?(5)g|h)))/
|
74
|
+
regexp = /(a(b(c(d)(e))))(?(1)(?(2)d|(?(3)e|f))|(?(4)(?(5)g|h)))/
|
75
75
|
|
76
76
|
root = RP.parse(regexp, 'ruby/2.0')
|
77
77
|
|
data/test/parser/test_escapes.rb
CHANGED
@@ -27,7 +27,8 @@ class TestParserEscapes < Test::Unit::TestCase
|
|
27
27
|
/a\}c/ => [1, :escape, :interval_close, EscapeSequence::Literal],
|
28
28
|
|
29
29
|
# unicode escapes
|
30
|
-
/a\
|
30
|
+
/a\u0640/ => [1, :escape, :codepoint, EscapeSequence::Literal],
|
31
|
+
/a\u{41 1F60D}/ => [1, :escape, :codepoint_list, EscapeSequence::Literal],
|
31
32
|
|
32
33
|
# hex escapes
|
33
34
|
/a\xFF/n => [1, :escape, :hex, EscapeSequence::Literal],
|
@@ -4,22 +4,22 @@ class ScannerConditionals < Test::Unit::TestCase
|
|
4
4
|
|
5
5
|
# Basic conditional scan token tests
|
6
6
|
tests = {
|
7
|
-
/(?(1)T|F)/
|
8
|
-
/(?(
|
9
|
-
/(?(
|
10
|
-
/(?(
|
11
|
-
/(?(
|
12
|
-
/(?(
|
13
|
-
/(?(
|
14
|
-
/(?(
|
15
|
-
|
16
|
-
/(?(1)TRUE)/
|
17
|
-
|
18
|
-
/(?(1)TRUE|)/
|
19
|
-
/(?(
|
20
|
-
|
21
|
-
/(?<N>A)(?(<N>)T|F)/ => [5,
|
22
|
-
/(?'N'A)(?('N')T|F)/ => [5,
|
7
|
+
/(a)(?(1)T|F)/ => [3, :conditional, :open, '(?', 3, 5],
|
8
|
+
/(a)(?(1)T|F)/ => [4, :conditional, :condition_open, '(', 5, 6],
|
9
|
+
/(a)(?(1)T|F)/ => [5, :conditional, :condition, '3', 6, 7],
|
10
|
+
/(a)(?(1)T|F)/ => [6, :conditional, :condition_close, ')', 7, 8],
|
11
|
+
/(a)(?(1)T|F)/ => [7, :literal, :literal, 'T', 8, 9],
|
12
|
+
/(a)(?(1)T|F)/ => [8, :conditional, :separator, '|', 9, 10],
|
13
|
+
/(a)(?(1)T|F)/ => [9, :literal, :literal, 'F', 10, 11],
|
14
|
+
/(a)(?(1)T|F)/ => [10, :conditional, :close, ')', 11, 12],
|
15
|
+
|
16
|
+
/(a)(?(1)TRUE)/ => [8, :conditional, :close, ')', 12, 13],
|
17
|
+
|
18
|
+
/(a)(?(1)TRUE|)/ => [8, :conditional, :separator, '|', 12, 13],
|
19
|
+
/(a)(?(1)TRUE|)/ => [9, :conditional, :close, ')', 13, 14],
|
20
|
+
|
21
|
+
/(?<N>A)(?(<N>)T|F)/ => [5, :conditional, :condition, '<N>', 10, 13],
|
22
|
+
/(?'N'A)(?('N')T|F)/ => [5, :conditional, :condition, "'N'", 10, 13],
|
23
23
|
}
|
24
24
|
|
25
25
|
tests.each_with_index do |(pattern, (index, type, token, text, ts, te)), count|
|
@@ -25,7 +25,7 @@ class ScannerEscapes < Test::Unit::TestCase
|
|
25
25
|
'a\x{0640}c' => [1, :escape, :hex_wide, '\x{0640}', 1, 9],
|
26
26
|
|
27
27
|
'a\u0640c' => [1, :escape, :codepoint, '\u0640', 1, 7],
|
28
|
-
'a\u{
|
28
|
+
'a\u{640 0641}c' => [1, :escape, :codepoint_list, '\u{640 0641}', 1, 13],
|
29
29
|
|
30
30
|
/a\cBc/ => [1, :escape, :control, '\cB', 1, 4],
|
31
31
|
/a\C-bc/ => [1, :escape, :control, '\C-b', 1, 5],
|
@@ -217,4 +217,18 @@ class TestSyntaxFiles < Test::Unit::TestCase
|
|
217
217
|
|
218
218
|
assert syntax.kind_of?(Regexp::Syntax::Ruby::V233)
|
219
219
|
end
|
220
|
+
|
221
|
+
# 2.4 syntax files
|
222
|
+
def test_syntax_file_2_4_0
|
223
|
+
syntax = Regexp::Syntax.new 'ruby/2.4.0'
|
224
|
+
|
225
|
+
assert syntax.kind_of?(Regexp::Syntax::Ruby::V23)
|
226
|
+
assert syntax.kind_of?(Regexp::Syntax::Ruby::V240)
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_syntax_file_2_4_alias
|
230
|
+
syntax = Regexp::Syntax.new 'ruby/2.4'
|
231
|
+
|
232
|
+
assert syntax.kind_of?(Regexp::Syntax::Ruby::V240)
|
233
|
+
end
|
220
234
|
end
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ammar Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-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:
|
@@ -84,6 +84,8 @@ files:
|
|
84
84
|
- lib/regexp_parser/syntax/ruby/2.3.2.rb
|
85
85
|
- lib/regexp_parser/syntax/ruby/2.3.3.rb
|
86
86
|
- lib/regexp_parser/syntax/ruby/2.3.rb
|
87
|
+
- lib/regexp_parser/syntax/ruby/2.4.0.rb
|
88
|
+
- lib/regexp_parser/syntax/ruby/2.4.rb
|
87
89
|
- lib/regexp_parser/syntax/tokens.rb
|
88
90
|
- lib/regexp_parser/syntax/tokens/anchor.rb
|
89
91
|
- lib/regexp_parser/syntax/tokens/assertion.rb
|
@@ -181,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
183
|
requirements:
|
182
184
|
- - ">="
|
183
185
|
- !ruby/object:Gem::Version
|
184
|
-
version: 1.
|
186
|
+
version: 1.9.1
|
185
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
188
|
requirements:
|
187
189
|
- - ">="
|
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
191
|
version: '0'
|
190
192
|
requirements: []
|
191
193
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.6.8
|
193
195
|
signing_key:
|
194
196
|
specification_version: 4
|
195
197
|
summary: Scanner, lexer, parser for ruby's regular expressions
|