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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +54 -0
  3. data/Gemfile +5 -1
  4. data/README.md +15 -21
  5. data/Rakefile +11 -17
  6. data/lib/regexp_parser/error.rb +4 -0
  7. data/lib/regexp_parser/expression/base.rb +123 -0
  8. data/lib/regexp_parser/expression/classes/anchor.rb +0 -2
  9. data/lib/regexp_parser/expression/classes/{backref.rb → backreference.rb} +5 -0
  10. data/lib/regexp_parser/expression/classes/{set → character_set}/intersection.rb +0 -0
  11. data/lib/regexp_parser/expression/classes/{set → character_set}/range.rb +2 -1
  12. data/lib/regexp_parser/expression/classes/{set.rb → character_set.rb} +0 -0
  13. data/lib/regexp_parser/expression/classes/conditional.rb +11 -1
  14. data/lib/regexp_parser/expression/classes/{escape.rb → escape_sequence.rb} +1 -0
  15. data/lib/regexp_parser/expression/classes/free_space.rb +1 -3
  16. data/lib/regexp_parser/expression/classes/group.rb +6 -1
  17. data/lib/regexp_parser/expression/classes/literal.rb +1 -5
  18. data/lib/regexp_parser/expression/classes/property.rb +1 -3
  19. data/lib/regexp_parser/expression/classes/root.rb +0 -1
  20. data/lib/regexp_parser/expression/classes/type.rb +0 -2
  21. data/lib/regexp_parser/expression/quantifier.rb +2 -2
  22. data/lib/regexp_parser/expression/sequence.rb +3 -10
  23. data/lib/regexp_parser/expression/subexpression.rb +1 -2
  24. data/lib/regexp_parser/expression.rb +7 -130
  25. data/lib/regexp_parser/lexer.rb +7 -5
  26. data/lib/regexp_parser/parser.rb +282 -334
  27. data/lib/regexp_parser/scanner/properties/long.yml +13 -0
  28. data/lib/regexp_parser/scanner/properties/short.yml +9 -1
  29. data/lib/regexp_parser/scanner/scanner.rl +64 -87
  30. data/lib/regexp_parser/scanner.rb +1024 -1073
  31. data/lib/regexp_parser/syntax/any.rb +2 -4
  32. data/lib/regexp_parser/syntax/base.rb +10 -10
  33. data/lib/regexp_parser/syntax/token/anchor.rb +15 -0
  34. data/lib/regexp_parser/syntax/{tokens → token}/assertion.rb +2 -2
  35. data/lib/regexp_parser/syntax/{tokens/backref.rb → token/backreference.rb} +6 -5
  36. data/lib/regexp_parser/syntax/{tokens → token}/character_set.rb +2 -2
  37. data/lib/regexp_parser/syntax/{tokens → token}/character_type.rb +3 -3
  38. data/lib/regexp_parser/syntax/{tokens → token}/conditional.rb +3 -3
  39. data/lib/regexp_parser/syntax/token/escape.rb +31 -0
  40. data/lib/regexp_parser/syntax/{tokens → token}/group.rb +7 -7
  41. data/lib/regexp_parser/syntax/{tokens → token}/keep.rb +1 -1
  42. data/lib/regexp_parser/syntax/{tokens → token}/meta.rb +2 -2
  43. data/lib/regexp_parser/syntax/{tokens → token}/posix_class.rb +3 -3
  44. data/lib/regexp_parser/syntax/token/quantifier.rb +35 -0
  45. data/lib/regexp_parser/syntax/token/unicode_property.rb +696 -0
  46. data/lib/regexp_parser/syntax/token.rb +45 -0
  47. data/lib/regexp_parser/syntax/version_lookup.rb +2 -2
  48. data/lib/regexp_parser/syntax/versions/1.8.6.rb +1 -1
  49. data/lib/regexp_parser/syntax/versions/3.1.0.rb +10 -0
  50. data/lib/regexp_parser/syntax.rb +8 -6
  51. data/lib/regexp_parser/token.rb +9 -20
  52. data/lib/regexp_parser/version.rb +1 -1
  53. data/lib/regexp_parser.rb +0 -2
  54. data/spec/expression/clone_spec.rb +36 -4
  55. data/spec/expression/free_space_spec.rb +2 -2
  56. data/spec/expression/methods/match_length_spec.rb +2 -2
  57. data/spec/lexer/nesting_spec.rb +2 -2
  58. data/spec/lexer/refcalls_spec.rb +5 -0
  59. data/spec/parser/all_spec.rb +2 -2
  60. data/spec/parser/escapes_spec.rb +43 -31
  61. data/spec/parser/properties_spec.rb +6 -4
  62. data/spec/parser/refcalls_spec.rb +5 -0
  63. data/spec/parser/set/ranges_spec.rb +26 -16
  64. data/spec/scanner/escapes_spec.rb +29 -20
  65. data/spec/scanner/refcalls_spec.rb +19 -0
  66. data/spec/scanner/sets_spec.rb +66 -23
  67. data/spec/spec_helper.rb +13 -1
  68. data/spec/support/capturing_stderr.rb +9 -0
  69. data/spec/syntax/versions/1.8.6_spec.rb +2 -2
  70. data/spec/syntax/versions/2.0.0_spec.rb +2 -2
  71. data/spec/syntax/versions/aliases_spec.rb +1 -0
  72. metadata +27 -26
  73. data/lib/regexp_parser/syntax/tokens/anchor.rb +0 -15
  74. data/lib/regexp_parser/syntax/tokens/escape.rb +0 -30
  75. data/lib/regexp_parser/syntax/tokens/quantifier.rb +0 -35
  76. data/lib/regexp_parser/syntax/tokens/unicode_property.rb +0 -675
  77. data/lib/regexp_parser/syntax/tokens.rb +0 -45
  78. data/spec/support/runner.rb +0 -42
  79. data/spec/support/warning_extractor.rb +0 -60
@@ -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