summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-05-12 18:52:26 +0900
committerNobuyoshi Nakada <[email protected]>2024-05-21 13:52:29 +0900
commit66446b94358a78ddd168e5ce0b5ac475bb34ec50 (patch)
tree96ef2973da06bd50b1f312bf8094b287f54e1a43
parent47efdae6028e39bbe8f35d325e26e6bc206251ef (diff)
ripper: Allow parenthesized comma in options
-rw-r--r--ext/ripper/tools/dsl.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb
index 4815364c92..b55952cbee 100644
--- a/ext/ripper/tools/dsl.rb
+++ b/ext/ripper/tools/dsl.rb
@@ -22,10 +22,15 @@ class DSL
def self.line?(line, lineno = nil, indent: nil)
if %r<(?<space>\s*)/\*% *ripper(?:\[(?<option>.*?)\])?: *(?<code>.*?) *%\*/> =~ line
- new(code, option&.split(",") || [], lineno, indent: indent || space)
+ new(code, comma_split(option), lineno, indent: indent || space)
end
end
+ def self.comma_split(str)
+ str or return []
+ str.scan(/(([^(,)]+|\((?:,|\g<0>)*\))+)/).map(&:first)
+ end
+
using Module.new {
refine Array do
def to_s