summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-19 15:22:36 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-19 15:22:36 +0000
commitc141a0f7e751779aa16f19e938dc49b8dec0145e (patch)
tree46152e1f4bfeedb1dc4c55af0b0bb21fe5dba838 /ext
parent25205cf8cd677865fd19ae0700ce4a17bc5534af (diff)
parse.y: swap `foo!` and `foo` in Ripper DSL
`foo!(...)` means Ripper event, and `foo(...)` means C function/macro call. This is for fail-safe; if I forget `!` accidentally, it would fail to compile, instead of wrongly adding a new Ripper event. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/ripper/tools/dsl.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb
index e67294e..dec4820 100644
--- a/ext/ripper/tools/dsl.rb
+++ b/ext/ripper/tools/dsl.rb
@@ -34,12 +34,13 @@ class DSL
s
end
- def method_missing(*args)
- if args.first =~ /!\z/
- "#{ $` }(#{ args.drop(1).join(", ") })"
+ def method_missing(event, *args)
+ if event.to_s =~ /!\z/
+ event = $`
+ @events[event] = args.size
+ "dispatch#{ args.size }(#{ [event, *args].join(", ") })"
else
- @events[args.first.to_s] = args.size - 1
- "dispatch#{ args.size - 1 }(#{ args.join(", ") })"
+ "#{ event }(#{ args.join(", ") })"
end
end
end