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