regexp_parser 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,7 +53,7 @@
53
53
  wide_hex_seq_empty = 'x' . '{' . (space+)? . '}';
54
54
 
55
55
  codepoint_single = 'u' . xdigit{4};
56
- codepoint_list = 'u{' . (xdigit{4} . space?)+'}';
56
+ codepoint_list = 'u{' . xdigit{1,5} . (space . xdigit{1,5})* . '}';
57
57
  codepoint_sequence = codepoint_single | codepoint_list;
58
58
 
59
59
  control_sequence = ('c' | 'C-');
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../2.3', __FILE__)
2
+
3
+ module Regexp::Syntax
4
+ module Ruby
5
+
6
+ class V240 < Regexp::Syntax::Ruby::V23
7
+ def initialize
8
+ super
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path('../2.4.0', __FILE__)
2
+
3
+ module Regexp::Syntax
4
+ module Ruby
5
+ # uses the latest 2.4 release
6
+ class V24 < Regexp::Syntax::Ruby::V240; end
7
+ end
8
+ end
@@ -11,7 +11,7 @@ module Regexp::Syntax
11
11
  ASCII = [:bell, :backspace, :escape, :form_feed, :newline, :carriage,
12
12
  :space, :tab, :vertical_tab]
13
13
 
14
- Unicode = [:codepoint_list]
14
+ Unicode = [:codepoint, :codepoint_list]
15
15
 
16
16
  Meta = [:dot, :alternation,
17
17
  :zero_or_one, :zero_or_more, :one_or_more,
@@ -58,6 +58,12 @@ module Regexp::Syntax
58
58
 
59
59
  # alias for the latest 2.3 implementation
60
60
  'ruby/2.3',
61
+
62
+ # Ruby 2.4.x
63
+ 'ruby/2.4.0',
64
+
65
+ # alias for the latest 2.4 implementation
66
+ 'ruby/2.4',
61
67
  ]
62
68
 
63
69
  end
@@ -1,5 +1,5 @@
1
1
  class Regexp
2
2
  module Parser
3
- VERSION = '0.4.1'
3
+ VERSION = '0.4.2'
4
4
  end
5
5
  end
@@ -31,5 +31,5 @@ Gem::Specification.new do |gem|
31
31
 
32
32
  gem.platform = Gem::Platform::RUBY
33
33
 
34
- gem.required_ruby_version = '>= 1.8.7'
34
+ gem.required_ruby_version = '>= 1.9.1'
35
35
  end
@@ -3,7 +3,7 @@ require File.expand_path("../../helpers", __FILE__)
3
3
  class ExpressionConditionals < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @root = RP.parse(/^a(b(?(1)c|(?(2)d|(?(3)e|f)))g)$/)
6
+ @root = RP.parse(/^(a(b))(b(?(1)c|(?(2)d|(?(3)e|f)))g)$/)
7
7
 
8
8
  @cond_1 = @root[2][1]
9
9
  @cond_2 = @root[2][1][2][0]
@@ -19,7 +19,7 @@ class ExpressionConditionals < Test::Unit::TestCase
19
19
  end
20
20
 
21
21
  def test_expression_conditional_root_level
22
- %w{^ a (b(?(1)c|(?(2)d|(?(3)e|f)))g) $}.each_with_index do |t, i|
22
+ %w{^ (a(b)) (b(?(1)c|(?(2)d|(?(3)e|f)))g) $}.each_with_index do |t, i|
23
23
  assert_equal 0, @root[i].conditional_level
24
24
  assert_equal t, @root[i].to_s
25
25
  end
@@ -98,7 +98,7 @@ class SubexpressionTraverse < Test::Unit::TestCase
98
98
  assert_equal Array, item.class
99
99
  assert_equal 2, item.length
100
100
  assert_equal true, item.first.is_a?(Regexp::Expression::Base)
101
- assert_equal true, item.last.is_a?(Fixnum)
101
+ assert_equal true, item.last.is_a?(Integer)
102
102
  end
103
103
  end
104
104
 
@@ -71,7 +71,7 @@ class TestParserConditionals < Test::Unit::TestCase
71
71
  end
72
72
 
73
73
  def test_parse_conditional_nested
74
- regexp = /(a(b(c)))(?(1)(?(2)d|(?(3)e|f))|(?(4)(?(5)g|h)))/
74
+ regexp = /(a(b(c(d)(e))))(?(1)(?(2)d|(?(3)e|f))|(?(4)(?(5)g|h)))/
75
75
 
76
76
  root = RP.parse(regexp, 'ruby/2.0')
77
77
 
@@ -27,7 +27,8 @@ class TestParserEscapes < Test::Unit::TestCase
27
27
  /a\}c/ => [1, :escape, :interval_close, EscapeSequence::Literal],
28
28
 
29
29
  # unicode escapes
30
- /a\u{9879}/ => [1, :escape, :codepoint_list, EscapeSequence::Literal],
30
+ /a\u0640/ => [1, :escape, :codepoint, EscapeSequence::Literal],
31
+ /a\u{41 1F60D}/ => [1, :escape, :codepoint_list, EscapeSequence::Literal],
31
32
 
32
33
  # hex escapes
33
34
  /a\xFF/n => [1, :escape, :hex, EscapeSequence::Literal],
@@ -4,22 +4,22 @@ class ScannerConditionals < Test::Unit::TestCase
4
4
 
5
5
  # Basic conditional scan token tests
6
6
  tests = {
7
- /(?(1)T|F)/ => [0, :conditional, :open, '(?', 0, 2],
8
- /(?(2)T|F)/ => [1, :conditional, :condition_open, '(', 2, 3],
9
- /(?(3)T|F)/ => [2, :conditional, :condition, '3', 3, 4],
10
- /(?(4)T|F)/ => [3, :conditional, :condition_close, ')', 4, 5],
11
- /(?(5)T|F)/ => [4, :literal, :literal, 'T', 5, 6],
12
- /(?(6)T|F)/ => [5, :conditional, :separator, '|', 6, 7],
13
- /(?(7)T|F)/ => [6, :literal, :literal, 'F', 7, 8],
14
- /(?(8)T|F)/ => [7, :conditional, :close, ')', 8, 9],
15
-
16
- /(?(1)TRUE)/ => [5, :conditional, :close, ')', 9, 10],
17
-
18
- /(?(1)TRUE|)/ => [5, :conditional, :separator, '|', 9, 10],
19
- /(?(2)TRUE|)/ => [6, :conditional, :close, ')', 10, 11],
20
-
21
- /(?<N>A)(?(<N>)T|F)/ => [5, :conditional, :condition, '<N>', 10, 13],
22
- /(?'N'A)(?('N')T|F)/ => [5, :conditional, :condition, "'N'", 10, 13],
7
+ /(a)(?(1)T|F)/ => [3, :conditional, :open, '(?', 3, 5],
8
+ /(a)(?(1)T|F)/ => [4, :conditional, :condition_open, '(', 5, 6],
9
+ /(a)(?(1)T|F)/ => [5, :conditional, :condition, '3', 6, 7],
10
+ /(a)(?(1)T|F)/ => [6, :conditional, :condition_close, ')', 7, 8],
11
+ /(a)(?(1)T|F)/ => [7, :literal, :literal, 'T', 8, 9],
12
+ /(a)(?(1)T|F)/ => [8, :conditional, :separator, '|', 9, 10],
13
+ /(a)(?(1)T|F)/ => [9, :literal, :literal, 'F', 10, 11],
14
+ /(a)(?(1)T|F)/ => [10, :conditional, :close, ')', 11, 12],
15
+
16
+ /(a)(?(1)TRUE)/ => [8, :conditional, :close, ')', 12, 13],
17
+
18
+ /(a)(?(1)TRUE|)/ => [8, :conditional, :separator, '|', 12, 13],
19
+ /(a)(?(1)TRUE|)/ => [9, :conditional, :close, ')', 13, 14],
20
+
21
+ /(?<N>A)(?(<N>)T|F)/ => [5, :conditional, :condition, '<N>', 10, 13],
22
+ /(?'N'A)(?('N')T|F)/ => [5, :conditional, :condition, "'N'", 10, 13],
23
23
  }
24
24
 
25
25
  tests.each_with_index do |(pattern, (index, type, token, text, ts, te)), count|
@@ -25,7 +25,7 @@ class ScannerEscapes < Test::Unit::TestCase
25
25
  'a\x{0640}c' => [1, :escape, :hex_wide, '\x{0640}', 1, 9],
26
26
 
27
27
  'a\u0640c' => [1, :escape, :codepoint, '\u0640', 1, 7],
28
- 'a\u{0640 0641}c' => [1, :escape, :codepoint_list, '\u{0640 0641}', 1, 14],
28
+ 'a\u{640 0641}c' => [1, :escape, :codepoint_list, '\u{640 0641}', 1, 13],
29
29
 
30
30
  /a\cBc/ => [1, :escape, :control, '\cB', 1, 4],
31
31
  /a\C-bc/ => [1, :escape, :control, '\C-b', 1, 5],
@@ -217,4 +217,18 @@ class TestSyntaxFiles < Test::Unit::TestCase
217
217
 
218
218
  assert syntax.kind_of?(Regexp::Syntax::Ruby::V233)
219
219
  end
220
+
221
+ # 2.4 syntax files
222
+ def test_syntax_file_2_4_0
223
+ syntax = Regexp::Syntax.new 'ruby/2.4.0'
224
+
225
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V23)
226
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V240)
227
+ end
228
+
229
+ def test_syntax_file_2_4_alias
230
+ syntax = Regexp::Syntax.new 'ruby/2.4'
231
+
232
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V240)
233
+ end
220
234
  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: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ammar Ali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-22 00:00:00.000000000 Z
11
+ date: 2017-01-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
14
14
  email:
@@ -84,6 +84,8 @@ files:
84
84
  - lib/regexp_parser/syntax/ruby/2.3.2.rb
85
85
  - lib/regexp_parser/syntax/ruby/2.3.3.rb
86
86
  - lib/regexp_parser/syntax/ruby/2.3.rb
87
+ - lib/regexp_parser/syntax/ruby/2.4.0.rb
88
+ - lib/regexp_parser/syntax/ruby/2.4.rb
87
89
  - lib/regexp_parser/syntax/tokens.rb
88
90
  - lib/regexp_parser/syntax/tokens/anchor.rb
89
91
  - lib/regexp_parser/syntax/tokens/assertion.rb
@@ -181,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
183
  requirements:
182
184
  - - ">="
183
185
  - !ruby/object:Gem::Version
184
- version: 1.8.7
186
+ version: 1.9.1
185
187
  required_rubygems_version: !ruby/object:Gem::Requirement
186
188
  requirements:
187
189
  - - ">="
@@ -189,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
191
  version: '0'
190
192
  requirements: []
191
193
  rubyforge_project:
192
- rubygems_version: 2.5.2
194
+ rubygems_version: 2.6.8
193
195
  signing_key:
194
196
  specification_version: 4
195
197
  summary: Scanner, lexer, parser for ruby's regular expressions