From b5be3e78938ba17d389df1c8f4bdbcc8b4c73550 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 20 Jan 2018 05:39:02 +0000 Subject: [PATCH] dsl.rb: ID constants * ext/ripper/tools/dsl.rb (DSL#method_missing): expand ID constnats without parentheses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/ripper/tools/dsl.rb | 2 ++ parse.y | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb index 848bd2fa31..0997a09309 100644 --- a/ext/ripper/tools/dsl.rb +++ b/ext/ripper/tools/dsl.rb @@ -43,6 +43,8 @@ class DSL event = $` @events[event] = args.size "dispatch#{ args.size }(#{ [event, *args].join(", ") })" + elsif args.empty? and /\Aid[A-Z]/ =~ event.to_s + event else "#{ event }(#{ args.join(", ") })" end diff --git a/parse.y b/parse.y index d78bd2f837..16ef15abe7 100644 --- a/parse.y +++ b/parse.y @@ -1646,7 +1646,7 @@ lhs : user_variable /*%%%*/ $$ = attrset(p, $1, idCOLON2, $3, &@$); /*% %*/ - /*% ripper: field!($1, "ID2VAL(idCOLON2)", $3) %*/ + /*% ripper: field!($1, ID2VAL(idCOLON2), $3) %*/ } | primary_value call_op tCONSTANT { @@ -3613,7 +3613,7 @@ numeric : simple_numeric $$ = $2; add_mark_object(p, $$->nd_lit = negate_lit(p, $$->nd_lit)); /*% %*/ - /*% ripper: unary!("ID2VAL(idUMinus)", $2) %*/ + /*% ripper: unary!(ID2VAL(idUMinus), $2) %*/ } ;