regexp_parser 1.7.0 → 2.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -2
- data/LICENSE +1 -1
- data/Rakefile +6 -70
- data/lib/regexp_parser/error.rb +4 -0
- data/lib/regexp_parser/expression/base.rb +76 -0
- data/lib/regexp_parser/expression/classes/alternation.rb +1 -1
- data/lib/regexp_parser/expression/classes/anchor.rb +0 -2
- data/lib/regexp_parser/expression/classes/{backref.rb → backreference.rb} +22 -2
- data/lib/regexp_parser/expression/classes/{set → character_set}/range.rb +4 -8
- data/lib/regexp_parser/expression/classes/{set.rb → character_set.rb} +3 -4
- data/lib/regexp_parser/expression/classes/{type.rb → character_type.rb} +0 -2
- data/lib/regexp_parser/expression/classes/conditional.rb +11 -5
- data/lib/regexp_parser/expression/classes/{escape.rb → escape_sequence.rb} +15 -7
- data/lib/regexp_parser/expression/classes/free_space.rb +5 -5
- data/lib/regexp_parser/expression/classes/group.rb +28 -15
- data/lib/regexp_parser/expression/classes/keep.rb +2 -0
- data/lib/regexp_parser/expression/classes/literal.rb +1 -5
- data/lib/regexp_parser/expression/classes/posix_class.rb +5 -1
- data/lib/regexp_parser/expression/classes/root.rb +4 -19
- data/lib/regexp_parser/expression/classes/{property.rb → unicode_property.rb} +5 -3
- data/lib/regexp_parser/expression/methods/construct.rb +41 -0
- data/lib/regexp_parser/expression/methods/human_name.rb +43 -0
- data/lib/regexp_parser/expression/methods/match_length.rb +11 -7
- data/lib/regexp_parser/expression/methods/parts.rb +23 -0
- data/lib/regexp_parser/expression/methods/printing.rb +26 -0
- data/lib/regexp_parser/expression/methods/strfregexp.rb +1 -1
- data/lib/regexp_parser/expression/methods/tests.rb +47 -1
- data/lib/regexp_parser/expression/methods/traverse.rb +34 -18
- data/lib/regexp_parser/expression/quantifier.rb +57 -17
- data/lib/regexp_parser/expression/sequence.rb +11 -47
- data/lib/regexp_parser/expression/sequence_operation.rb +4 -9
- data/lib/regexp_parser/expression/shared.rb +111 -0
- data/lib/regexp_parser/expression/subexpression.rb +27 -19
- data/lib/regexp_parser/expression.rb +14 -141
- data/lib/regexp_parser/lexer.rb +83 -41
- data/lib/regexp_parser/parser.rb +371 -429
- data/lib/regexp_parser/scanner/char_type.rl +11 -11
- data/lib/regexp_parser/scanner/errors/premature_end_error.rb +8 -0
- data/lib/regexp_parser/scanner/errors/scanner_error.rb +6 -0
- data/lib/regexp_parser/scanner/errors/validation_error.rb +63 -0
- data/lib/regexp_parser/scanner/properties/long.csv +633 -0
- data/lib/regexp_parser/scanner/properties/short.csv +248 -0
- data/lib/regexp_parser/scanner/property.rl +4 -4
- data/lib/regexp_parser/scanner/scanner.rl +303 -368
- data/lib/regexp_parser/scanner.rb +1423 -1674
- data/lib/regexp_parser/syntax/any.rb +2 -7
- data/lib/regexp_parser/syntax/base.rb +92 -67
- 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/token/backreference.rb +33 -0
- data/lib/regexp_parser/syntax/token/character_set.rb +16 -0
- 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 +33 -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/token/meta.rb +20 -0
- 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 +733 -0
- data/lib/regexp_parser/syntax/token/virtual.rb +11 -0
- data/lib/regexp_parser/syntax/token.rb +45 -0
- data/lib/regexp_parser/syntax/version_lookup.rb +19 -36
- data/lib/regexp_parser/syntax/versions/1.8.6.rb +13 -20
- data/lib/regexp_parser/syntax/versions/1.9.1.rb +10 -17
- data/lib/regexp_parser/syntax/versions/1.9.3.rb +3 -10
- data/lib/regexp_parser/syntax/versions/2.0.0.rb +8 -15
- data/lib/regexp_parser/syntax/versions/2.2.0.rb +3 -9
- data/lib/regexp_parser/syntax/versions/2.3.0.rb +3 -9
- data/lib/regexp_parser/syntax/versions/2.4.0.rb +3 -9
- data/lib/regexp_parser/syntax/versions/2.4.1.rb +2 -8
- data/lib/regexp_parser/syntax/versions/2.5.0.rb +3 -9
- data/lib/regexp_parser/syntax/versions/2.6.0.rb +3 -9
- data/lib/regexp_parser/syntax/versions/2.6.2.rb +3 -9
- data/lib/regexp_parser/syntax/versions/2.6.3.rb +3 -9
- data/lib/regexp_parser/syntax/versions/3.1.0.rb +4 -0
- data/lib/regexp_parser/syntax/versions/3.2.0.rb +4 -0
- data/lib/regexp_parser/syntax/versions.rb +3 -1
- 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/regexp_parser.gemspec +19 -23
- metadata +52 -171
- data/CHANGELOG.md +0 -349
- data/README.md +0 -470
- data/lib/regexp_parser/scanner/properties/long.yml +0 -594
- data/lib/regexp_parser/scanner/properties/short.yml +0 -237
- data/lib/regexp_parser/syntax/tokens/anchor.rb +0 -15
- data/lib/regexp_parser/syntax/tokens/backref.rb +0 -24
- data/lib/regexp_parser/syntax/tokens/character_set.rb +0 -13
- data/lib/regexp_parser/syntax/tokens/escape.rb +0 -30
- data/lib/regexp_parser/syntax/tokens/meta.rb +0 -13
- 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/expression/base_spec.rb +0 -94
- data/spec/expression/clone_spec.rb +0 -120
- data/spec/expression/conditional_spec.rb +0 -89
- data/spec/expression/free_space_spec.rb +0 -27
- data/spec/expression/methods/match_length_spec.rb +0 -161
- data/spec/expression/methods/match_spec.rb +0 -25
- data/spec/expression/methods/strfregexp_spec.rb +0 -224
- data/spec/expression/methods/tests_spec.rb +0 -99
- data/spec/expression/methods/traverse_spec.rb +0 -161
- data/spec/expression/options_spec.rb +0 -128
- data/spec/expression/root_spec.rb +0 -9
- data/spec/expression/sequence_spec.rb +0 -9
- data/spec/expression/subexpression_spec.rb +0 -50
- data/spec/expression/to_h_spec.rb +0 -26
- data/spec/expression/to_s_spec.rb +0 -100
- data/spec/lexer/all_spec.rb +0 -22
- data/spec/lexer/conditionals_spec.rb +0 -53
- data/spec/lexer/escapes_spec.rb +0 -14
- data/spec/lexer/keep_spec.rb +0 -10
- data/spec/lexer/literals_spec.rb +0 -89
- data/spec/lexer/nesting_spec.rb +0 -99
- data/spec/lexer/refcalls_spec.rb +0 -55
- data/spec/parser/all_spec.rb +0 -43
- data/spec/parser/alternation_spec.rb +0 -88
- data/spec/parser/anchors_spec.rb +0 -17
- data/spec/parser/conditionals_spec.rb +0 -179
- data/spec/parser/errors_spec.rb +0 -30
- data/spec/parser/escapes_spec.rb +0 -121
- data/spec/parser/free_space_spec.rb +0 -130
- data/spec/parser/groups_spec.rb +0 -108
- data/spec/parser/keep_spec.rb +0 -6
- data/spec/parser/posix_classes_spec.rb +0 -8
- data/spec/parser/properties_spec.rb +0 -115
- data/spec/parser/quantifiers_spec.rb +0 -51
- data/spec/parser/refcalls_spec.rb +0 -112
- data/spec/parser/set/intersections_spec.rb +0 -127
- data/spec/parser/set/ranges_spec.rb +0 -111
- data/spec/parser/sets_spec.rb +0 -178
- data/spec/parser/types_spec.rb +0 -18
- data/spec/scanner/all_spec.rb +0 -18
- data/spec/scanner/anchors_spec.rb +0 -21
- data/spec/scanner/conditionals_spec.rb +0 -128
- data/spec/scanner/errors_spec.rb +0 -68
- data/spec/scanner/escapes_spec.rb +0 -53
- data/spec/scanner/free_space_spec.rb +0 -133
- data/spec/scanner/groups_spec.rb +0 -52
- data/spec/scanner/keep_spec.rb +0 -10
- data/spec/scanner/literals_spec.rb +0 -49
- data/spec/scanner/meta_spec.rb +0 -18
- data/spec/scanner/properties_spec.rb +0 -64
- data/spec/scanner/quantifiers_spec.rb +0 -20
- data/spec/scanner/refcalls_spec.rb +0 -36
- data/spec/scanner/sets_spec.rb +0 -102
- data/spec/scanner/types_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -15
- data/spec/support/runner.rb +0 -42
- data/spec/support/shared_examples.rb +0 -77
- data/spec/support/warning_extractor.rb +0 -60
- data/spec/syntax/syntax_spec.rb +0 -48
- data/spec/syntax/syntax_token_map_spec.rb +0 -23
- data/spec/syntax/versions/1.8.6_spec.rb +0 -17
- data/spec/syntax/versions/1.9.1_spec.rb +0 -10
- data/spec/syntax/versions/1.9.3_spec.rb +0 -9
- data/spec/syntax/versions/2.0.0_spec.rb +0 -13
- data/spec/syntax/versions/2.2.0_spec.rb +0 -9
- data/spec/syntax/versions/aliases_spec.rb +0 -37
- data/spec/token/token_spec.rb +0 -85
- /data/lib/regexp_parser/expression/classes/{set → character_set}/intersection.rb +0 -0
@@ -1,15 +1,10 @@
|
|
1
1
|
module Regexp::Syntax
|
2
|
-
|
3
2
|
# A syntax that always returns true, passing all tokens as implemented. This
|
4
3
|
# is useful during development, testing, and should be useful for some types
|
5
4
|
# of transformations as well.
|
6
5
|
class Any < Base
|
7
|
-
|
8
|
-
@implements = { :* => [:*] }
|
9
|
-
end
|
6
|
+
implements :*, [:*]
|
10
7
|
|
11
|
-
def implements?(
|
12
|
-
def implements!(type, token) true end
|
8
|
+
def self.implements?(_type, _token) true end
|
13
9
|
end
|
14
|
-
|
15
10
|
end
|
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
1
|
module Regexp::Syntax
|
4
|
-
class NotImplementedError < SyntaxError
|
2
|
+
class NotImplementedError < Regexp::Syntax::SyntaxError
|
5
3
|
def initialize(syntax, type, token)
|
6
|
-
super "#{syntax
|
4
|
+
super "#{syntax} does not implement: [#{type}:#{token}]"
|
7
5
|
end
|
8
6
|
end
|
9
7
|
|
@@ -11,85 +9,112 @@ module Regexp::Syntax
|
|
11
9
|
class Base
|
12
10
|
include Regexp::Syntax::Token
|
13
11
|
|
14
|
-
|
15
|
-
|
12
|
+
class << self
|
13
|
+
attr_accessor :features
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
# automatically inherit features through the syntax class hierarchy
|
16
|
+
def inherited(subclass)
|
17
|
+
super
|
18
|
+
subclass.features = features.to_h.map { |k, v| [k, v.dup] }.to_h
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def implements(type, tokens)
|
22
|
+
(features[type] ||= []).concat(tokens)
|
23
|
+
added_features[type] = tokens
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def excludes(type, tokens)
|
27
|
+
tokens.each { |tok| features[type].delete(tok) }
|
28
|
+
removed_features[type] = tokens
|
29
|
+
end
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
def implements?(type, token)
|
32
|
+
implementations(type).include?(token)
|
33
|
+
end
|
34
|
+
alias :check? :implements?
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
def implementations(type)
|
37
|
+
features[type] || []
|
38
|
+
end
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
40
|
+
def implements!(type, token)
|
41
|
+
raise NotImplementedError.new(self, type, token) unless
|
42
|
+
implements?(type, token)
|
43
|
+
end
|
44
|
+
alias :check! :implements!
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
implements?(type, token)
|
45
|
-
end
|
46
|
-
alias :check! :implements!
|
47
|
-
|
48
|
-
def normalize(type, token)
|
49
|
-
case type
|
50
|
-
when :group
|
51
|
-
normalize_group(type, token)
|
52
|
-
when :backref
|
53
|
-
normalize_backref(type, token)
|
54
|
-
else
|
55
|
-
[type, token]
|
46
|
+
def added_features
|
47
|
+
@added_features ||= {}
|
56
48
|
end
|
57
|
-
end
|
58
49
|
|
59
|
-
|
60
|
-
|
61
|
-
when :named_ab, :named_sq
|
62
|
-
[:group, :named]
|
63
|
-
else
|
64
|
-
[type, token]
|
50
|
+
def removed_features
|
51
|
+
@removed_features ||= {}
|
65
52
|
end
|
53
|
+
|
54
|
+
def normalize(type, token)
|
55
|
+
case type
|
56
|
+
when :group
|
57
|
+
normalize_group(type, token)
|
58
|
+
when :backref
|
59
|
+
normalize_backref(type, token)
|
60
|
+
else
|
61
|
+
[type, token]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def normalize_group(type, token)
|
66
|
+
case token
|
67
|
+
when :named_ab, :named_sq
|
68
|
+
%i[group named]
|
69
|
+
else
|
70
|
+
[type, token]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def normalize_backref(type, token)
|
75
|
+
case token
|
76
|
+
when :name_ref_ab, :name_ref_sq
|
77
|
+
%i[backref name_ref]
|
78
|
+
when :name_call_ab, :name_call_sq
|
79
|
+
%i[backref name_call]
|
80
|
+
when :name_recursion_ref_ab, :name_recursion_ref_sq
|
81
|
+
%i[backref name_recursion_ref]
|
82
|
+
when :number_ref_ab, :number_ref_sq
|
83
|
+
%i[backref number_ref]
|
84
|
+
when :number_call_ab, :number_call_sq
|
85
|
+
%i[backref number_call]
|
86
|
+
when :number_rel_ref_ab, :number_rel_ref_sq
|
87
|
+
%i[backref number_rel_ref]
|
88
|
+
when :number_rel_call_ab, :number_rel_call_sq
|
89
|
+
%i[backref number_rel_call]
|
90
|
+
when :number_recursion_ref_ab, :number_recursion_ref_sq
|
91
|
+
%i[backref number_recursion_ref]
|
92
|
+
else
|
93
|
+
[type, token]
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# TODO: drop this backwards compatibility code in v3.0.0, do `private :new`
|
99
|
+
def initialize
|
100
|
+
warn 'Using instances of Regexp::Parser::Syntax is deprecated ' \
|
101
|
+
"and will no longer be supported in v3.0.0."
|
66
102
|
end
|
67
103
|
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
when :name_recursion_ref_ab, :name_recursion_ref_sq
|
75
|
-
[:backref, :name_recursion_ref]
|
76
|
-
when :number_ref_ab, :number_ref_sq
|
77
|
-
[:backref, :number_ref]
|
78
|
-
when :number_call_ab, :number_call_sq
|
79
|
-
[:backref, :number_call]
|
80
|
-
when :number_rel_ref_ab, :number_rel_ref_sq
|
81
|
-
[:backref, :number_rel_ref]
|
82
|
-
when :number_rel_call_ab, :number_rel_call_sq
|
83
|
-
[:backref, :number_rel_call]
|
84
|
-
when :number_recursion_ref_ab, :number_recursion_ref_sq
|
85
|
-
[:backref, :number_recursion_ref]
|
104
|
+
def method_missing(name, *args)
|
105
|
+
if self.class.respond_to?(name)
|
106
|
+
warn 'Using instances of Regexp::Parser::Syntax is deprecated ' \
|
107
|
+
"and will no longer be supported in v3.0.0. Please call "\
|
108
|
+
"methods on the class directly, e.g.: #{self.class}.#{name}"
|
109
|
+
self.class.send(name, *args)
|
86
110
|
else
|
87
|
-
|
111
|
+
super
|
88
112
|
end
|
89
113
|
end
|
90
114
|
|
91
|
-
def
|
92
|
-
|
115
|
+
def respond_to_missing?(name, include_private = false)
|
116
|
+
self.class.respond_to?(name) || super
|
93
117
|
end
|
118
|
+
# end of backwards compatibility code
|
94
119
|
end
|
95
120
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
module Token
|
3
|
+
module Anchor
|
4
|
+
Basic = %i[bol eol]
|
5
|
+
Extended = Basic + %i[word_boundary nonword_boundary]
|
6
|
+
String = %i[bos eos eos_ob_eol]
|
7
|
+
MatchStart = %i[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,8 +1,8 @@
|
|
1
1
|
module Regexp::Syntax
|
2
2
|
module Token
|
3
3
|
module Assertion
|
4
|
-
Lookahead = [
|
5
|
-
Lookbehind = [
|
4
|
+
Lookahead = %i[lookahead nlookahead]
|
5
|
+
Lookbehind = %i[lookbehind nlookbehind]
|
6
6
|
|
7
7
|
All = Lookahead + Lookbehind
|
8
8
|
Type = :assertion
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
module Token
|
3
|
+
module Backreference
|
4
|
+
Plain = %i[number]
|
5
|
+
NumberRef = %i[number_ref number_rel_ref]
|
6
|
+
Number = Plain + NumberRef
|
7
|
+
Name = %i[name_ref]
|
8
|
+
|
9
|
+
RecursionLevel = %i[name_recursion_ref number_recursion_ref]
|
10
|
+
|
11
|
+
V1_8_6 = Plain
|
12
|
+
|
13
|
+
V1_9_1 = Name + NumberRef + RecursionLevel
|
14
|
+
|
15
|
+
All = V1_8_6 + V1_9_1
|
16
|
+
Type = :backref
|
17
|
+
end
|
18
|
+
|
19
|
+
# Type is the same as Backreference so keeping it here, for now.
|
20
|
+
module SubexpressionCall
|
21
|
+
Name = %i[name_call]
|
22
|
+
Number = %i[number_call number_rel_call]
|
23
|
+
|
24
|
+
All = Name + Number
|
25
|
+
end
|
26
|
+
|
27
|
+
Map[Backreference::Type] = Backreference::All +
|
28
|
+
SubexpressionCall::All
|
29
|
+
|
30
|
+
# alias for symmetry between token symbol and Expression class name
|
31
|
+
Backref = Backreference
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
module Token
|
3
|
+
module CharacterSet
|
4
|
+
Basic = %i[open close negate range]
|
5
|
+
Extended = Basic + %i[intersection]
|
6
|
+
|
7
|
+
All = Extended
|
8
|
+
Type = :set
|
9
|
+
end
|
10
|
+
|
11
|
+
Map[CharacterSet::Type] = CharacterSet::All
|
12
|
+
|
13
|
+
# alias for symmetry between token symbol and Token module name
|
14
|
+
Set = CharacterSet
|
15
|
+
end
|
16
|
+
end
|
@@ -2,10 +2,10 @@ module Regexp::Syntax
|
|
2
2
|
module Token
|
3
3
|
module CharacterType
|
4
4
|
Basic = []
|
5
|
-
Extended = [
|
6
|
-
Hex = [
|
5
|
+
Extended = %i[digit nondigit space nonspace word nonword]
|
6
|
+
Hex = %i[hex nonhex]
|
7
7
|
|
8
|
-
Clustered = [
|
8
|
+
Clustered = %i[linebreak xgrapheme]
|
9
9
|
|
10
10
|
All = Basic + Extended + Hex + Clustered
|
11
11
|
Type = :type
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Regexp::Syntax
|
2
2
|
module Token
|
3
3
|
module Conditional
|
4
|
-
Delimiters = [
|
4
|
+
Delimiters = %i[open close]
|
5
5
|
|
6
|
-
Condition = [
|
7
|
-
Separator = [
|
6
|
+
Condition = %i[condition_open condition condition_close]
|
7
|
+
Separator = %i[separator]
|
8
8
|
|
9
9
|
All = Conditional::Delimiters + Conditional::Condition + Conditional::Separator
|
10
10
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
module Token
|
3
|
+
module Escape
|
4
|
+
Basic = %i[backslash literal]
|
5
|
+
|
6
|
+
Control = %i[control meta_sequence]
|
7
|
+
|
8
|
+
ASCII = %i[bell backspace escape form_feed newline carriage
|
9
|
+
tab vertical_tab]
|
10
|
+
|
11
|
+
Unicode = %i[codepoint codepoint_list]
|
12
|
+
|
13
|
+
Meta = %i[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 = %i[hex]
|
21
|
+
|
22
|
+
Octal = %i[octal]
|
23
|
+
|
24
|
+
All = Basic + Control + ASCII + Unicode + Meta + Hex + Octal
|
25
|
+
Type = :escape
|
26
|
+
end
|
27
|
+
|
28
|
+
Map[Escape::Type] = Escape::All
|
29
|
+
|
30
|
+
# alias for symmetry between Token::* and Expression::*
|
31
|
+
EscapeSequence = Escape
|
32
|
+
end
|
33
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Regexp::Syntax
|
2
2
|
module Token
|
3
3
|
module Group
|
4
|
-
Basic = [
|
5
|
-
Extended = Basic + [
|
4
|
+
Basic = %i[capture close]
|
5
|
+
Extended = Basic + %i[options options_switch]
|
6
6
|
|
7
|
-
Named = [
|
8
|
-
Atomic = [
|
9
|
-
Passive = [
|
10
|
-
Comment = [
|
7
|
+
Named = %i[named]
|
8
|
+
Atomic = %i[atomic]
|
9
|
+
Passive = %i[passive]
|
10
|
+
Comment = %i[comment]
|
11
11
|
|
12
12
|
V1_8_6 = Group::Extended + Group::Named + Group::Atomic +
|
13
13
|
Group::Passive + Group::Comment
|
14
14
|
|
15
|
-
V2_4_1 = [
|
15
|
+
V2_4_1 = %i[absence]
|
16
16
|
|
17
17
|
All = V1_8_6 + V2_4_1
|
18
18
|
Type = :group
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
module Token
|
3
|
+
module Meta
|
4
|
+
Basic = %i[dot]
|
5
|
+
Alternation = %i[alternation]
|
6
|
+
Extended = Basic + Alternation
|
7
|
+
|
8
|
+
All = Extended
|
9
|
+
Type = :meta
|
10
|
+
end
|
11
|
+
|
12
|
+
Map[Meta::Type] = Meta::All
|
13
|
+
|
14
|
+
# alias for symmetry between Token::* and Expression::*
|
15
|
+
module Alternation
|
16
|
+
All = Meta::Alternation
|
17
|
+
Type = Meta::Type
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Regexp::Syntax
|
2
2
|
module Token
|
3
3
|
module PosixClass
|
4
|
-
Standard = [
|
5
|
-
|
4
|
+
Standard = %i[alnum alpha blank cntrl digit graph
|
5
|
+
lower print punct space upper xdigit]
|
6
6
|
|
7
|
-
Extensions = [
|
7
|
+
Extensions = %i[ascii word]
|
8
8
|
|
9
9
|
All = Standard + Extensions
|
10
10
|
Type = :posixclass
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
module Token
|
3
|
+
module Quantifier
|
4
|
+
Greedy = %i[
|
5
|
+
zero_or_one
|
6
|
+
zero_or_more
|
7
|
+
one_or_more
|
8
|
+
]
|
9
|
+
|
10
|
+
Reluctant = %i[
|
11
|
+
zero_or_one_reluctant
|
12
|
+
zero_or_more_reluctant
|
13
|
+
one_or_more_reluctant
|
14
|
+
]
|
15
|
+
|
16
|
+
Possessive = %i[
|
17
|
+
zero_or_one_possessive
|
18
|
+
zero_or_more_possessive
|
19
|
+
one_or_more_possessive
|
20
|
+
]
|
21
|
+
|
22
|
+
Interval = %i[interval]
|
23
|
+
IntervalReluctant = %i[interval_reluctant]
|
24
|
+
IntervalPossessive = %i[interval_possessive]
|
25
|
+
|
26
|
+
IntervalAll = Interval + IntervalReluctant + IntervalPossessive
|
27
|
+
|
28
|
+
V1_8_6 = Greedy + Reluctant + Interval + IntervalReluctant
|
29
|
+
All = Greedy + Reluctant + Possessive + IntervalAll
|
30
|
+
Type = :quantifier
|
31
|
+
end
|
32
|
+
|
33
|
+
Map[Quantifier::Type] = Quantifier::All
|
34
|
+
end
|
35
|
+
end
|