regexp_parser 2.0.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +54 -0
- data/Gemfile +5 -1
- data/README.md +15 -21
- data/Rakefile +11 -17
- data/lib/regexp_parser/error.rb +4 -0
- data/lib/regexp_parser/expression/base.rb +123 -0
- data/lib/regexp_parser/expression/classes/anchor.rb +0 -2
- data/lib/regexp_parser/expression/classes/{backref.rb → backreference.rb} +5 -0
- data/lib/regexp_parser/expression/classes/{set → character_set}/intersection.rb +0 -0
- data/lib/regexp_parser/expression/classes/{set → character_set}/range.rb +2 -1
- data/lib/regexp_parser/expression/classes/{set.rb → character_set.rb} +0 -0
- data/lib/regexp_parser/expression/classes/conditional.rb +11 -1
- data/lib/regexp_parser/expression/classes/{escape.rb → escape_sequence.rb} +1 -0
- data/lib/regexp_parser/expression/classes/free_space.rb +1 -3
- data/lib/regexp_parser/expression/classes/group.rb +6 -1
- data/lib/regexp_parser/expression/classes/literal.rb +1 -5
- data/lib/regexp_parser/expression/classes/property.rb +1 -3
- data/lib/regexp_parser/expression/classes/root.rb +0 -1
- data/lib/regexp_parser/expression/classes/type.rb +0 -2
- data/lib/regexp_parser/expression/quantifier.rb +2 -2
- data/lib/regexp_parser/expression/sequence.rb +3 -10
- data/lib/regexp_parser/expression/subexpression.rb +1 -2
- data/lib/regexp_parser/expression.rb +7 -130
- data/lib/regexp_parser/lexer.rb +7 -5
- data/lib/regexp_parser/parser.rb +282 -334
- data/lib/regexp_parser/scanner/properties/long.yml +13 -0
- data/lib/regexp_parser/scanner/properties/short.yml +9 -1
- data/lib/regexp_parser/scanner/scanner.rl +64 -87
- data/lib/regexp_parser/scanner.rb +1024 -1073
- data/lib/regexp_parser/syntax/any.rb +2 -4
- data/lib/regexp_parser/syntax/base.rb +10 -10
- data/lib/regexp_parser/syntax/token/anchor.rb +15 -0
- data/lib/regexp_parser/syntax/{tokens → token}/assertion.rb +2 -2
- data/lib/regexp_parser/syntax/{tokens/backref.rb → token/backreference.rb} +6 -5
- data/lib/regexp_parser/syntax/{tokens → token}/character_set.rb +2 -2
- data/lib/regexp_parser/syntax/{tokens → token}/character_type.rb +3 -3
- data/lib/regexp_parser/syntax/{tokens → token}/conditional.rb +3 -3
- data/lib/regexp_parser/syntax/token/escape.rb +31 -0
- data/lib/regexp_parser/syntax/{tokens → token}/group.rb +7 -7
- data/lib/regexp_parser/syntax/{tokens → token}/keep.rb +1 -1
- data/lib/regexp_parser/syntax/{tokens → token}/meta.rb +2 -2
- data/lib/regexp_parser/syntax/{tokens → token}/posix_class.rb +3 -3
- data/lib/regexp_parser/syntax/token/quantifier.rb +35 -0
- data/lib/regexp_parser/syntax/token/unicode_property.rb +696 -0
- data/lib/regexp_parser/syntax/token.rb +45 -0
- data/lib/regexp_parser/syntax/version_lookup.rb +2 -2
- data/lib/regexp_parser/syntax/versions/1.8.6.rb +1 -1
- data/lib/regexp_parser/syntax/versions/3.1.0.rb +10 -0
- data/lib/regexp_parser/syntax.rb +8 -6
- data/lib/regexp_parser/token.rb +9 -20
- data/lib/regexp_parser/version.rb +1 -1
- data/lib/regexp_parser.rb +0 -2
- data/spec/expression/clone_spec.rb +36 -4
- data/spec/expression/free_space_spec.rb +2 -2
- data/spec/expression/methods/match_length_spec.rb +2 -2
- data/spec/lexer/nesting_spec.rb +2 -2
- data/spec/lexer/refcalls_spec.rb +5 -0
- data/spec/parser/all_spec.rb +2 -2
- data/spec/parser/escapes_spec.rb +43 -31
- data/spec/parser/properties_spec.rb +6 -4
- data/spec/parser/refcalls_spec.rb +5 -0
- data/spec/parser/set/ranges_spec.rb +26 -16
- data/spec/scanner/escapes_spec.rb +29 -20
- data/spec/scanner/refcalls_spec.rb +19 -0
- data/spec/scanner/sets_spec.rb +66 -23
- data/spec/spec_helper.rb +13 -1
- data/spec/support/capturing_stderr.rb +9 -0
- data/spec/syntax/versions/1.8.6_spec.rb +2 -2
- data/spec/syntax/versions/2.0.0_spec.rb +2 -2
- data/spec/syntax/versions/aliases_spec.rb +1 -0
- metadata +27 -26
- data/lib/regexp_parser/syntax/tokens/anchor.rb +0 -15
- data/lib/regexp_parser/syntax/tokens/escape.rb +0 -30
- data/lib/regexp_parser/syntax/tokens/quantifier.rb +0 -35
- data/lib/regexp_parser/syntax/tokens/unicode_property.rb +0 -675
- data/lib/regexp_parser/syntax/tokens.rb +0 -45
- data/spec/support/runner.rb +0 -42
- data/spec/support/warning_extractor.rb +0 -60
@@ -5,9 +5,19 @@ RSpec.describe('RefCall scanning') do
|
|
5
5
|
include_examples 'scan', '(abc)\1' , 3 => [:backref, :number, '\1', 5, 7]
|
6
6
|
|
7
7
|
# Group back-references, named, numbered, and relative
|
8
|
+
#
|
9
|
+
# NOTE: only \g supports forward-looking references using '+', e.g. \g<+1>
|
10
|
+
# refers to the next group, but \k<+1> refers to a group named '+1'.
|
11
|
+
# Inversely, only \k supports addition or substraction of a recursion level.
|
12
|
+
# E.g. \k<x+0> refers to a group named 'x' at the current recursion level,
|
13
|
+
# but \g<x+0> refers to a a group named 'x+0'.
|
14
|
+
#
|
8
15
|
include_examples 'scan', '(?<X>abc)\k<X>', 3 => [:backref, :name_ref_ab, '\k<X>', 9, 14]
|
9
16
|
include_examples 'scan', "(?<X>abc)\\k'X'", 3 => [:backref, :name_ref_sq, "\\k'X'", 9, 14]
|
10
17
|
|
18
|
+
include_examples 'scan', '(?<+1>abc)\k<+1>', 3 => [:backref, :name_ref_ab, '\k<+1>', 10, 16]
|
19
|
+
include_examples 'scan', "(?<+1>abc)\\k'+1'", 3 => [:backref, :name_ref_sq, "\\k'+1'", 10, 16]
|
20
|
+
|
11
21
|
include_examples 'scan', '(abc)\k<1>', 3 => [:backref, :number_ref_ab, '\k<1>', 5, 10]
|
12
22
|
include_examples 'scan', "(abc)\\k'1'", 3 => [:backref, :number_ref_sq, "\\k'1'", 5, 10]
|
13
23
|
|
@@ -18,9 +28,15 @@ RSpec.describe('RefCall scanning') do
|
|
18
28
|
include_examples 'scan', '(?<X>abc)\g<X>', 3 => [:backref, :name_call_ab, '\g<X>', 9, 14]
|
19
29
|
include_examples 'scan', "(?<X>abc)\\g'X'", 3 => [:backref, :name_call_sq, "\\g'X'", 9, 14]
|
20
30
|
|
31
|
+
include_examples 'scan', '(?<X>abc)\g<X-1>', 3 => [:backref, :name_call_ab, '\g<X-1>', 9, 16]
|
32
|
+
include_examples 'scan', "(?<X>abc)\\g'X-1'", 3 => [:backref, :name_call_sq, "\\g'X-1'", 9, 16]
|
33
|
+
|
21
34
|
include_examples 'scan', '(abc)\g<1>', 3 => [:backref, :number_call_ab, '\g<1>', 5, 10]
|
22
35
|
include_examples 'scan', "(abc)\\g'1'", 3 => [:backref, :number_call_sq, "\\g'1'", 5, 10]
|
23
36
|
|
37
|
+
include_examples 'scan', 'a(b|\g<0>)', 4 => [:backref, :number_call_ab, '\g<0>', 4, 9]
|
38
|
+
include_examples 'scan', "a(b|\\g'0')", 4 => [:backref, :number_call_sq, "\\g'0'", 4, 9]
|
39
|
+
|
24
40
|
include_examples 'scan', '(abc)\g<-1>', 3 => [:backref, :number_rel_call_ab, '\g<-1>', 5, 11]
|
25
41
|
include_examples 'scan', "(abc)\\g'-1'", 3 => [:backref, :number_rel_call_sq, "\\g'-1'", 5, 11]
|
26
42
|
|
@@ -33,4 +49,7 @@ RSpec.describe('RefCall scanning') do
|
|
33
49
|
|
34
50
|
include_examples 'scan', '(abc)\k<1-0>', 3 => [:backref, :number_recursion_ref_ab, '\k<1-0>', 5, 12]
|
35
51
|
include_examples 'scan', "(abc)\\k'1-0'", 3 => [:backref, :number_recursion_ref_sq, "\\k'1-0'", 5, 12]
|
52
|
+
|
53
|
+
include_examples 'scan', '(abc)\k<+1-0>', 3 => [:backref, :name_recursion_ref_ab, '\k<+1-0>', 5, 13]
|
54
|
+
include_examples 'scan', "(abc)\\k'+1-0'", 3 => [:backref, :name_recursion_ref_sq, "\\k'+1-0'", 5, 13]
|
36
55
|
end
|
data/spec/scanner/sets_spec.rb
CHANGED
@@ -6,8 +6,18 @@ RSpec.describe('Set scanning') do
|
|
6
6
|
include_examples 'scan', /[^n]/, 1 => [:set, :negate, '^', 1, 2]
|
7
7
|
|
8
8
|
include_examples 'scan', /[c]/, 1 => [:literal, :literal, 'c', 1, 2]
|
9
|
-
include_examples 'scan', /[
|
10
|
-
|
9
|
+
include_examples 'scan', /[^d]/, 2 => [:literal, :literal, 'd', 2, 3]
|
10
|
+
|
11
|
+
include_examples 'scan', /[\b]/, 1 => [:escape, :backspace, '\b', 1, 3]
|
12
|
+
include_examples 'scan', /[A\bX]/, 2 => [:escape, :backspace, '\b', 2, 4]
|
13
|
+
|
14
|
+
include_examples 'scan', /[\a]/, 1 => [:escape, :bell, '\a', 1, 3]
|
15
|
+
include_examples 'scan', /[\e]/, 1 => [:escape, :escape, '\e', 1, 3]
|
16
|
+
include_examples 'scan', /[\f]/, 1 => [:escape, :form_feed, '\f', 1, 3]
|
17
|
+
include_examples 'scan', /[\n]/, 1 => [:escape, :newline, '\n', 1, 3]
|
18
|
+
include_examples 'scan', /[\r]/, 1 => [:escape, :carriage, '\r', 1, 3]
|
19
|
+
include_examples 'scan', /[\t]/, 1 => [:escape, :tab, '\t', 1, 3]
|
20
|
+
include_examples 'scan', /[\v]/, 1 => [:escape, :vertical_tab, '\v', 1, 3]
|
11
21
|
|
12
22
|
include_examples 'scan', /[.]/, 1 => [:literal, :literal, '.', 1, 2]
|
13
23
|
include_examples 'scan', /[?]/, 1 => [:literal, :literal, '?', 1, 2]
|
@@ -18,22 +28,36 @@ RSpec.describe('Set scanning') do
|
|
18
28
|
include_examples 'scan', /[<]/, 1 => [:literal, :literal, '<', 1, 2]
|
19
29
|
include_examples 'scan', /[>]/, 1 => [:literal, :literal, '>', 1, 2]
|
20
30
|
|
21
|
-
include_examples 'scan',
|
22
|
-
|
23
|
-
include_examples 'scan', '[
|
31
|
+
include_examples 'scan', '[\\\\]', 1 => [:escape, :backslash, '\\\\', 1, 3]
|
32
|
+
include_examples 'scan', '[\u0040]', 1 => [:escape, :codepoint, '\u0040', 1, 7]
|
33
|
+
include_examples 'scan', '[\u{40}]', 1 => [:escape, :codepoint_list, '\u{40}', 1, 7]
|
34
|
+
include_examples 'scan', '[\c2]', 1 => [:escape, :control, '\c2', 1, 4]
|
35
|
+
include_examples 'scan', '[\C-C]', 1 => [:escape, :control, '\C-C', 1, 5]
|
36
|
+
include_examples 'scan', '[\x20]', 1 => [:escape, :hex, '\x20', 1, 5]
|
37
|
+
include_examples 'scan', '[\M-Z]', 1 => [:escape, :meta_sequence, '\M-Z', 1, 5]
|
38
|
+
include_examples 'scan', '[\M-\C-X]', 1 => [:escape, :meta_sequence, '\M-\C-X', 1, 8]
|
39
|
+
include_examples 'scan', '[\\[]', 1 => [:escape, :set_open, '\[', 1, 3]
|
40
|
+
include_examples 'scan', '[\\]]', 1 => [:escape, :set_close, '\]', 1, 3]
|
41
|
+
include_examples 'scan', '[a\-]', 2 => [:escape, :literal, '\-', 2, 4]
|
42
|
+
include_examples 'scan', '[\-c]', 1 => [:escape, :literal, '\-', 1, 3]
|
43
|
+
include_examples 'scan', '[\.]', 1 => [:escape, :literal, '\.', 1, 3]
|
44
|
+
include_examples 'scan', '[\?]', 1 => [:escape, :literal, '\?', 1, 3]
|
45
|
+
include_examples 'scan', '[\*]', 1 => [:escape, :literal, '\*', 1, 3]
|
46
|
+
include_examples 'scan', '[\+]', 1 => [:escape, :literal, '\+', 1, 3]
|
47
|
+
include_examples 'scan', '[\|]', 1 => [:escape, :literal, '\|', 1, 3]
|
48
|
+
include_examples 'scan', '[\{]', 1 => [:escape, :literal, '\{', 1, 3]
|
49
|
+
include_examples 'scan', '[\}]', 1 => [:escape, :literal, '\}', 1, 3]
|
50
|
+
include_examples 'scan', '[\(]', 1 => [:escape, :literal, '\(', 1, 3]
|
51
|
+
include_examples 'scan', '[\)]', 1 => [:escape, :literal, '\)', 1, 3]
|
24
52
|
include_examples 'scan', '[\!]', 1 => [:escape, :literal, '\!', 1, 3]
|
25
53
|
include_examples 'scan', '[\#]', 1 => [:escape, :literal, '\#', 1, 3]
|
26
|
-
include_examples 'scan', '[\\]]', 1 => [:escape, :set_close, '\]', 1, 3]
|
27
|
-
include_examples 'scan', '[\\\\]', 1 => [:escape, :backslash, '\\\\', 1, 3]
|
28
54
|
include_examples 'scan', '[\A]', 1 => [:escape, :literal, '\A', 1, 3]
|
29
55
|
include_examples 'scan', '[\z]', 1 => [:escape, :literal, '\z', 1, 3]
|
30
56
|
include_examples 'scan', '[\g]', 1 => [:escape, :literal, '\g', 1, 3]
|
31
57
|
include_examples 'scan', '[\K]', 1 => [:escape, :literal, '\K', 1, 3]
|
32
58
|
include_examples 'scan', '[\R]', 1 => [:escape, :literal, '\R', 1, 3]
|
33
59
|
include_examples 'scan', '[\X]', 1 => [:escape, :literal, '\X', 1, 3]
|
34
|
-
include_examples 'scan', '[\c2]', 1 => [:escape, :literal, '\c', 1, 3]
|
35
60
|
include_examples 'scan', '[\B]', 1 => [:escape, :literal, '\B', 1, 3]
|
36
|
-
include_examples 'scan', '[a\-c]', 2 => [:escape, :literal, '\-', 2, 4]
|
37
61
|
|
38
62
|
include_examples 'scan', /[\d]/, 1 => [:type, :digit, '\d', 1, 3]
|
39
63
|
include_examples 'scan', /[\da-z]/, 1 => [:type, :digit, '\d', 1, 3]
|
@@ -54,40 +78,59 @@ RSpec.describe('Set scanning') do
|
|
54
78
|
include_examples 'scan', /[a-b-]/, 4 => [:literal, :literal, '-', 4, 5]
|
55
79
|
include_examples 'scan', /[-a]/, 1 => [:literal, :literal, '-', 1, 2]
|
56
80
|
include_examples 'scan', /[a-c^]/, 4 => [:literal, :literal, '^', 4, 5]
|
57
|
-
include_examples 'scan', /[a-bd-f]/, 2 => [:set,
|
58
|
-
include_examples 'scan', /[a-cd-f]/, 5 => [:set,
|
81
|
+
include_examples 'scan', /[a-bd-f]/, 2 => [:set, :range, '-', 2, 3]
|
82
|
+
include_examples 'scan', /[a-cd-f]/, 5 => [:set, :range, '-', 5, 6]
|
83
|
+
# this is a buggy range, it matches only `c`, but not `a`, `b` or `-`
|
84
|
+
include_examples 'scan', /[a-[c]]/, 2 => [:set, :range, '-', 2, 3]
|
85
|
+
# these are not ranges, they match `a`, `c` and `-` (or non-`-` if negated)
|
86
|
+
include_examples 'scan', /[[a]-[c]]/, 4 => [:literal, :literal, '-', 4, 5]
|
87
|
+
include_examples 'scan', /[[a]-c]/, 4 => [:literal, :literal, '-', 4, 5]
|
88
|
+
include_examples 'scan', /[^-c]/, 2 => [:literal, :literal, '-', 2, 3]
|
59
89
|
|
60
90
|
include_examples 'scan', /[a[:digit:]c]/, 2 => [:posixclass, :digit, '[:digit:]', 2, 11]
|
61
91
|
include_examples 'scan', /[[:digit:][:space:]]/, 2 => [:posixclass, :space, '[:space:]', 10, 19]
|
62
92
|
include_examples 'scan', /[[:^digit:]]/, 1 => [:nonposixclass, :digit, '[:^digit:]', 1, 11]
|
63
93
|
|
64
|
-
include_examples 'scan', /[a[.a-b.]c]/, 2 => [:set, :collation, '[.a-b.]', 2, 9]
|
65
|
-
include_examples 'scan', /[a[=e=]c]/, 2 => [:set, :equivalent, '[=e=]', 2, 7]
|
66
|
-
|
67
94
|
include_examples 'scan', /[a-d&&g-h]/, 4 => [:set, :intersection, '&&', 4, 6]
|
68
95
|
include_examples 'scan', /[a&&]/, 2 => [:set, :intersection, '&&', 2, 4]
|
69
96
|
include_examples 'scan', /[&&z]/, 1 => [:set, :intersection, '&&', 1, 3]
|
97
|
+
include_examples 'scan', /[&&]/, 1 => [:set, :intersection, '&&', 1, 3]
|
70
98
|
|
71
|
-
include_examples 'scan',
|
72
|
-
include_examples 'scan',
|
73
|
-
include_examples 'scan',
|
74
|
-
include_examples 'scan',
|
99
|
+
include_examples 'scan', '[a\p{digit}c]', 2 => [:property, :digit, '\p{digit}', 2, 11]
|
100
|
+
include_examples 'scan', '[a\P{digit}c]', 2 => [:nonproperty, :digit, '\P{digit}', 2, 11]
|
101
|
+
include_examples 'scan', '[a\p{^digit}c]', 2 => [:nonproperty, :digit, '\p{^digit}', 2, 12]
|
102
|
+
include_examples 'scan', '[a\P{^digit}c]', 2 => [:property, :digit, '\P{^digit}', 2, 12]
|
75
103
|
|
76
|
-
include_examples 'scan',
|
77
|
-
include_examples 'scan',
|
78
|
-
include_examples 'scan',
|
104
|
+
include_examples 'scan', '[a\p{ALPHA}c]', 2 => [:property, :alpha, '\p{ALPHA}', 2, 11]
|
105
|
+
include_examples 'scan', '[a\p{P}c]', 2 => [:property, :punctuation,'\p{P}', 2, 7]
|
106
|
+
include_examples 'scan', '[a\p{P}\P{P}c]', 3 => [:nonproperty, :punctuation,'\P{P}', 7, 12]
|
79
107
|
|
80
|
-
include_examples 'scan',
|
108
|
+
include_examples 'scan', '[\x20-\x27]',
|
81
109
|
1 => [:escape, :hex, '\x20', 1, 5],
|
82
110
|
2 => [:set, :range, '-', 5, 6],
|
83
111
|
3 => [:escape, :hex, '\x27', 6, 10]
|
84
112
|
|
85
|
-
include_examples 'scan',
|
113
|
+
include_examples 'scan', '[a-w&&[^c-g]z]',
|
86
114
|
5 => [:set, :open, '[', 6, 7],
|
87
115
|
6 => [:set, :negate, '^', 7, 8],
|
88
116
|
8 => [:set, :range, '-', 9, 10],
|
89
117
|
10=> [:set, :close, ']', 11, 12]
|
90
118
|
|
119
|
+
# Collations/collating sequences and character equivalents are not enabled
|
120
|
+
# in Ruby at the moment. If they ever are, enable them in the scanner,
|
121
|
+
# add them to a new syntax version, and handle them in the parser. Until then,
|
122
|
+
# expect them to be scanned as regular subsets containing literals.
|
123
|
+
# include_examples 'scan', /[a[.a-b.]c]/, 2 => [:set, :collation, '[.a-b.]', 2, 9]
|
124
|
+
# include_examples 'scan', /[a[=e=]c]/, 2 => [:set, :equivalent, '[=e=]', 2, 7]
|
125
|
+
include_examples 'scan', '[a[.a-b.]c]',
|
126
|
+
2 => [:set, :open, '[', 2, 3],
|
127
|
+
3 => [:literal, :literal, '.', 3, 4],
|
128
|
+
4 => [:literal, :literal, 'a', 4, 5]
|
129
|
+
include_examples 'scan', '[a[=e=]c]',
|
130
|
+
2 => [:set, :open, '[', 2, 3],
|
131
|
+
3 => [:literal, :literal, '=', 3, 4],
|
132
|
+
4 => [:literal, :literal, 'e', 4, 5]
|
133
|
+
|
91
134
|
# multi-byte characters should not affect indices
|
92
135
|
include_examples 'scan', /[れます]/,
|
93
136
|
0 => [:set, :open, '[', 0, 1],
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
$VERBOSE = true
|
2
|
+
|
1
3
|
require 'ice_nine'
|
2
|
-
require 'regexp_parser'
|
3
4
|
require 'regexp_property_values'
|
5
|
+
require_relative 'support/capturing_stderr'
|
4
6
|
require_relative 'support/shared_examples'
|
5
7
|
|
8
|
+
req_warn = capturing_stderr { require('regexp_parser') || fail('pre-required') }
|
9
|
+
req_warn.empty? || fail("requiring parser generated warnings:\n#{req_warn}")
|
10
|
+
|
6
11
|
RS = Regexp::Scanner
|
7
12
|
RL = Regexp::Lexer
|
8
13
|
RP = Regexp::Parser
|
@@ -14,3 +19,10 @@ include Regexp::Expression
|
|
14
19
|
def ruby_version_at_least(version)
|
15
20
|
Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new(version)
|
16
21
|
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.around(:example) do |example|
|
25
|
+
# treat unexpected warnings as failures
|
26
|
+
expect { example.run }.not_to output.to_stderr
|
27
|
+
end
|
28
|
+
end
|
@@ -4,14 +4,14 @@ RSpec.describe(Regexp::Syntax::V1_8_6) do
|
|
4
4
|
include_examples 'syntax', Regexp::Syntax.new('ruby/1.8.6'),
|
5
5
|
implements: {
|
6
6
|
assertion: T::Assertion::Lookahead,
|
7
|
-
backref:
|
7
|
+
backref: T::Backreference::Plain,
|
8
8
|
escape: T::Escape::Basic + T::Escape::ASCII + T::Escape::Meta + T::Escape::Control,
|
9
9
|
group: T::Group::V1_8_6,
|
10
10
|
quantifier: T::Quantifier::Greedy + T::Quantifier::Reluctant + T::Quantifier::Interval + T::Quantifier::IntervalReluctant
|
11
11
|
},
|
12
12
|
excludes: {
|
13
13
|
assertion: T::Assertion::Lookbehind,
|
14
|
-
backref: T::Backreference::All -
|
14
|
+
backref: T::Backreference::All - T::Backreference::Plain + T::SubexpressionCall::All,
|
15
15
|
quantifier: T::Quantifier::Possessive
|
16
16
|
}
|
17
17
|
end
|
@@ -28,6 +28,7 @@ RSpec.describe(Regexp::Syntax) do
|
|
28
28
|
include_examples 'syntax alias', 'ruby/2.6.2', Regexp::Syntax::V2_6_2
|
29
29
|
include_examples 'syntax alias', 'ruby/2.6.3', Regexp::Syntax::V2_6_3
|
30
30
|
include_examples 'syntax alias', 'ruby/2.6', Regexp::Syntax::V2_6_3
|
31
|
+
include_examples 'syntax alias', 'ruby/3.1', Regexp::Syntax::V3_1_0
|
31
32
|
|
32
33
|
specify('future alias warning') do
|
33
34
|
expect { Regexp::Syntax.new('ruby/5.0') }
|
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: 2.0
|
4
|
+
version: 2.2.0
|
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: 2021-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
|
14
14
|
email:
|
@@ -23,12 +23,17 @@ files:
|
|
23
23
|
- README.md
|
24
24
|
- Rakefile
|
25
25
|
- lib/regexp_parser.rb
|
26
|
+
- lib/regexp_parser/error.rb
|
26
27
|
- lib/regexp_parser/expression.rb
|
28
|
+
- lib/regexp_parser/expression/base.rb
|
27
29
|
- lib/regexp_parser/expression/classes/alternation.rb
|
28
30
|
- lib/regexp_parser/expression/classes/anchor.rb
|
29
|
-
- lib/regexp_parser/expression/classes/
|
31
|
+
- lib/regexp_parser/expression/classes/backreference.rb
|
32
|
+
- lib/regexp_parser/expression/classes/character_set.rb
|
33
|
+
- lib/regexp_parser/expression/classes/character_set/intersection.rb
|
34
|
+
- lib/regexp_parser/expression/classes/character_set/range.rb
|
30
35
|
- lib/regexp_parser/expression/classes/conditional.rb
|
31
|
-
- lib/regexp_parser/expression/classes/
|
36
|
+
- lib/regexp_parser/expression/classes/escape_sequence.rb
|
32
37
|
- lib/regexp_parser/expression/classes/free_space.rb
|
33
38
|
- lib/regexp_parser/expression/classes/group.rb
|
34
39
|
- lib/regexp_parser/expression/classes/keep.rb
|
@@ -36,9 +41,6 @@ files:
|
|
36
41
|
- lib/regexp_parser/expression/classes/posix_class.rb
|
37
42
|
- lib/regexp_parser/expression/classes/property.rb
|
38
43
|
- lib/regexp_parser/expression/classes/root.rb
|
39
|
-
- lib/regexp_parser/expression/classes/set.rb
|
40
|
-
- lib/regexp_parser/expression/classes/set/intersection.rb
|
41
|
-
- lib/regexp_parser/expression/classes/set/range.rb
|
42
44
|
- lib/regexp_parser/expression/classes/type.rb
|
43
45
|
- lib/regexp_parser/expression/methods/match.rb
|
44
46
|
- lib/regexp_parser/expression/methods/match_length.rb
|
@@ -61,20 +63,20 @@ files:
|
|
61
63
|
- lib/regexp_parser/syntax.rb
|
62
64
|
- lib/regexp_parser/syntax/any.rb
|
63
65
|
- lib/regexp_parser/syntax/base.rb
|
64
|
-
- lib/regexp_parser/syntax/
|
65
|
-
- lib/regexp_parser/syntax/
|
66
|
-
- lib/regexp_parser/syntax/
|
67
|
-
- lib/regexp_parser/syntax/
|
68
|
-
- lib/regexp_parser/syntax/
|
69
|
-
- lib/regexp_parser/syntax/
|
70
|
-
- lib/regexp_parser/syntax/
|
71
|
-
- lib/regexp_parser/syntax/
|
72
|
-
- lib/regexp_parser/syntax/
|
73
|
-
- lib/regexp_parser/syntax/
|
74
|
-
- lib/regexp_parser/syntax/
|
75
|
-
- lib/regexp_parser/syntax/
|
76
|
-
- lib/regexp_parser/syntax/
|
77
|
-
- lib/regexp_parser/syntax/
|
66
|
+
- lib/regexp_parser/syntax/token.rb
|
67
|
+
- lib/regexp_parser/syntax/token/anchor.rb
|
68
|
+
- lib/regexp_parser/syntax/token/assertion.rb
|
69
|
+
- lib/regexp_parser/syntax/token/backreference.rb
|
70
|
+
- lib/regexp_parser/syntax/token/character_set.rb
|
71
|
+
- lib/regexp_parser/syntax/token/character_type.rb
|
72
|
+
- lib/regexp_parser/syntax/token/conditional.rb
|
73
|
+
- lib/regexp_parser/syntax/token/escape.rb
|
74
|
+
- lib/regexp_parser/syntax/token/group.rb
|
75
|
+
- lib/regexp_parser/syntax/token/keep.rb
|
76
|
+
- lib/regexp_parser/syntax/token/meta.rb
|
77
|
+
- lib/regexp_parser/syntax/token/posix_class.rb
|
78
|
+
- lib/regexp_parser/syntax/token/quantifier.rb
|
79
|
+
- lib/regexp_parser/syntax/token/unicode_property.rb
|
78
80
|
- lib/regexp_parser/syntax/version_lookup.rb
|
79
81
|
- lib/regexp_parser/syntax/versions.rb
|
80
82
|
- lib/regexp_parser/syntax/versions/1.8.6.rb
|
@@ -89,6 +91,7 @@ files:
|
|
89
91
|
- lib/regexp_parser/syntax/versions/2.6.0.rb
|
90
92
|
- lib/regexp_parser/syntax/versions/2.6.2.rb
|
91
93
|
- lib/regexp_parser/syntax/versions/2.6.3.rb
|
94
|
+
- lib/regexp_parser/syntax/versions/3.1.0.rb
|
92
95
|
- lib/regexp_parser/token.rb
|
93
96
|
- lib/regexp_parser/version.rb
|
94
97
|
- regexp_parser.gemspec
|
@@ -149,9 +152,8 @@ files:
|
|
149
152
|
- spec/scanner/sets_spec.rb
|
150
153
|
- spec/scanner/types_spec.rb
|
151
154
|
- spec/spec_helper.rb
|
152
|
-
- spec/support/
|
155
|
+
- spec/support/capturing_stderr.rb
|
153
156
|
- spec/support/shared_examples.rb
|
154
|
-
- spec/support/warning_extractor.rb
|
155
157
|
- spec/syntax/syntax_spec.rb
|
156
158
|
- spec/syntax/syntax_token_map_spec.rb
|
157
159
|
- spec/syntax/versions/1.8.6_spec.rb
|
@@ -183,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
185
|
- !ruby/object:Gem::Version
|
184
186
|
version: '0'
|
185
187
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.3.0.dev
|
187
189
|
signing_key:
|
188
190
|
specification_version: 4
|
189
191
|
summary: Scanner, lexer, parser for ruby's regular expressions
|
@@ -245,9 +247,8 @@ test_files:
|
|
245
247
|
- spec/scanner/sets_spec.rb
|
246
248
|
- spec/scanner/types_spec.rb
|
247
249
|
- spec/spec_helper.rb
|
248
|
-
- spec/support/
|
250
|
+
- spec/support/capturing_stderr.rb
|
249
251
|
- spec/support/shared_examples.rb
|
250
|
-
- spec/support/warning_extractor.rb
|
251
252
|
- spec/syntax/syntax_spec.rb
|
252
253
|
- spec/syntax/syntax_token_map_spec.rb
|
253
254
|
- spec/syntax/versions/1.8.6_spec.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Regexp::Syntax
|
2
|
-
module Token
|
3
|
-
module Anchor
|
4
|
-
Basic = [:bol, :eol]
|
5
|
-
Extended = Basic + [:word_boundary, :nonword_boundary]
|
6
|
-
String = [:bos, :eos, :eos_ob_eol]
|
7
|
-
MatchStart = [:match_start]
|
8
|
-
|
9
|
-
All = Extended + String + MatchStart
|
10
|
-
Type = :anchor
|
11
|
-
end
|
12
|
-
|
13
|
-
Map[Anchor::Type] = Anchor::All
|
14
|
-
end
|
15
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Regexp::Syntax
|
2
|
-
module Token
|
3
|
-
module Escape
|
4
|
-
Basic = [:backslash, :literal]
|
5
|
-
|
6
|
-
Control = [:control, :meta_sequence]
|
7
|
-
|
8
|
-
ASCII = [:bell, :backspace, :escape, :form_feed, :newline, :carriage,
|
9
|
-
:tab, :vertical_tab]
|
10
|
-
|
11
|
-
Unicode = [:codepoint, :codepoint_list]
|
12
|
-
|
13
|
-
Meta = [:dot, :alternation,
|
14
|
-
:zero_or_one, :zero_or_more, :one_or_more,
|
15
|
-
:bol, :eol,
|
16
|
-
:group_open, :group_close,
|
17
|
-
:interval_open, :interval_close,
|
18
|
-
:set_open, :set_close]
|
19
|
-
|
20
|
-
Hex = [:hex]
|
21
|
-
|
22
|
-
Octal = [:octal]
|
23
|
-
|
24
|
-
All = Basic + Control + ASCII + Unicode + Meta + Hex + Octal
|
25
|
-
Type = :escape
|
26
|
-
end
|
27
|
-
|
28
|
-
Map[Escape::Type] = Escape::All
|
29
|
-
end
|
30
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Regexp::Syntax
|
2
|
-
module Token
|
3
|
-
module Quantifier
|
4
|
-
Greedy = [
|
5
|
-
:zero_or_one,
|
6
|
-
:zero_or_more,
|
7
|
-
:one_or_more
|
8
|
-
]
|
9
|
-
|
10
|
-
Reluctant = [
|
11
|
-
:zero_or_one_reluctant,
|
12
|
-
:zero_or_more_reluctant,
|
13
|
-
:one_or_more_reluctant
|
14
|
-
]
|
15
|
-
|
16
|
-
Possessive = [
|
17
|
-
:zero_or_one_possessive,
|
18
|
-
:zero_or_more_possessive,
|
19
|
-
:one_or_more_possessive
|
20
|
-
]
|
21
|
-
|
22
|
-
Interval = [:interval]
|
23
|
-
IntervalReluctant = [:interval_reluctant]
|
24
|
-
IntervalPossessive = [:interval_possessive]
|
25
|
-
|
26
|
-
IntervalAll = Interval + IntervalReluctant +
|
27
|
-
IntervalPossessive
|
28
|
-
|
29
|
-
All = Greedy + Reluctant + Possessive + IntervalAll
|
30
|
-
Type = :quantifier
|
31
|
-
end
|
32
|
-
|
33
|
-
Map[Quantifier::Type] = Quantifier::All
|
34
|
-
end
|
35
|
-
end
|