From 265b5382b21db28e52d0314ef47025f881dcbf0f Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 26 Nov 2019 14:00:08 +0900 Subject: Allow `$10` and more in the Ripper DSL --- ext/ripper/tools/dsl.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'ext/ripper/tools') diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb index 27ba87f89b..d2b9715a71 100644 --- a/ext/ripper/tools/dsl.rb +++ b/ext/ripper/tools/dsl.rb @@ -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" -- cgit v1.2.3