regexp_parser 2.0.2 → 2.0.3
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.md +10 -0
- data/lib/regexp_parser/parser.rb +0 -2
- data/lib/regexp_parser/scanner.rb +612 -674
- data/lib/regexp_parser/scanner/scanner.rl +8 -8
- data/lib/regexp_parser/syntax.rb +4 -4
- data/lib/regexp_parser/syntax/base.rb +1 -1
- data/lib/regexp_parser/syntax/version_lookup.rb +2 -2
- data/lib/regexp_parser/version.rb +1 -1
- data/spec/scanner/sets_spec.rb +15 -3
- metadata +2 -2
@@ -37,7 +37,7 @@
|
|
37
37
|
class_posix = ('[:' . '^'? . class_name_posix . ':]');
|
38
38
|
|
39
39
|
|
40
|
-
# these are not supported in ruby
|
40
|
+
# these are not supported in ruby at the moment
|
41
41
|
collating_sequence = '[.' . (alpha | [\-])+ . '.]';
|
42
42
|
character_equivalent = '[=' . alpha . '=]';
|
43
43
|
|
@@ -228,13 +228,13 @@
|
|
228
228
|
emit(type, class_name.to_sym, text)
|
229
229
|
};
|
230
230
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
character_equivalent >(open_bracket, 1) @set_closed @eof(premature_end_error) {
|
236
|
-
|
237
|
-
};
|
231
|
+
# These are not supported in ruby at the moment. Enable them if they are.
|
232
|
+
# collating_sequence >(open_bracket, 1) @set_closed @eof(premature_end_error) {
|
233
|
+
# emit(:set, :collation, copy(data, ts, te))
|
234
|
+
# };
|
235
|
+
# character_equivalent >(open_bracket, 1) @set_closed @eof(premature_end_error) {
|
236
|
+
# emit(:set, :equivalent, copy(data, ts, te))
|
237
|
+
# };
|
238
238
|
|
239
239
|
meta_char > (set_meta, 1) {
|
240
240
|
emit(:literal, :literal, copy(data, ts, te))
|
data/lib/regexp_parser/syntax.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
module Regexp::Syntax
|
2
|
+
class SyntaxError < StandardError; end
|
3
|
+
end
|
4
|
+
|
1
5
|
require File.expand_path('../syntax/tokens', __FILE__)
|
2
6
|
require File.expand_path('../syntax/base', __FILE__)
|
3
7
|
require File.expand_path('../syntax/any', __FILE__)
|
4
8
|
require File.expand_path('../syntax/version_lookup', __FILE__)
|
5
9
|
require File.expand_path('../syntax/versions', __FILE__)
|
6
|
-
|
7
|
-
module Regexp::Syntax
|
8
|
-
class SyntaxError < StandardError; end
|
9
|
-
end
|
@@ -3,13 +3,13 @@ module Regexp::Syntax
|
|
3
3
|
VERSION_REGEXP = /#{VERSION_FORMAT}/
|
4
4
|
VERSION_CONST_REGEXP = /\AV\d+_\d+(?:_\d+)?\z/
|
5
5
|
|
6
|
-
class InvalidVersionNameError < SyntaxError
|
6
|
+
class InvalidVersionNameError < Regexp::Syntax::SyntaxError
|
7
7
|
def initialize(name)
|
8
8
|
super "Invalid version name '#{name}'. Expected format is '#{VERSION_FORMAT}'"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
class UnknownSyntaxNameError < SyntaxError
|
12
|
+
class UnknownSyntaxNameError < Regexp::Syntax::SyntaxError
|
13
13
|
def initialize(name)
|
14
14
|
super "Unknown syntax name '#{name}'."
|
15
15
|
end
|
data/spec/scanner/sets_spec.rb
CHANGED
@@ -61,9 +61,6 @@ RSpec.describe('Set scanning') do
|
|
61
61
|
include_examples 'scan', /[[:digit:][:space:]]/, 2 => [:posixclass, :space, '[:space:]', 10, 19]
|
62
62
|
include_examples 'scan', /[[:^digit:]]/, 1 => [:nonposixclass, :digit, '[:^digit:]', 1, 11]
|
63
63
|
|
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
64
|
include_examples 'scan', /[a-d&&g-h]/, 4 => [:set, :intersection, '&&', 4, 6]
|
68
65
|
include_examples 'scan', /[a&&]/, 2 => [:set, :intersection, '&&', 2, 4]
|
69
66
|
include_examples 'scan', /[&&z]/, 1 => [:set, :intersection, '&&', 1, 3]
|
@@ -88,6 +85,21 @@ RSpec.describe('Set scanning') do
|
|
88
85
|
8 => [:set, :range, '-', 9, 10],
|
89
86
|
10=> [:set, :close, ']', 11, 12]
|
90
87
|
|
88
|
+
# Collations/collating sequences and character equivalents are not enabled
|
89
|
+
# in Ruby at the moment. If they ever are, enable them in the scanner,
|
90
|
+
# add them to a new syntax version, and handle them in the parser. Until then,
|
91
|
+
# expect them to be scanned as regular subsets containing literals.
|
92
|
+
# include_examples 'scan', /[a[.a-b.]c]/, 2 => [:set, :collation, '[.a-b.]', 2, 9]
|
93
|
+
# include_examples 'scan', /[a[=e=]c]/, 2 => [:set, :equivalent, '[=e=]', 2, 7]
|
94
|
+
include_examples 'scan', '[a[.a-b.]c]',
|
95
|
+
2 => [:set, :open, '[', 2, 3],
|
96
|
+
3 => [:literal, :literal, '.', 3, 4],
|
97
|
+
4 => [:literal, :literal, 'a', 4, 5]
|
98
|
+
include_examples 'scan', '[a[=e=]c]',
|
99
|
+
2 => [:set, :open, '[', 2, 3],
|
100
|
+
3 => [:literal, :literal, '=', 3, 4],
|
101
|
+
4 => [:literal, :literal, 'e', 4, 5]
|
102
|
+
|
91
103
|
# multi-byte characters should not affect indices
|
92
104
|
include_examples 'scan', /[れます]/,
|
93
105
|
0 => [:set, :open, '[', 0, 1],
|
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.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ammar Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
|
14
14
|
email:
|