ruby_parser 3.2.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 3.2.1 / 2013-07-03
2
+
3
+ * 1 bug fix:
4
+
5
+ * 1.9/2.0: Trailing assocs were being munged into arrays. (presidentbeef)
6
+
1
7
  === 3.2.0 / 2013-07-02
2
8
 
3
9
  * 1 major enhancement:
data/README.txt CHANGED
@@ -13,19 +13,25 @@ base types.
13
13
 
14
14
  As an example:
15
15
 
16
- def conditional1 arg1
17
- return 1 if arg1 == 0
18
- return 0
19
- end
16
+ def conditional1 arg1
17
+ return 1 if arg1 == 0
18
+ return 0
19
+ end
20
20
 
21
21
  becomes:
22
22
 
23
- s(:defn, :conditional1, s(:args, :arg1),
24
- s(:if,
25
- s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),
26
- s(:return, s(:lit, 1)),
27
- nil),
28
- s(:return, s(:lit, 0)))
23
+ s(:defn, :conditional1, s(:args, :arg1),
24
+ s(:if,
25
+ s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),
26
+ s(:return, s(:lit, 1)),
27
+ nil),
28
+ s(:return, s(:lit, 0)))
29
+
30
+ Tested against 801,039 files from the latest of all rubygems (as of 2013-05):
31
+
32
+ * 1.8 parser is at 99.9739% accuracy, 3.651 sigma
33
+ * 1.9 parser is at 99.9940% accuracy, 4.013 sigma
34
+ * 2.0 parser is at 99.9939% accuracy, 4.008 sigma
29
35
 
30
36
  == FEATURES/PROBLEMS:
31
37
 
data/lib/ruby20_parser.rb CHANGED
@@ -4510,13 +4510,14 @@ def _reduce_244(val, _values, result)
4510
4510
  end
4511
4511
 
4512
4512
  def _reduce_245(val, _values, result)
4513
- result = args [val[0], s(:hash, *val[2].values)]
4513
+ result = args [val[0], array_to_hash(val[2])]
4514
4514
 
4515
4515
  result
4516
4516
  end
4517
4517
 
4518
4518
  def _reduce_246(val, _values, result)
4519
- result = s(:array, s(:hash, *val[0].values))
4519
+ result = args [array_to_hash(val[0])]
4520
+ result[0] = :array # TODO: switch to args?
4520
4521
 
4521
4522
  result
4522
4523
  end
@@ -4583,7 +4584,8 @@ def _reduce_257(val, _values, result)
4583
4584
  end
4584
4585
 
4585
4586
  def _reduce_258(val, _values, result)
4586
- result = call_args val
4587
+ result = call_args [val[0], array_to_hash(val[2])]
4588
+ result = self.arg_blk_pass result, val[3]
4587
4589
 
4588
4590
  result
4589
4591
  end
@@ -4753,7 +4755,7 @@ def _reduce_291(val, _values, result)
4753
4755
  end
4754
4756
 
4755
4757
  def _reduce_292(val, _values, result)
4756
- result = s(:hash, *val[1].values)
4758
+ result = s(:hash, *val[1].values) # TODO: array_to_hash?
4757
4759
 
4758
4760
  result
4759
4761
  end
data/lib/ruby20_parser.y CHANGED
@@ -794,11 +794,12 @@ rule
794
794
  }
795
795
  | args tCOMMA assocs trailer
796
796
  {
797
- result = args [val[0], s(:hash, *val[2].values)]
797
+ result = args [val[0], array_to_hash(val[2])]
798
798
  }
799
799
  | assocs trailer
800
800
  {
801
- result = s(:array, s(:hash, *val[0].values))
801
+ result = args [array_to_hash(val[0])]
802
+ result[0] = :array # TODO: switch to args?
802
803
  }
803
804
 
804
805
  paren_args: tLPAREN2 opt_call_args rparen
@@ -847,7 +848,8 @@ rule
847
848
  }
848
849
  | args tCOMMA assocs opt_block_arg
849
850
  {
850
- result = call_args val
851
+ result = call_args [val[0], array_to_hash(val[2])]
852
+ result = self.arg_blk_pass result, val[3]
851
853
  }
852
854
  | block_arg
853
855
  {
@@ -965,7 +967,7 @@ rule
965
967
  }
966
968
  | tLBRACE assoc_list tRCURLY
967
969
  {
968
- result = s(:hash, *val[1].values)
970
+ result = s(:hash, *val[1].values) # TODO: array_to_hash?
969
971
  }
970
972
  | kRETURN
971
973
  {
@@ -111,7 +111,7 @@ class RPStringScanner < StringScanner
111
111
  end
112
112
 
113
113
  module RubyParserStuff
114
- VERSION = "3.2.0" unless constants.include? "VERSION" # SIGH
114
+ VERSION = "3.2.1" unless constants.include? "VERSION" # SIGH
115
115
 
116
116
  attr_accessor :lexer, :in_def, :in_single, :file
117
117
  attr_reader :env, :comments
@@ -214,7 +214,12 @@ module RubyParserStuff
214
214
  end
215
215
 
216
216
  def array_to_hash array
217
- s(:hash, *array[1..-1])
217
+ case array.sexp_type
218
+ when :kwsplat then
219
+ array
220
+ else
221
+ s(:hash, *array[1..-1])
222
+ end
218
223
  end
219
224
 
220
225
  def call_args args
@@ -1681,6 +1681,27 @@ module TestRubyParserShared1920
1681
1681
  assert_parse rb, pt
1682
1682
  end
1683
1683
 
1684
+ def test_call_arg_assoc
1685
+ rb = "f(1, 2=>3)"
1686
+ pt = s(:call, nil, :f, s(:lit, 1), s(:hash, s(:lit, 2), s(:lit, 3)))
1687
+
1688
+ assert_parse rb, pt
1689
+ end
1690
+
1691
+ def test_call_assoc
1692
+ rb = "f(2=>3)"
1693
+ pt = s(:call, nil, :f, s(:hash, s(:lit, 2), s(:lit, 3)))
1694
+
1695
+ assert_parse rb, pt
1696
+ end
1697
+
1698
+ def test_call_assoc_new
1699
+ rb = "f(a:3)"
1700
+ pt = s(:call, nil, :f, s(:hash, s(:lit, :a), s(:lit, 3)))
1701
+
1702
+ assert_parse rb, pt
1703
+ end
1704
+
1684
1705
  def test_do_lambda
1685
1706
  rb = "->() do end"
1686
1707
  pt = s(:iter, s(:call, nil, :lambda), 0)
@@ -2750,6 +2771,13 @@ class TestRuby20Parser < RubyParserTestCase
2750
2771
  assert_parse rb, pt
2751
2772
  end
2752
2773
 
2774
+ def test_call_kwsplat
2775
+ rb = "a(**1)"
2776
+ pt = s(:call, nil, :a, s(:kwsplat, s(:lit, 1)))
2777
+
2778
+ assert_parse rb, pt
2779
+ end
2780
+
2753
2781
  def test_iter_kwarg
2754
2782
  rb = "a { |b: 1| }"
2755
2783
  pt = s(:iter, s(:call, nil, :a), s(:args, s(:kwarg, :b, s(:lit, 1))))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 2
9
- - 0
10
- version: 3.2.0
9
+ - 1
10
+ version: 3.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -136,19 +136,25 @@ description: |-
136
136
 
137
137
  As an example:
138
138
 
139
- def conditional1 arg1
140
- return 1 if arg1 == 0
141
- return 0
142
- end
139
+ def conditional1 arg1
140
+ return 1 if arg1 == 0
141
+ return 0
142
+ end
143
143
 
144
144
  becomes:
145
145
 
146
- s(:defn, :conditional1, s(:args, :arg1),
147
- s(:if,
148
- s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),
149
- s(:return, s(:lit, 1)),
150
- nil),
151
- s(:return, s(:lit, 0)))
146
+ s(:defn, :conditional1, s(:args, :arg1),
147
+ s(:if,
148
+ s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),
149
+ s(:return, s(:lit, 1)),
150
+ nil),
151
+ s(:return, s(:lit, 0)))
152
+
153
+ Tested against 801,039 files from the latest of all rubygems (as of 2013-05):
154
+
155
+ * 1.8 parser is at 99.9739% accuracy, 3.651 sigma
156
+ * 1.9 parser is at 99.9940% accuracy, 4.013 sigma
157
+ * 2.0 parser is at 99.9939% accuracy, 4.008 sigma
152
158
  email:
153
159
  - ryand-ruby@zenspider.com
154
160
  executables:
metadata.gz.sig CHANGED
@@ -1 +1,3 @@
1
- e0�ݡ�,龋}�A� ��k- ��Ŭ,2f��llw9}"V7%vH޽�ܫ���PQ]|�ezer�e�zG;3�(e縏ӫ3:k��Vy�Fa���Q'୳o����=�7:��!��V6�6��.�Hny��nUOɚsr��GG*�"���&X�׫ ����?Y��77|�t�o���/�d�"�)VP���H�E��a���;S�YF!X��^��Y-��sHgA���s��!�ug�����~���r
1
+ 5�� Gs�ڶ��)1X \5+��BCј&�%'�o�6�gf7�v�<)�g]?��J7��K���G����exE8
2
+ �g L�Ún��h��Dl+��p�;�ڟ� ���;[xF�
3
+ ~�U�6��8_أ3��� �!4�!xM��k��v�$���R���#��+�*r��