regexp_parser 2.6.2 → 2.8.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +67 -0
  3. data/Gemfile +2 -2
  4. data/README.md +32 -29
  5. data/lib/regexp_parser/expression/base.rb +0 -7
  6. data/lib/regexp_parser/expression/classes/alternation.rb +1 -1
  7. data/lib/regexp_parser/expression/classes/backreference.rb +4 -2
  8. data/lib/regexp_parser/expression/classes/character_set/range.rb +2 -7
  9. data/lib/regexp_parser/expression/classes/character_set.rb +3 -4
  10. data/lib/regexp_parser/expression/classes/conditional.rb +2 -6
  11. data/lib/regexp_parser/expression/classes/escape_sequence.rb +3 -1
  12. data/lib/regexp_parser/expression/classes/free_space.rb +3 -1
  13. data/lib/regexp_parser/expression/classes/group.rb +0 -22
  14. data/lib/regexp_parser/expression/classes/posix_class.rb +5 -1
  15. data/lib/regexp_parser/expression/classes/unicode_property.rb +5 -2
  16. data/lib/regexp_parser/expression/methods/construct.rb +2 -4
  17. data/lib/regexp_parser/expression/methods/parts.rb +23 -0
  18. data/lib/regexp_parser/expression/methods/printing.rb +26 -0
  19. data/lib/regexp_parser/expression/methods/tests.rb +40 -3
  20. data/lib/regexp_parser/expression/methods/traverse.rb +35 -19
  21. data/lib/regexp_parser/expression/quantifier.rb +30 -17
  22. data/lib/regexp_parser/expression/sequence.rb +5 -10
  23. data/lib/regexp_parser/expression/sequence_operation.rb +4 -9
  24. data/lib/regexp_parser/expression/shared.rb +37 -20
  25. data/lib/regexp_parser/expression/subexpression.rb +20 -15
  26. data/lib/regexp_parser/expression.rb +2 -0
  27. data/lib/regexp_parser/lexer.rb +76 -36
  28. data/lib/regexp_parser/parser.rb +97 -97
  29. data/lib/regexp_parser/scanner/errors/premature_end_error.rb +8 -0
  30. data/lib/regexp_parser/scanner/errors/scanner_error.rb +6 -0
  31. data/lib/regexp_parser/scanner/errors/validation_error.rb +63 -0
  32. data/lib/regexp_parser/scanner/mapping.rb +89 -0
  33. data/lib/regexp_parser/scanner/property.rl +2 -2
  34. data/lib/regexp_parser/scanner/scanner.rl +90 -169
  35. data/lib/regexp_parser/scanner.rb +1157 -1330
  36. data/lib/regexp_parser/syntax/token/backreference.rb +3 -0
  37. data/lib/regexp_parser/syntax/token/character_set.rb +3 -0
  38. data/lib/regexp_parser/syntax/token/escape.rb +3 -1
  39. data/lib/regexp_parser/syntax/token/meta.rb +9 -2
  40. data/lib/regexp_parser/syntax/token/unicode_property.rb +3 -0
  41. data/lib/regexp_parser/syntax/token/virtual.rb +11 -0
  42. data/lib/regexp_parser/syntax/version_lookup.rb +0 -8
  43. data/lib/regexp_parser/syntax/versions.rb +2 -0
  44. data/lib/regexp_parser/version.rb +1 -1
  45. metadata +10 -3
@@ -26,5 +26,8 @@ module Regexp::Syntax
26
26
 
27
27
  Map[Backreference::Type] = Backreference::All +
28
28
  SubexpressionCall::All
29
+
30
+ # alias for symmetry between token symbol and Expression class name
31
+ Backref = Backreference
29
32
  end
30
33
  end
@@ -9,5 +9,8 @@ module Regexp::Syntax
9
9
  end
10
10
 
11
11
  Map[CharacterSet::Type] = CharacterSet::All
12
+
13
+ # alias for symmetry between token symbol and Token module name
14
+ Set = CharacterSet
12
15
  end
13
16
  end
@@ -1,6 +1,5 @@
1
1
  module Regexp::Syntax
2
2
  module Token
3
- # TODO: unify naming with RE::EscapeSequence, one way or the other, in v3.0.0
4
3
  module Escape
5
4
  Basic = %i[backslash literal]
6
5
 
@@ -27,5 +26,8 @@ module Regexp::Syntax
27
26
  end
28
27
 
29
28
  Map[Escape::Type] = Escape::All
29
+
30
+ # alias for symmetry between Token::* and Expression::*
31
+ EscapeSequence = Escape
30
32
  end
31
33
  end
@@ -1,13 +1,20 @@
1
1
  module Regexp::Syntax
2
2
  module Token
3
3
  module Meta
4
- Basic = %i[dot]
5
- Extended = Basic + %i[alternation]
4
+ Basic = %i[dot]
5
+ Alternation = %i[alternation]
6
+ Extended = Basic + Alternation
6
7
 
7
8
  All = Extended
8
9
  Type = :meta
9
10
  end
10
11
 
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
12
19
  end
13
20
  end
@@ -713,5 +713,8 @@ module Regexp::Syntax
713
713
 
714
714
  Map[UnicodeProperty::Type] = UnicodeProperty::All
715
715
  Map[UnicodeProperty::NonType] = UnicodeProperty::All
716
+
717
+ # alias for symmetry between token symbol and Token module name
718
+ Property = UnicodeProperty
716
719
  end
717
720
  end
@@ -0,0 +1,11 @@
1
+ module Regexp::Syntax
2
+ module Token
3
+ module Virtual
4
+ Root = %i[root]
5
+ Sequence = %i[sequence]
6
+
7
+ All = %i[root sequence]
8
+ Type = :expression
9
+ end
10
+ end
11
+ end
@@ -37,7 +37,6 @@ module Regexp::Syntax
37
37
  return Regexp::Syntax::Any if ['*', 'any'].include?(version.to_s)
38
38
 
39
39
  version =~ VERSION_REGEXP || raise(InvalidVersionNameError, version)
40
- warn_if_future_version(version)
41
40
  version_const_name = "V#{version.to_s.scan(/\d+/).join('_')}"
42
41
  const_get(version_const_name) || raise(UnknownSyntaxNameError, version)
43
42
  end
@@ -63,11 +62,4 @@ module Regexp::Syntax
63
62
  # add .99 to treat versions without a patch value as latest patch version
64
63
  Gem::Version.new((name.to_s.scan(/\d+/) << 99).join('.'))
65
64
  end
66
-
67
- def warn_if_future_version(const_name)
68
- return if comparable(const_name) < comparable('4.0.0')
69
-
70
- warn('This library has only been tested up to Ruby 3.x, '\
71
- "but you are running with #{const_name}")
72
- end
73
65
  end
@@ -4,3 +4,5 @@
4
4
  # Aliases for the latest patch version are provided as 'ruby/n.n',
5
5
  # e.g. 'ruby/1.9' refers to Ruby v1.9.3.
6
6
  Dir[File.expand_path('../versions/*.rb', __FILE__)].sort.each { |f| require f }
7
+
8
+ Regexp::Syntax::CURRENT = Regexp::Syntax.for("ruby/#{RUBY_VERSION}")
@@ -1,5 +1,5 @@
1
1
  class Regexp
2
2
  class Parser
3
- VERSION = '2.6.2'
3
+ VERSION = '2.8.0'
4
4
  end
5
5
  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: 2.6.2
4
+ version: 2.8.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: 2023-01-19 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
14
14
  email:
@@ -47,6 +47,8 @@ files:
47
47
  - lib/regexp_parser/expression/methods/match.rb
48
48
  - lib/regexp_parser/expression/methods/match_length.rb
49
49
  - lib/regexp_parser/expression/methods/options.rb
50
+ - lib/regexp_parser/expression/methods/parts.rb
51
+ - lib/regexp_parser/expression/methods/printing.rb
50
52
  - lib/regexp_parser/expression/methods/strfregexp.rb
51
53
  - lib/regexp_parser/expression/methods/tests.rb
52
54
  - lib/regexp_parser/expression/methods/traverse.rb
@@ -59,6 +61,10 @@ files:
59
61
  - lib/regexp_parser/parser.rb
60
62
  - lib/regexp_parser/scanner.rb
61
63
  - lib/regexp_parser/scanner/char_type.rl
64
+ - lib/regexp_parser/scanner/errors/premature_end_error.rb
65
+ - lib/regexp_parser/scanner/errors/scanner_error.rb
66
+ - lib/regexp_parser/scanner/errors/validation_error.rb
67
+ - lib/regexp_parser/scanner/mapping.rb
62
68
  - lib/regexp_parser/scanner/properties/long.csv
63
69
  - lib/regexp_parser/scanner/properties/short.csv
64
70
  - lib/regexp_parser/scanner/property.rl
@@ -80,6 +86,7 @@ files:
80
86
  - lib/regexp_parser/syntax/token/posix_class.rb
81
87
  - lib/regexp_parser/syntax/token/quantifier.rb
82
88
  - lib/regexp_parser/syntax/token/unicode_property.rb
89
+ - lib/regexp_parser/syntax/token/virtual.rb
83
90
  - lib/regexp_parser/syntax/version_lookup.rb
84
91
  - lib/regexp_parser/syntax/versions.rb
85
92
  - lib/regexp_parser/syntax/versions/1.8.6.rb
@@ -125,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
132
  - !ruby/object:Gem::Version
126
133
  version: '0'
127
134
  requirements: []
128
- rubygems_version: 3.3.3
135
+ rubygems_version: 3.4.1
129
136
  signing_key:
130
137
  specification_version: 4
131
138
  summary: Scanner, lexer, parser for ruby's regular expressions