parser 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parser/builders/default.rb +7 -2
- data/parser.gemspec +1 -1
- data/test/test_parser.rb +18 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3192a05f45765370bae5e845962967a28d64d6fe
|
4
|
+
data.tar.gz: 38543a4c5abe950bb1bf984702e0823efa164af5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4da4fa68c1ed37af9eb16442c6816da2943c6914e04f80cdd16d76c3cc7360eaba18861c6dc39984a08720ea7befa84b3fa9c8b311c69ab61ca8f9c89cc2e0c
|
7
|
+
data.tar.gz: cbdd62c1a300719540385b0965d014da25c31853a7ddc73eef375568ee91fad4344de3465d30e631f41e92013ccf549d909eb31d2a8e40031ed90f81878fde32
|
@@ -40,7 +40,7 @@ module Parser
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def string_compose(begin_t, parts, end_t)
|
43
|
-
if parts
|
43
|
+
if collapse_string_parts?(parts)
|
44
44
|
parts.first
|
45
45
|
else
|
46
46
|
s(:dstr, *parts)
|
@@ -92,7 +92,7 @@ module Parser
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def word(parts)
|
95
|
-
if parts
|
95
|
+
if collapse_string_parts?(parts)
|
96
96
|
parts.first
|
97
97
|
else
|
98
98
|
s(:dstr, *parts)
|
@@ -667,6 +667,11 @@ module Parser
|
|
667
667
|
cond
|
668
668
|
end
|
669
669
|
|
670
|
+
def collapse_string_parts?(parts)
|
671
|
+
parts.one? &&
|
672
|
+
[:str, :dstr].include?(parts.first.type)
|
673
|
+
end
|
674
|
+
|
670
675
|
def t(token, type, *args)
|
671
676
|
s(type, *(args << { :source_map => Source::Map.new(location(token)) }))
|
672
677
|
end
|
data/parser.gemspec
CHANGED
data/test/test_parser.rb
CHANGED
@@ -316,12 +316,14 @@ class TestParser < MiniTest::Unit::TestCase
|
|
316
316
|
|
317
317
|
def test_array_words_interp
|
318
318
|
assert_parses(
|
319
|
-
s(:array,
|
319
|
+
s(:array,
|
320
|
+
s(:str, "foo"),
|
321
|
+
s(:dstr, s(:lvar, :bar))),
|
320
322
|
%q{%W[foo #{bar}]},
|
321
323
|
%q{^^^ begin
|
322
324
|
| ^ end
|
323
325
|
| ~~~ expression (str)
|
324
|
-
| ~~~ expression (lvar)
|
326
|
+
| ~~~ expression (dstr.lvar)
|
325
327
|
|~~~~~~~~~~~~~~ expression})
|
326
328
|
|
327
329
|
assert_parses(
|
@@ -357,12 +359,14 @@ class TestParser < MiniTest::Unit::TestCase
|
|
357
359
|
|
358
360
|
def test_array_symbols_interp
|
359
361
|
assert_parses(
|
360
|
-
s(:array,
|
362
|
+
s(:array,
|
363
|
+
s(:sym, :foo),
|
364
|
+
s(:dsym, s(:lvar, :bar))),
|
361
365
|
%q{%I[foo #{bar}]},
|
362
366
|
%q{^^^ begin
|
363
367
|
| ^ end
|
364
368
|
| ~~~ expression (sym)
|
365
|
-
| ~~~ expression (lvar)
|
369
|
+
| ~~~ expression (dsym.lvar)
|
366
370
|
|~~~~~~~~~~~~~~ expression},
|
367
371
|
ALL_VERSIONS - %w(1.8 1.9))
|
368
372
|
|
@@ -3948,4 +3952,14 @@ class TestParser < MiniTest::Unit::TestCase
|
|
3948
3952
|
s(:args), s(:nil)),
|
3949
3953
|
%q{desc "foo" do end})
|
3950
3954
|
end
|
3955
|
+
|
3956
|
+
def test_bug_interp_single
|
3957
|
+
assert_parses(
|
3958
|
+
s(:dstr, s(:int, 1)),
|
3959
|
+
%q{"#{1}"})
|
3960
|
+
|
3961
|
+
assert_parses(
|
3962
|
+
s(:array, s(:dstr, s(:int, 1))),
|
3963
|
+
%q{%W"#{1}"})
|
3964
|
+
end
|
3951
3965
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Zotov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|