ruby_parser
Advanced tools
+6
-0
@@ -0,1 +1,7 @@ | ||
| === 3.2.1 / 2013-07-03 | ||
| * 1 bug fix: | ||
| * 1.9/2.0: Trailing assocs were being munged into arrays. (presidentbeef) | ||
| === 3.2.0 / 2013-07-02 | ||
@@ -2,0 +8,0 @@ |
@@ -114,3 +114,3 @@ # encoding: ASCII-8BIT | ||
| module RubyParserStuff | ||
| VERSION = "3.2.0" unless constants.include? "VERSION" # SIGH | ||
| VERSION = "3.2.1" unless constants.include? "VERSION" # SIGH | ||
@@ -218,3 +218,8 @@ attr_accessor :lexer, :in_def, :in_single, :file | ||
| def array_to_hash array | ||
| s(:hash, *array[1..-1]) | ||
| case array.sexp_type | ||
| when :kwsplat then | ||
| array | ||
| else | ||
| s(:hash, *array[1..-1]) | ||
| end | ||
| end | ||
@@ -221,0 +226,0 @@ |
+16
-10
@@ -16,16 +16,22 @@ = ruby_parser | ||
| def conditional1 arg1 | ||
| return 1 if arg1 == 0 | ||
| return 0 | ||
| end | ||
| def conditional1 arg1 | ||
| return 1 if arg1 == 0 | ||
| return 0 | ||
| end | ||
| becomes: | ||
| s(:defn, :conditional1, s(:args, :arg1), | ||
| s(:if, | ||
| s(:call, s(:lvar, :arg1), :==, s(:lit, 0)), | ||
| s(:return, s(:lit, 1)), | ||
| nil), | ||
| s(:return, s(:lit, 0))) | ||
| s(:defn, :conditional1, s(:args, :arg1), | ||
| s(:if, | ||
| s(:call, s(:lvar, :arg1), :==, s(:lit, 0)), | ||
| s(:return, s(:lit, 1)), | ||
| nil), | ||
| s(:return, s(:lit, 0))) | ||
| Tested against 801,039 files from the latest of all rubygems (as of 2013-05): | ||
| * 1.8 parser is at 99.9739% accuracy, 3.651 sigma | ||
| * 1.9 parser is at 99.9940% accuracy, 4.013 sigma | ||
| * 2.0 parser is at 99.9939% accuracy, 4.008 sigma | ||
| == FEATURES/PROBLEMS: | ||
@@ -32,0 +38,0 @@ |
@@ -1684,2 +1684,23 @@ #!/usr/local/bin/ruby | ||
| def test_call_arg_assoc | ||
| rb = "f(1, 2=>3)" | ||
| pt = s(:call, nil, :f, s(:lit, 1), s(:hash, s(:lit, 2), s(:lit, 3))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_call_assoc | ||
| rb = "f(2=>3)" | ||
| pt = s(:call, nil, :f, s(:hash, s(:lit, 2), s(:lit, 3))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_call_assoc_new | ||
| rb = "f(a:3)" | ||
| pt = s(:call, nil, :f, s(:hash, s(:lit, :a), s(:lit, 3))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_do_lambda | ||
@@ -2754,2 +2775,9 @@ rb = "->() do end" | ||
| def test_call_kwsplat | ||
| rb = "a(**1)" | ||
| pt = s(:call, nil, :a, s(:kwsplat, s(:lit, 1))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_kwarg | ||
@@ -2756,0 +2784,0 @@ rb = "a { |b: 1| }" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet