ruby_parser 3.6.5 → 3.6.6

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: f6eb0d6e0579b323fc21cdc6105397a480bac14d
4
- data.tar.gz: 3a8c2361d645fb32c5107670e05522d4d9f42023
3
+ metadata.gz: 09754494e04948801beb28a7a2f32a8e53ba20c5
4
+ data.tar.gz: d24103e108f923b0f0665b3bf9e367f1618f9b73
5
5
  SHA512:
6
- metadata.gz: 429098576dc2f8ca764cf19de30a756f15b6efe8845e1dee0e25e1aeb1c5bafc9247199bf759b200582f6ad9e4eaf89d0caa4db1ab8a0563b74eed5d491bfed3
7
- data.tar.gz: e2c3c8c523e35a40f27adc89506a7e93113aac369b48c9f61f03df4770c8e114c7c9226d309a613b79d3eeee3da9b11755788af01f7183cff3bc669558f6b0f4
6
+ metadata.gz: f0c22a3e4dd845e6df193ccef9cd23cb9b461070b2964a11413b6e8c30d3851d69a8cee31e472fb48d9a3e5b0ac42d0adbd6ccf1456260d7f87d8ef526588147
7
+ data.tar.gz: 43f5cfddfe50a2c212536d002f99b7bef6bca40c9e92493bca0a1caea8a8ed2847eb66be041661d7f1ab171980a75b9d33609bf24e4e7f74babcb95e86ac6c78
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- ��`ś(T���]Z:�ly���1ѿ��!
2
- �|-�(o�¡��O�dI)5���͢��g���_�B`����h"�O�lO�Y��xB���W�hw�NK�aШ��ΠQiu�[�.�N+�~XSF��U����-Lk�M�e[�g�en ��&Tcf|��_uPOm�i��k�s�_�$��ۚo�f؈ڑ�N(�������#pQ��T��H���h���@݄�v�Z%�&W�+ʒB�Z���7Vy�m�8�����
1
+ O�#f��-Ց)�ewqﳮ�*�L;�;�b"�jLR���
2
+
3
+
4
+ ��Q�!�f(S�tk��QG�k)WO��Eo��mZ�!�i<O����&V7g��8��2���ir=Ɍ^'��oF�̻��J��%k���h��0�B�En��d���D$ĝ�/�9�&k�980w44<�_=�@��ލ)VmK� D���Bn6@7��Ki�����O"$�Z\�RN21�~D�J�9Z�A8��w��[3�4��O۲oYf�@1�~���
data.tar.gz.sig CHANGED
Binary file
data/History.txt CHANGED
@@ -1,3 +1,17 @@
1
+ === 3.6.6 / 2015-04-13
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Added expr_labelarg state (eg: a:1)
6
+
7
+ * 5 bug fixes:
8
+
9
+ * Fix scan logging backtrace when DEBUG=1
10
+ * Fixed kwsplat on 2.0 & 2.1.
11
+ * Fixed mandatory keyword block args. (cvortmann)
12
+ * Handle #$<x> in expanded strings/regexps where x is NOT a valid gvar name.
13
+ * Invalid gvar names raise a compile error.
14
+
1
15
  === 3.6.5 / 2015-03-12
2
16
 
3
17
  * 1 minor enhancement:
data/Rakefile CHANGED
@@ -79,9 +79,9 @@ task :isolate => :phony
79
79
  task "compare#{v}" do
80
80
  sh "./yack.rb lib/ruby#{v}_parser.output > racc#{v}.txt"
81
81
  sh "./yack.rb parse#{v}.output > yacc#{v}.txt"
82
- sh "diff -du racc#{v}.txt yacc#{v}.txt || true"
82
+ sh "diff -du yacc#{v}.txt racc#{v}.txt || true"
83
83
  puts
84
- sh "diff -du racc#{v}.txt yacc#{v}.txt | wc -l"
84
+ sh "diff -du yacc#{v}.txt racc#{v}.txt | wc -l"
85
85
  end
86
86
  end
87
87
 
data/lib/ruby20_parser.rb CHANGED
@@ -6584,7 +6584,7 @@ def _reduce_589(val, _values, result)
6584
6584
  end
6585
6585
 
6586
6586
  def _reduce_590(val, _values, result)
6587
- result = s(:kwsplat, val[1])
6587
+ result = s(:array, s(:kwsplat, val[1]))
6588
6588
 
6589
6589
  result
6590
6590
  end
data/lib/ruby20_parser.y CHANGED
@@ -2292,7 +2292,7 @@ keyword_variable: kNIL { result = s(:nil) }
2292
2292
  }
2293
2293
  | tDSTAR arg_value
2294
2294
  {
2295
- result = s(:kwsplat, val[1])
2295
+ result = s(:array, s(:kwsplat, val[1]))
2296
2296
  }
2297
2297
 
2298
2298
  operation: tIDENTIFIER | tCONSTANT | tFID
data/lib/ruby21_parser.rb CHANGED
@@ -6479,7 +6479,11 @@ def _reduce_560(val, _values, result)
6479
6479
  end
6480
6480
 
6481
6481
  def _reduce_561(val, _values, result)
6482
- raise "fuck 11"
6482
+ label, _ = val[0] # TODO: fix lineno?
6483
+ identifier = label.to_sym
6484
+ self.env[identifier] = :lvar
6485
+
6486
+ result = s(:array, s(:kwarg, identifier))
6483
6487
 
6484
6488
  result
6485
6489
  end
@@ -6655,7 +6659,7 @@ def _reduce_593(val, _values, result)
6655
6659
  end
6656
6660
 
6657
6661
  def _reduce_594(val, _values, result)
6658
- result = s(:kwsplat, val[1])
6662
+ result = s(:array, s(:kwsplat, val[1]))
6659
6663
 
6660
6664
  result
6661
6665
  end
data/lib/ruby21_parser.y CHANGED
@@ -2172,7 +2172,11 @@ keyword_variable: kNIL { result = s(:nil) }
2172
2172
  }
2173
2173
  | f_label
2174
2174
  {
2175
- raise "fuck 11"
2175
+ label, _ = val[0] # TODO: fix lineno?
2176
+ identifier = label.to_sym
2177
+ self.env[identifier] = :lvar
2178
+
2179
+ result = s(:array, s(:kwarg, identifier))
2176
2180
  }
2177
2181
 
2178
2182
  f_block_kwarg: f_block_kw
@@ -2307,7 +2311,7 @@ keyword_variable: kNIL { result = s(:nil) }
2307
2311
  }
2308
2312
  | tDSTAR arg_value
2309
2313
  {
2310
- result = s(:kwsplat, val[1])
2314
+ result = s(:array, s(:kwsplat, val[1]))
2311
2315
  }
2312
2316
 
2313
2317
  operation: tIDENTIFIER | tCONSTANT | tFID
data/lib/ruby_lexer.rb CHANGED
@@ -271,7 +271,7 @@ class RubyLexer
271
271
  end
272
272
 
273
273
  def is_beg?
274
- in_lex_state? :expr_beg, :expr_value, :expr_mid, :expr_class
274
+ in_lex_state? :expr_beg, :expr_value, :expr_mid, :expr_class, :expr_labelarg
275
275
  end
276
276
 
277
277
  def is_end?
@@ -406,7 +406,8 @@ class RubyLexer
406
406
  end
407
407
 
408
408
  def process_gvar_oddity text
409
- result :expr_end, "$", "$" # TODO: wtf is this?
409
+ return result :expr_end, "$", "$" if text == "$" # TODO: wtf is this?
410
+ rb_compile_error "#{text.inspect} is not allowed as a global variable name"
410
411
  end
411
412
 
412
413
  def process_ivar text
@@ -673,7 +674,7 @@ class RubyLexer
673
674
  end
674
675
 
675
676
  if !ruby18 and is_label_possible? and scan(/:(?!:)/) then
676
- return result(:expr_beg, :tLABEL, [token, self.lineno])
677
+ return result(:expr_labelarg, :tLABEL, [token, self.lineno])
677
678
  end
678
679
 
679
680
  unless in_lex_state? :expr_dot then
@@ -1144,7 +1145,12 @@ class RubyLexer
1144
1145
 
1145
1146
  if expand
1146
1147
  case
1147
- when scan(/#(?=[$@])/) then
1148
+ when scan(/#(?=\$(-.|[a-zA-Z_0-9~\*\$\?!@\/\\;,\.=:<>\"\&\`\'+]))/) then
1149
+ # TODO: !ISASCII
1150
+ # ?! see parser_peek_variable_name
1151
+ return :tSTRING_DVAR, nil
1152
+ when scan(/#(?=\@\@?[a-zA-Z_])/) then
1153
+ # TODO: !ISASCII
1148
1154
  return :tSTRING_DVAR, nil
1149
1155
  when scan(/#[{]/) then
1150
1156
  return :tSTRING_DBEG, nil
data/lib/ruby_lexer.rex CHANGED
@@ -92,6 +92,7 @@ rule
92
92
 
93
93
  /\[/ process_square_bracket
94
94
 
95
+ # 2.2: /\'#{SSTRING}\':/o process_symbol
95
96
  /\'#{SSTRING}\'/o { result :expr_end, :tSTRING, matched[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'") } # " stupid emacs
96
97
 
97
98
  : /\|/
@@ -79,7 +79,7 @@ class RPStringScanner < StringScanner
79
79
  alias :old_scan :scan
80
80
  def scan re
81
81
  s = old_scan re
82
- where = caller.first.split(/:/).first(2).join(":")
82
+ where = caller[1].split(/:/).first(2).join(":")
83
83
  d :scan => [s, where] if s
84
84
  s
85
85
  end
@@ -91,7 +91,7 @@ class RPStringScanner < StringScanner
91
91
  end
92
92
 
93
93
  module RubyParserStuff
94
- VERSION = "3.6.5" unless constants.include? "VERSION" # SIGH
94
+ VERSION = "3.6.6" unless constants.include? "VERSION" # SIGH
95
95
 
96
96
  attr_accessor :lexer, :in_def, :in_single, :file
97
97
  attr_reader :env, :comments
@@ -298,7 +298,7 @@ class TestRubyLexer < Minitest::Test
298
298
  assert_lex3("{a:",
299
299
  nil,
300
300
  :tLBRACE, "{", :expr_beg,
301
- :tLABEL, "a", :expr_beg)
301
+ :tLABEL, "a", :expr_labelarg)
302
302
  end
303
303
 
304
304
  def test_yylex_label_in_params__19
@@ -308,7 +308,7 @@ class TestRubyLexer < Minitest::Test
308
308
  nil,
309
309
  :tIDENTIFIER, "foo", :expr_cmdarg,
310
310
  :tLPAREN2, "(", :expr_beg,
311
- :tLABEL, "a", :expr_beg)
311
+ :tLABEL, "a", :expr_labelarg)
312
312
  end
313
313
 
314
314
  def test_yylex_paren_string_parens_interpolated
@@ -852,9 +852,13 @@ class TestRubyLexer < Minitest::Test
852
852
  end
853
853
  end
854
854
 
855
- def test_yylex_dollar
856
- assert_lex3("$", nil, "$", "$", :expr_end)
857
- # FIX: wtf is this?!?
855
+ def test_yylex_dollar_bad
856
+ e = refute_lex("$%")
857
+ assert_includes(e.message, "is not allowed as a global variable name")
858
+ end
859
+
860
+ def test_yylex_dollar_eos
861
+ assert_lex3("$", nil, "$", "$", :expr_end) # FIX: wtf is this?!?
858
862
  end
859
863
 
860
864
  def test_yylex_dot # HINT message sends
@@ -2289,6 +2293,14 @@ class TestRubyLexer < Minitest::Test
2289
2293
  :tSTRING_END, "\"", :expr_end)
2290
2294
  end
2291
2295
 
2296
+ def test_yylex_string_double_pound_dollar_bad
2297
+ assert_lex3('"#$%"', nil,
2298
+
2299
+ :tSTRING_BEG, "\"", :expr_beg,
2300
+ :tSTRING_CONTENT, "#$%", :expr_beg,
2301
+ :tSTRING_END, "\"", :expr_end)
2302
+ end
2303
+
2292
2304
  def test_yylex_string_double_nested_curlies
2293
2305
  assert_lex3("%{nest{one{two}one}nest}",
2294
2306
  nil,
@@ -2611,6 +2623,35 @@ class TestRubyLexer < Minitest::Test
2611
2623
  end
2612
2624
  end
2613
2625
 
2626
+ def test_yylex_sym_quoted
2627
+ assert_lex(":'a'",
2628
+ s(:lit, :a),
2629
+
2630
+ :tSYMBOL, "a", :expr_end, 0, 0)
2631
+ end
2632
+
2633
+ def test_yylex_hash_colon
2634
+ assert_lex("{a:1}",
2635
+ s(:hash, s(:lit, :a), s(:lit, 1)),
2636
+
2637
+ :tLBRACE, "{", :expr_beg, 0, 1,
2638
+ :tLABEL, "a", :expr_labelarg, 0, 1,
2639
+ :tINTEGER, 1, :expr_end, 0, 1,
2640
+ :tRCURLY, "}", :expr_endarg, 0, 0)
2641
+ end
2642
+
2643
+ def test_yylex_hash_colon_quoted_22
2644
+ skip "Waiting for 2.2 parser"
2645
+
2646
+ assert_lex("{'a':1}",
2647
+ s(:hash, s(:lit, :a), s(:lit, 1)),
2648
+
2649
+ :tLBRACE, "{", :expr_beg, 0, 1,
2650
+ :tSYMBOL, "a", :expr_end, 0, 1,
2651
+ :tINTEGER, 1, :expr_end, 0, 1,
2652
+ :tRCURLY, "}", :expr_endarg, 0, 0)
2653
+ end
2654
+
2614
2655
  def test_ruby21_new_numbers
2615
2656
  skip "Don't have imaginary and rational literal lexing yet"
2616
2657
 
@@ -2142,21 +2142,30 @@ module TestRubyParserShared20to21
2142
2142
  def test_defn_kwarg_env
2143
2143
  rb = "def test(**testing) test_splat(**testing) end"
2144
2144
  pt = s(:defn, :test, s(:args, :"**testing"),
2145
- s(:call, nil, :test_splat, s(:kwsplat, s(:lvar, :testing))))
2145
+ s(:call, nil, :test_splat, s(:hash, s(:kwsplat, s(:lvar, :testing)))))
2146
2146
 
2147
2147
  assert_parse rb, pt
2148
2148
  end
2149
2149
 
2150
2150
  def test_call_arg_kwsplat
2151
2151
  rb = "a(b, **1)"
2152
- pt = s(:call, nil, :a, s(:call, nil, :b), s(:kwsplat, s(:lit, 1)))
2152
+ pt = s(:call, nil, :a, s(:call, nil, :b), s(:hash, s(:kwsplat, s(:lit, 1))))
2153
+
2154
+ assert_parse rb, pt
2155
+ end
2156
+
2157
+ def test_call_arg_assoc_kwsplat
2158
+ rb = "f(1, kw: 2, **3)"
2159
+ pt = s(:call, nil, :f,
2160
+ s(:lit, 1),
2161
+ s(:hash, s(:lit, :kw), s(:lit, 2), s(:kwsplat, s(:lit, 3))))
2153
2162
 
2154
2163
  assert_parse rb, pt
2155
2164
  end
2156
2165
 
2157
2166
  def test_call_kwsplat
2158
2167
  rb = "a(**1)"
2159
- pt = s(:call, nil, :a, s(:kwsplat, s(:lit, 1)))
2168
+ pt = s(:call, nil, :a, s(:hash, s(:kwsplat, s(:lit, 1))))
2160
2169
 
2161
2170
  assert_parse rb, pt
2162
2171
  end
@@ -3228,16 +3237,55 @@ class TestRuby21Parser < RubyParserTestCase
3228
3237
  end
3229
3238
 
3230
3239
  def test_block_kw
3240
+ rb = "blah { |k:42| }"
3241
+ pt = s(:iter, s(:call, nil, :blah), s(:args, s(:kwarg, :k, s(:lit, 42))))
3242
+
3243
+ assert_parse rb, pt
3244
+
3245
+ rb = "blah { |k:42| }"
3246
+ assert_parse rb, pt
3247
+ end
3248
+
3249
+ def test_block_kw__required
3250
+ rb = "blah do |k:| end"
3251
+ pt = s(:iter, s(:call, nil, :blah), s(:args, s(:kwarg, :k)))
3252
+
3253
+ assert_parse rb, pt
3254
+
3255
+ rb = "blah do |k:| end"
3256
+ assert_parse rb, pt
3257
+ end
3258
+
3259
+ def test_stabby_block_kw
3231
3260
  rb = "-> (k:42) { }"
3232
3261
  pt = s(:iter, s(:call, nil, :lambda), s(:args, s(:kwarg, :k, s(:lit, 42))))
3233
3262
 
3234
3263
  assert_parse rb, pt
3235
3264
  end
3236
3265
 
3237
- def test_block_kw__required
3266
+ def test_stabby_block_kw__required
3238
3267
  rb = "-> (k:) { }"
3239
3268
  pt = s(:iter, s(:call, nil, :lambda), s(:args, s(:kwarg, :k)))
3240
3269
 
3241
3270
  assert_parse rb, pt
3242
3271
  end
3272
+
3273
+ def test_parse_line_heredoc_hardnewline
3274
+ skip "not yet"
3275
+
3276
+ rb = <<-'CODE'.gsub(/^ /, '')
3277
+ <<-EOFOO
3278
+ \n\n\n\n\n\n\n\n\n
3279
+ EOFOO
3280
+
3281
+ class Foo
3282
+ end
3283
+ CODE
3284
+
3285
+ pt = s(:block,
3286
+ s(:str, "\n\n\n\n\n\n\n\n\n\n").line(1),
3287
+ s(:class, :Foo, nil).line(5)).line(1)
3288
+
3289
+ assert_parse rb, pt
3290
+ end
3243
3291
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.5
4
+ version: 3.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -29,7 +29,7 @@ cert_chain:
29
29
  xJcC6UN6NHMOVMyAXsr2HR0gRRx4ofN1LoP2KhXzSr8UMvQYlwPmE0N5GQv1b5AO
30
30
  VpzF30vNaJK6ZT7xlIsIlwmH
31
31
  -----END CERTIFICATE-----
32
- date: 2015-03-12 00:00:00.000000000 Z
32
+ date: 2015-04-13 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -51,14 +51,14 @@ dependencies:
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '5.5'
54
+ version: '5.6'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '5.5'
61
+ version: '5.6'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rdoc
64
64
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file