regexp_parser 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ea0d8b4e867d39d8f87f15f51607ac74551945d
4
- data.tar.gz: af634117db3e8ab2e73f627f13bc5685686f0d56
3
+ metadata.gz: e3cfa8eca93da452bed80baa13cb98349eca9dcf
4
+ data.tar.gz: 8a60f4b22945ab450723a9aac0443a9d2ae9bb3d
5
5
  SHA512:
6
- metadata.gz: b83a24999e481fc9fdbbbf311e042411756671a8da98e5dddb4dc254cf1bd3d4b898d946763ecbb4ef150f42884a9b1cf6232b49c4c3c26620f38260ab4348db
7
- data.tar.gz: 1d0e39de0e83780ccb52d95a522887d7de8f6fbf8c9a37f24c88c9becc4bbb3b993cb1e55fe3b253ec9fb34d98a5db5676ff7c89f81a5c3ab9578f6eaa0eb481
6
+ metadata.gz: ad557e665cf6bfa3a5adb025c1fd44756213579427f99e2c47e38ca2de95edc1c068ef5d0328c3c7d6522f8f0a268a85cd5348884f7f6652c3db4e580c31f4a7
7
+ data.tar.gz: 2eed59b10fd17a36d41cf3ae702b5fcb54303c050c46884dc2a4bda3a745531fc4870a9afd254dfc69aaab48cf36683797dcaa550426b464ccb3cd705f4da965
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ Wed May 25 2016 Ammar Ali <ammarabuali@gmail.com>
2
+
3
+ * Thanks to John Backus (https://github.com/backus):
4
+ - Fix warnings (PR #19)
5
+ * Thanks to Dana Scheider (https://github.com/danascheider):
6
+ - Correct error in README (PR #20)
7
+ * Fixed mistyped \h and \H character types (issue #21)
8
+ * Added ancestry syntax files for latest rubies (issue #22)
9
+ * Bumped version to 0.3.4
10
+
1
11
  Tue Apr 26 2016 Ammar Ali <ammarabuali@gmail.com>
2
12
 
3
13
  * Thanks to John Backus (https://github.com/backus):
data/README.md CHANGED
@@ -201,7 +201,7 @@ syntax, and prints the token objects' text indented to their level.
201
201
  ```ruby
202
202
  require 'regexp_parser'
203
203
 
204
- Regexp::Lexer.scan /a?(b(c))*[d]+/, 'ruby/1.9' do |token|
204
+ Regexp::Lexer.lex /a?(b(c))*[d]+/, 'ruby/1.9' do |token|
205
205
  puts "#{' ' * token.level}#{token.text}"
206
206
  end
207
207
 
data/Rakefile CHANGED
@@ -53,8 +53,17 @@ namespace :ragel do
53
53
  desc "Process the ragel source files and output ruby code"
54
54
  task :rb do |t|
55
55
  RAGEL_SOURCE_FILES.each do |file|
56
+ output_file = "#{RAGEL_OUTPUT_DIR}/#{file}.rb"
56
57
  # using faster flat table driven FSM, about 25% larger code, but about 30% faster
57
- sh "ragel -F1 -R #{RAGEL_SOURCE_DIR}/#{file}.rl -o #{RAGEL_OUTPUT_DIR}/#{file}.rb"
58
+ sh "ragel -F1 -R #{RAGEL_SOURCE_DIR}/#{file}.rl -o #{output_file}"
59
+
60
+ contents = File.read(output_file)
61
+
62
+ File.open(output_file, 'r+') do |file|
63
+ contents = "# -*- warn-indent:false; -*-\n" + contents
64
+
65
+ file.write(contents)
66
+ end
58
67
  end
59
68
  end
60
69
 
@@ -16,6 +16,7 @@ module Regexp::Expression
16
16
  @level = token.level
17
17
  @set_level = token.set_level
18
18
  @conditional_level = token.conditional_level
19
+ @quantifier = nil
19
20
  @options = nil
20
21
  end
21
22
 
@@ -1,3 +1,4 @@
1
+ # -*- warn-indent:false; -*-
1
2
 
2
3
  # line 1 "/Users/ammar/src/code/ruby/projects/regexp_parser/lib/regexp_parser/scanner/scanner.rl"
3
4
 
@@ -72,6 +72,7 @@ module Regexp::Syntax
72
72
  when 'ruby/2.1.6'; syntax = Regexp::Syntax::Ruby::V216.new
73
73
  when 'ruby/2.1.7'; syntax = Regexp::Syntax::Ruby::V217.new
74
74
  when 'ruby/2.1.8'; syntax = Regexp::Syntax::Ruby::V218.new
75
+ when 'ruby/2.1.9'; syntax = Regexp::Syntax::Ruby::V219.new
75
76
 
76
77
  # aliases for the latest 2.1 implementations
77
78
  when 'ruby/2.1'; syntax = Regexp::Syntax::Ruby::V21.new
@@ -82,12 +83,14 @@ module Regexp::Syntax
82
83
  when 'ruby/2.2.2'; syntax = Regexp::Syntax::Ruby::V222.new
83
84
  when 'ruby/2.2.3'; syntax = Regexp::Syntax::Ruby::V223.new
84
85
  when 'ruby/2.2.4'; syntax = Regexp::Syntax::Ruby::V224.new
86
+ when 'ruby/2.2.5'; syntax = Regexp::Syntax::Ruby::V225.new
85
87
 
86
88
  # aliases for the latest 2.2 implementations
87
89
  when 'ruby/2.2'; syntax = Regexp::Syntax::Ruby::V22.new
88
90
 
89
91
  # Ruby 2.3.x
90
92
  when 'ruby/2.3.0'; syntax = Regexp::Syntax::Ruby::V230.new
93
+ when 'ruby/2.3.1'; syntax = Regexp::Syntax::Ruby::V231.new
91
94
 
92
95
  # alias for the latest 2.3 implementation
93
96
  when 'ruby/2.3'; syntax = Regexp::Syntax::Ruby::V23.new
@@ -15,7 +15,9 @@ module Regexp::Syntax
15
15
  implements :backref, Backreference::All +
16
16
  SubexpressionCall::All
17
17
 
18
- implements :escape, CharacterType::Hex + Escape::Unicode
18
+ implements :escape, Escape::Unicode
19
+
20
+ implements :type, CharacterType::Hex
19
21
 
20
22
  implements :property,
21
23
  UnicodeProperty::V190
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../2.1.8', __FILE__)
2
+
3
+ module Regexp::Syntax
4
+ module Ruby
5
+
6
+ class V219 < Regexp::Syntax::Ruby::V218
7
+ def initialize
8
+ super
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -1,8 +1,8 @@
1
- require File.expand_path('../2.1.8', __FILE__)
1
+ require File.expand_path('../2.1.9', __FILE__)
2
2
 
3
3
  module Regexp::Syntax
4
4
  module Ruby
5
5
  # uses the latest 2.1 release
6
- class V21 < Regexp::Syntax::Ruby::V218; end
6
+ class V21 < Regexp::Syntax::Ruby::V219; end
7
7
  end
8
8
  end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../2.2.4', __FILE__)
2
+
3
+ module Regexp::Syntax
4
+ module Ruby
5
+
6
+ class V225 < Regexp::Syntax::Ruby::V224
7
+ def initialize
8
+ super
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -1,8 +1,8 @@
1
- require File.expand_path('../2.2.4', __FILE__)
1
+ require File.expand_path('../2.2.5', __FILE__)
2
2
 
3
3
  module Regexp::Syntax
4
4
  module Ruby
5
5
  # uses the latest 2.2 release
6
- class V22 < Regexp::Syntax::Ruby::V224; end
6
+ class V22 < Regexp::Syntax::Ruby::V225; end
7
7
  end
8
8
  end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../2.3.0', __FILE__)
2
+
3
+ module Regexp::Syntax
4
+ module Ruby
5
+
6
+ class V231 < Regexp::Syntax::Ruby::V230
7
+ def initialize
8
+ super
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -1,8 +1,8 @@
1
- require File.expand_path('../2.3.0', __FILE__)
1
+ require File.expand_path('../2.3.1', __FILE__)
2
2
 
3
3
  module Regexp::Syntax
4
4
  module Ruby
5
5
  # uses the latest 2.3 release
6
- class V23 < Regexp::Syntax::Ruby::V230; end
6
+ class V23 < Regexp::Syntax::Ruby::V231; end
7
7
  end
8
8
  end
@@ -1,5 +1,5 @@
1
1
  class Regexp
2
2
  module Parser
3
- VERSION = '0.3.3'
3
+ VERSION = '0.3.4'
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ require File.expand_path("../../helpers", __FILE__)
2
2
 
3
3
  %w{
4
4
  alternation anchors errors escapes free_space groups
5
- properties quantifiers refcalls sets
5
+ properties quantifiers refcalls sets types
6
6
  }.each do|tc|
7
7
  require File.expand_path("../test_#{tc}", __FILE__)
8
8
  end
@@ -0,0 +1,33 @@
1
+ require File.expand_path("../../helpers", __FILE__)
2
+
3
+ class TestParserTypes < Test::Unit::TestCase
4
+
5
+ tests = {
6
+ /a\dc/ => [1, :type, :digit, CharacterType::Digit],
7
+ /a\Dc/ => [1, :type, :nondigit, CharacterType::NonDigit],
8
+
9
+ /a\sc/ => [1, :type, :space, CharacterType::Space],
10
+ /a\Sc/ => [1, :type, :nonspace, CharacterType::NonSpace],
11
+
12
+ /a\hc/ => [1, :type, :hex, CharacterType::Hex],
13
+ /a\Hc/ => [1, :type, :nonhex, CharacterType::NonHex],
14
+
15
+ /a\wc/ => [1, :type, :word, CharacterType::Word],
16
+ /a\Wc/ => [1, :type, :nonword, CharacterType::NonWord],
17
+ }
18
+
19
+ count = 0
20
+ tests.each do |pattern, test|
21
+ define_method "test_parse_type_#{test[2]}_#{count+=1}" do
22
+ root = RP.parse(pattern, 'ruby/1.9')
23
+ exp = root.expressions[test[0]]
24
+
25
+ assert( exp.is_a?( test[3] ),
26
+ "Expected #{test[3]}, but got #{exp.class.name}")
27
+
28
+ assert_equal( test[1], exp.type )
29
+ assert_equal( test[2], exp.token )
30
+ end
31
+ end
32
+
33
+ end
@@ -13,6 +13,10 @@ class TestSyntaxRuby_V191 < Test::Unit::TestCase
13
13
  Escape::Backreference + Escape::ASCII + Escape::Meta + Escape::Unicode
14
14
  ].flatten,
15
15
 
16
+ :type => [
17
+ CharacterType::Hex
18
+ ].flatten,
19
+
16
20
  :quantifier => [
17
21
  Quantifier::Greedy + Quantifier::Reluctant +
18
22
  Quantifier::Possessive
@@ -111,10 +111,17 @@ class TestSyntaxFiles < Test::Unit::TestCase
111
111
  assert syntax.kind_of?(Regexp::Syntax::Ruby::V217)
112
112
  end
113
113
 
114
+ def test_syntax_file_2_1_9
115
+ syntax = Regexp::Syntax.new 'ruby/2.1.9'
116
+
117
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V218)
118
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V219)
119
+ end
120
+
114
121
  def test_syntax_file_2_1_alias
115
122
  syntax = Regexp::Syntax.new 'ruby/2.1'
116
123
 
117
- assert syntax.kind_of?(Regexp::Syntax::Ruby::V218)
124
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V219)
118
125
  end
119
126
 
120
127
 
@@ -149,10 +156,17 @@ class TestSyntaxFiles < Test::Unit::TestCase
149
156
  assert syntax.kind_of?(Regexp::Syntax::Ruby::V224)
150
157
  end
151
158
 
159
+ def test_syntax_file_2_2_5
160
+ syntax = Regexp::Syntax.new 'ruby/2.2.5'
161
+
162
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V224)
163
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V225)
164
+ end
165
+
152
166
  def test_syntax_file_2_2_alias
153
167
  syntax = Regexp::Syntax.new 'ruby/2.2'
154
168
 
155
- assert syntax.kind_of?(Regexp::Syntax::Ruby::V224)
169
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V225)
156
170
  end
157
171
 
158
172
  # 2.3 syntax files
@@ -160,11 +174,19 @@ class TestSyntaxFiles < Test::Unit::TestCase
160
174
  syntax = Regexp::Syntax.new 'ruby/2.3.0'
161
175
 
162
176
  assert syntax.kind_of?(Regexp::Syntax::Ruby::V22)
177
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V230)
178
+ end
179
+
180
+ def test_syntax_file_2_3_1
181
+ syntax = Regexp::Syntax.new 'ruby/2.3.1'
182
+
183
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V230)
184
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V231)
163
185
  end
164
186
 
165
187
  def test_syntax_file_2_3_alias
166
188
  syntax = Regexp::Syntax.new 'ruby/2.3'
167
189
 
168
- assert syntax.kind_of?(Regexp::Syntax::Ruby::V230)
190
+ assert syntax.kind_of?(Regexp::Syntax::Ruby::V231)
169
191
  end
170
192
  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.3.3
4
+ version: 0.3.4
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-04-26 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library for tokenizing, lexing, and parsing Ruby regular expressions.
14
14
  email:
@@ -66,14 +66,17 @@ files:
66
66
  - lib/regexp_parser/syntax/ruby/2.1.6.rb
67
67
  - lib/regexp_parser/syntax/ruby/2.1.7.rb
68
68
  - lib/regexp_parser/syntax/ruby/2.1.8.rb
69
+ - lib/regexp_parser/syntax/ruby/2.1.9.rb
69
70
  - lib/regexp_parser/syntax/ruby/2.1.rb
70
71
  - lib/regexp_parser/syntax/ruby/2.2.0.rb
71
72
  - lib/regexp_parser/syntax/ruby/2.2.1.rb
72
73
  - lib/regexp_parser/syntax/ruby/2.2.2.rb
73
74
  - lib/regexp_parser/syntax/ruby/2.2.3.rb
74
75
  - lib/regexp_parser/syntax/ruby/2.2.4.rb
76
+ - lib/regexp_parser/syntax/ruby/2.2.5.rb
75
77
  - lib/regexp_parser/syntax/ruby/2.2.rb
76
78
  - lib/regexp_parser/syntax/ruby/2.3.0.rb
79
+ - lib/regexp_parser/syntax/ruby/2.3.1.rb
77
80
  - lib/regexp_parser/syntax/ruby/2.3.rb
78
81
  - lib/regexp_parser/syntax/tokens.rb
79
82
  - lib/regexp_parser/syntax/tokens/anchor.rb
@@ -123,6 +126,7 @@ files:
123
126
  - test/parser/test_quantifiers.rb
124
127
  - test/parser/test_refcalls.rb
125
128
  - test/parser/test_sets.rb
129
+ - test/parser/test_types.rb
126
130
  - test/scanner/test_all.rb
127
131
  - test/scanner/test_anchors.rb
128
132
  - test/scanner/test_conditionals.rb
@@ -211,6 +215,7 @@ test_files:
211
215
  - test/parser/test_quantifiers.rb
212
216
  - test/parser/test_refcalls.rb
213
217
  - test/parser/test_sets.rb
218
+ - test/parser/test_types.rb
214
219
  - test/scanner/test_all.rb
215
220
  - test/scanner/test_anchors.rb
216
221
  - test/scanner/test_conditionals.rb