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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e0c9d9727b2d7da39af4c37f2fa324be928ece6
4
- data.tar.gz: 5a9dc8e99c54aad863aeae920641064af6aa57ee
3
+ metadata.gz: 3192a05f45765370bae5e845962967a28d64d6fe
4
+ data.tar.gz: 38543a4c5abe950bb1bf984702e0823efa164af5
5
5
  SHA512:
6
- metadata.gz: 4086430fbdc0d756d3d5c6b54501126793b03080a3657f64cd7889637ce73f6f38a36256c0dbee200a8204fe57743703c0407933e11993b875fa3742c01e440a
7
- data.tar.gz: 1fc63b05dd53df335802bc7cd393685303f0eb5e73e895f391c6a6c26306832a22fd1a7b61d2abf9b6b94731e876655fd1fdde1dafac0e97a544ae128ab0a63e
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.one?
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.one?
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'parser'
5
- spec.version = '1.0.0'
5
+ spec.version = '1.0.1'
6
6
  spec.authors = ['Peter Zotov']
7
7
  spec.email = ['whitequark@whitequark.org']
8
8
  spec.description = %q{A Ruby parser written in pure Ruby.}
@@ -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, s(:str, "foo"), s(:lvar, :bar)),
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, s(:sym, :foo), s(:lvar, :bar)),
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.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-17 00:00:00.000000000 Z
11
+ date: 2013-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast