alex-rkelly 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module RKelly
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
@@ -11,5 +11,9 @@ module RKelly
11
11
  return transformer.call(name, value) if transformer
12
12
  [name, value]
13
13
  end
14
+
15
+ def to_s
16
+ return "#{self.name}: #{self.value}"
17
+ end
14
18
  end
15
19
  end
@@ -90,7 +90,16 @@ module RKelly
90
90
  end
91
91
  end
92
92
 
93
- token(:REGEXP, /\A\/(?:[^\/\r\n\\]*(?:\\[^\r\n][^\/\r\n\\]*)*)\/[gi]*/)
93
+ # To distinguish regular expressions from comments, we require that
94
+ # regular expressions start with a non * character (ie, not look like
95
+ # /*foo*/). Note that we can't depend on the length of the match to
96
+ # correctly distinguish, since `/**/i` is longer if matched as a regular
97
+ # expression than as matched as a comment.
98
+ # Incidentally, we're also not matching empty regular expressions
99
+ # (eg, // and //g). Here we could depend on match length and priority to
100
+ # determine that these are actually comments, but it turns out to be
101
+ # easier to not match them in the first place.
102
+ token(:REGEXP, /\A\/(?:[^\/\r\n\\*]|\\[^\r\n])[^\/\r\n\\]*(?:\\[^\r\n][^\/\r\n\\]*)*\/[gi]*/)
94
103
  token(:S, /\A[\s\r\n]*/m)
95
104
 
96
105
  token(:SINGLE_CHAR, /\A./) do |type, value|
@@ -127,6 +127,14 @@ class TokenizerTest < Test::Unit::TestCase
127
127
  end
128
128
  end
129
129
 
130
+ def test_regular_expression_is_not_found_if_block_comment_with_re_modifier
131
+ tokens = @tokenizer.tokenize("/**/i")
132
+ assert_tokens([
133
+ [:COMMENT, "/**/"],
134
+ [:IDENT, "i"]
135
+ ], tokens)
136
+ end
137
+
130
138
  def test_comment_assign
131
139
  tokens = @tokenizer.tokenize("foo = /**/;")
132
140
  assert_tokens([
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alex-rkelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: