1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

merges r30805 and r30809 from trunk into ruby_1_9_2. fixes #4365

--
* 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/branches/ruby_1_9_2@31510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2011-05-11 21:23:24 +00:00
parent b7db271c02
commit 5b0cef85ac
5 changed files with 53 additions and 12 deletions

View file

@ -1,3 +1,8 @@
Sun Feb 6 12:18:25 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (words, qwords): dispatch array events. based on a
patch from Michael Edgar. [Bug #4365].
Sat Feb 5 21:47:09 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (mlhs_basic): include mlhs_post for ripper. a patch

10
parse.y
View file

@ -3938,11 +3938,16 @@ words : tWORDS_BEG ' ' tSTRING_END
$$ = NEW_ZARRAY();
/*%
$$ = dispatch0(words_new);
$$ = dispatch1(array, $$);
%*/
}
| tWORDS_BEG word_list tSTRING_END
{
/*%%%*/
$$ = $2;
/*%
$$ = dispatch1(array, $2);
%*/
}
;
@ -3988,11 +3993,16 @@ qwords : tQWORDS_BEG ' ' tSTRING_END
$$ = NEW_ZARRAY();
/*%
$$ = dispatch0(qwords_new);
$$ = dispatch1(array, $$);
%*/
}
| tQWORDS_BEG qword_list tSTRING_END
{
/*%%%*/
$$ = $2;
/*%
$$ = dispatch1(array, $2);
%*/
}
;

View file

@ -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,30 @@ class DummyParser < Ripper
Node.new('assocs', *a)
end
def on_word_new
""
end
def on_word_add(word, w)
word << w
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)

View file

@ -160,6 +160,8 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
def test_array # array literal
assert_equal '[array([1,2,3])]', parse('[1,2,3]')
assert_equal '[array([abc,def])]', parse('%w[abc def]')
assert_equal '[array([abc,def])]', parse('%W[abc def]')
end
def test_assign # generic assignment

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2"
#define RUBY_PATCHLEVEL 194
#define RUBY_PATCHLEVEL 195
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1