mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y (words, qwords): dispatch array events. based on a
patch from Michael Edgar. [Bug #4365]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
58195557b2
commit
b1986003bd
4 changed files with 44 additions and 11 deletions
|
@ -130,44 +130,44 @@ class DummyParser < Ripper
|
|||
on_args_add_block(m.children, b)
|
||||
m
|
||||
end
|
||||
|
||||
|
||||
def on_paren(params)
|
||||
params
|
||||
end
|
||||
|
||||
|
||||
def on_brace_block(params, code)
|
||||
Node.new('block', params, code)
|
||||
end
|
||||
|
||||
|
||||
def on_block_var(params, shadow)
|
||||
params
|
||||
end
|
||||
|
||||
|
||||
def on_rest_param(var)
|
||||
"*#{var}"
|
||||
end
|
||||
|
||||
|
||||
def on_blockarg(var)
|
||||
"&#{var}"
|
||||
end
|
||||
|
||||
|
||||
def on_params(required, optional, rest, more, block)
|
||||
args = NodeList.new
|
||||
|
||||
|
||||
required.each do |req|
|
||||
args.push(req)
|
||||
end if required
|
||||
|
||||
|
||||
optional.each do |var, val|
|
||||
args.push("#{var}=#{val}")
|
||||
end if optional
|
||||
|
||||
|
||||
args.push(rest) if rest
|
||||
|
||||
|
||||
more.each do |m|
|
||||
args.push(m)
|
||||
end if more
|
||||
|
||||
|
||||
args.push(block) if block
|
||||
args
|
||||
end
|
||||
|
@ -184,6 +184,22 @@ class DummyParser < Ripper
|
|||
Node.new('assocs', *a)
|
||||
end
|
||||
|
||||
def on_words_new
|
||||
NodeList.new
|
||||
end
|
||||
|
||||
def on_words_add(words, word)
|
||||
words.push word
|
||||
end
|
||||
|
||||
def on_qwords_new
|
||||
NodeList.new
|
||||
end
|
||||
|
||||
def on_qwords_add(words, word)
|
||||
words.push word
|
||||
end
|
||||
|
||||
(Ripper::PARSER_EVENTS.map(&:to_s) - instance_methods(false).map {|n|n.to_s.sub(/^on_/, '')}).each do |event|
|
||||
define_method(:"on_#{event}") do |*args|
|
||||
Node.new(event, *args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue