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
data/spec/support/runner.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'pathname'
|
2
|
-
require 'rspec'
|
3
|
-
|
4
|
-
module RegexpParserSpec
|
5
|
-
class Runner
|
6
|
-
def initialize(arguments, warning_whitelist)
|
7
|
-
@arguments = arguments
|
8
|
-
@warning_whitelist = warning_whitelist
|
9
|
-
end
|
10
|
-
|
11
|
-
def run
|
12
|
-
spec_status = nil
|
13
|
-
|
14
|
-
Warning::Filter.new(warning_whitelist).assert_expected_warnings_only do
|
15
|
-
setup
|
16
|
-
spec_status = run_rspec
|
17
|
-
end
|
18
|
-
|
19
|
-
spec_status
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def setup
|
25
|
-
$VERBOSE = true
|
26
|
-
|
27
|
-
spec_files.each(&method(:require))
|
28
|
-
end
|
29
|
-
|
30
|
-
def run_rspec
|
31
|
-
RSpec::Core::Runner.run([])
|
32
|
-
end
|
33
|
-
|
34
|
-
def spec_files
|
35
|
-
arguments
|
36
|
-
.map { |path| Pathname.new(path).expand_path.freeze }
|
37
|
-
.select(&:file?)
|
38
|
-
end
|
39
|
-
|
40
|
-
attr_reader :arguments, :warning_whitelist
|
41
|
-
end
|
42
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
require 'delegate'
|
3
|
-
|
4
|
-
module RegexpParserSpec
|
5
|
-
class Warning
|
6
|
-
class UnexpectedWarnings < StandardError
|
7
|
-
MSG = 'Unexpected warnings: %s'.freeze
|
8
|
-
|
9
|
-
def initialize(warnings)
|
10
|
-
super(MSG % warnings.join("\n"))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Filter
|
15
|
-
def initialize(whitelist)
|
16
|
-
@whitelist = whitelist
|
17
|
-
end
|
18
|
-
|
19
|
-
def assert_expected_warnings_only
|
20
|
-
original = $stderr
|
21
|
-
$stderr = Extractor.new(original, @whitelist)
|
22
|
-
|
23
|
-
yield
|
24
|
-
|
25
|
-
assert_no_warnings($stderr.warnings)
|
26
|
-
ensure
|
27
|
-
$stderr = original
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def assert_no_warnings(warnings)
|
33
|
-
raise UnexpectedWarnings, warnings.to_a if warnings.any?
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class Extractor < DelegateClass(IO)
|
38
|
-
PATTERN = /\A(?:.+):(?:\d+): warning: (?:.+)\n\z/
|
39
|
-
|
40
|
-
def initialize(io, whitelist)
|
41
|
-
@whitelist = whitelist
|
42
|
-
@warnings = Set.new
|
43
|
-
super(io)
|
44
|
-
end
|
45
|
-
|
46
|
-
def write(message)
|
47
|
-
return super if PATTERN !~ message
|
48
|
-
|
49
|
-
warning = message.chomp
|
50
|
-
@warnings << warning if @whitelist.none?(&warning.method(:include?))
|
51
|
-
|
52
|
-
self
|
53
|
-
end
|
54
|
-
|
55
|
-
def warnings
|
56
|
-
@warnings.dup.freeze
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|