diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-11-26 14:00:08 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-11-26 21:57:00 +0900 |
commit | 265b5382b21db28e52d0314ef47025f881dcbf0f (patch) | |
tree | 6504ac87c91f0576113db3f4f8899c8ff4223053 /ext/ripper | |
parent | 7db719c51652f0de6cae079c6ce0723dd00a9939 (diff) | |
download | ruby-265b5382b21db28e52d0314ef47025f881dcbf0f.tar.gz |
Allow `$10` and more in the Ripper DSL
Diffstat (limited to 'ext/ripper')
-rw-r--r-- | ext/ripper/tools/dsl.rb | 11 |
1 files changed, 4 insertions, 7 deletions
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" |