mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Extend Ripper DSL to set to pseudo variables other than $$
This commit is contained in:
parent
5c81e19b19
commit
1d435bd51a
1 changed files with 6 additions and 4 deletions
|
@ -12,7 +12,11 @@ class DSL
|
|||
@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
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue