ruby-changes:58318
From: Nobuyoshi <ko1@a...>
Date: Sat, 19 Oct 2019 17:46:56 +0900 (JST)
Subject: [ruby-changes:58318] 1d435bd51a (master): Extend Ripper DSL to set to pseudo variables other than `$$`
https://git.ruby-lang.org/ruby.git/commit/?id=1d435bd51a From 1d435bd51aeca75f6e437bc92de2271a716a1ced Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 19 Oct 2019 15:57:25 +0900 Subject: Extend Ripper DSL to set to pseudo variables other than `$$` diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb index 34b435e..925c09b 100644 --- a/ext/ripper/tools/dsl.rb +++ b/ext/ripper/tools/dsl.rb @@ -12,7 +12,11 @@ class DSL https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/dsl.rb#L12 @events = {} @error = options.include?("error") @brace = options.include?("brace") - @final = options.include?("final") + if options.include?("final") + @final = "p->result" + else + @final = (options.grep(/\A\$[$\d]\z/)[0] || "$$") + end @vars = 0 # create $1 == "$1", $2 == "$2", ... @@ -37,9 +41,7 @@ class DSL https://github.com/ruby/ruby/blob/trunk/ext/ripper/tools/dsl.rb#L41 undef class def generate - s = "$$" - s = "p->result" if @final - s = "#@code#{ s }=#@last_value;" + s = "#@code#@final=#@last_value;" s = "{VALUE #{ (1..@vars).map {|v| "v#{ v }" }.join(",") };#{ s }}" if @vars > 0 s << "ripper_error(p);" if @error s = "{#{ s }}" if @brace -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/