1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Allow $10 and more in the Ripper DSL

This commit is contained in:
Nobuyoshi Nakada 2019-11-26 14:00:08 +09:00
parent 7db719c516
commit 265b5382b2
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60

View file

@ -15,17 +15,14 @@ class DSL
if options.include?("final")
@final = "p->result"
else
@final = (options.grep(/\A\$[$\d]\z/)[0] || "$$")
@final = (options.grep(/\A\$(?:\$|\d+)\z/)[0] || "$$")
end
@vars = 0
# create $1 == "$1", $2 == "$2", ...
re, s = "", ""
1.upto(9) do |n|
re << "(..)"
s << "$#{ n }"
end
/#{ re }/ =~ s
s = (1..20).map {|n| "$#{n}"}
re = Array.new(s.size, "([^\0]+)")
/#{re.join("\0")}/ =~ s.join("\0")
# struct parser_params *p
p = p = "p"