From 7a978073c9160e6ed1c706aaf034b2c4c4d104e1 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 19 Nov 2007 07:10:09 +0000 Subject: * parse.y (parser_yylex): should clear parser->tokp as well. [ruby-dev:32250] * parse.y: remove NEED_ASSOC that break test_parser_events. * parse.y (parser_yylex): should not decrement line numbers at the end of file. * file.c (rb_find_file_ext): search .rb files first through in the loadpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 13 ++++++++ ext/ripper/lib/ripper/lexer.rb | 2 +- file.c | 18 +++++----- parse.y | 56 ++++++++++++++----------------- test/ripper/dummyparser.rb | 70 ++++++++++++++++++++++++++++++++++----- test/ripper/test_files.rb | 2 +- test/ripper/test_parser_events.rb | 2 +- 7 files changed, 112 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index f03870f755..39d885dcea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,19 @@ Sat Nov 17 23:51:29 2007 Masaki Suketa * ext/win32ole/win32ole.c (ole_invoke): bug fix. [ruby-talk:279100] +Sat Nov 17 23:21:15 2007 Yukihiro Matsumoto + + * parse.y (parser_yylex): should clear parser->tokp as well. + [ruby-dev:32250] + + * parse.y: remove NEED_ASSOC that break test_parser_events. + + * parse.y (parser_yylex): should not decrement line numbers at the + end of file. + + * file.c (rb_find_file_ext): search .rb files first through in the + loadpath. + Fri Nov 16 23:31:18 2007 Yukihiro Matsumoto * bignum.c (rb_big_odd_p): new method added. a patch from Tadashi diff --git a/ext/ripper/lib/ripper/lexer.rb b/ext/ripper/lib/ripper/lexer.rb index 22048f161c..14ef99f034 100644 --- a/ext/ripper/lib/ripper/lexer.rb +++ b/ext/ripper/lib/ripper/lexer.rb @@ -23,7 +23,7 @@ class Ripper # require 'ripper' # require 'pp' # - # p Ripper.scan("def m(a) nil end") + # p Ripper.lex("def m(a) nil end") # #=> [[[1, 0], :on_kw, "def"], # [[1, 3], :on_sp, " " ], # [[1, 4], :on_ident, "m" ], diff --git a/file.c b/file.c index 903e744811..3127ecde6b 100644 --- a/file.c +++ b/file.c @@ -4197,16 +4197,16 @@ rb_find_file_ext(VALUE *filep, const char *const *ext) if (!rb_load_path) return 0; Check_Type(rb_load_path, T_ARRAY); - for (i=0;itokp = lex_p; + } +#endif goto normal_newline; } } diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb index 31fcafb159..483ac0d013 100644 --- a/test/ripper/dummyparser.rb +++ b/test/ripper/dummyparser.rb @@ -30,7 +30,7 @@ class NodeList end def prepend(items) - @list[0,0] = items + @list.unshift items end def to_s @@ -98,32 +98,44 @@ class DummyParser < Ripper args end - def on_arglist_new + def on_args_new NodeList.new end - def on_arglist_add(list, arg) + def on_args_add(list, arg) list.push(arg) end - def on_arglist_add_block(list, blk) - list.push('&' + blk.to_s) + def on_args_add_block(list, blk) + if blk + list.push('&' + blk.to_s) + else + list + end end - def on_arglist_add_star(list, arg) + def on_args_add_star(list, arg) list.push('*' + arg.to_s) end - def on_arglist_prepend(list, args) + def on_args_prepend(list, args) list.prepend args list end def on_method_add_arg(m, arg) + if arg == nil + arg = on_args_new + end m.children.push arg m end + def on_method_add_block(m, b) + on_args_add_block(m.children, b) + m + end + def on_assoc_new(a, b) Node.new('assoc', a, b) end @@ -390,7 +402,7 @@ class DummyParser < Ripper Node.new('sclass', a, b) end - def on_space(a) + def on_sp(a) Node.new('space', a) end @@ -514,4 +526,46 @@ class DummyParser < Ripper Node.new('zsuper') end + def on_backref(a) + a + end + def on_comma(a) + a + end + def on_gvar(a) + a + end + def on_ident(a) + a + end + def on_int(a) + a + end + def on_kw(a) + a + end + def on_lbrace(a) + a + end + def on_rbrace(a) + a + end + def on_lbracket(a) + a + end + def on_rbracket(a) + a + end + def on_lparen(a) + a + end + def on_rparen(a) + a + end + def on_op(a) + a + end + def on_semicolon(a) + a + end end diff --git a/test/ripper/test_files.rb b/test/ripper/test_files.rb index e5ccaf4b06..c2d7a50a3f 100644 --- a/test/ripper/test_files.rb +++ b/test/ripper/test_files.rb @@ -22,4 +22,4 @@ end rescue LoadError end - \ No newline at end of file + diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index a5d6a62f66..fa640a37ec 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -495,4 +495,4 @@ class TestRipper_ParserEvents < Test::Unit::TestCase end rescue LoadError -end \ No newline at end of file +end -- cgit v1.2.3