diff --git a/ChangeLog b/ChangeLog index e48620a64b..938501b8d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 23 17:31:02 2009 Keiju Ishitsuka + + * lib/irb/ruby-lex.rb: make irb be able to parse + string_dvar. [ruby-core: 24051] + Thu Jul 23 17:26:51 2009 Hidetoshi NAGAI * ext/tk/extconf.rb: should not create "config_list" in a $srcdir. @@ -89,7 +94,7 @@ Wed Jul 22 06:35:56 2009 Yukihiro Matsumoto * test/ruby/test_enum.rb (TestEnumerable#each): recursive join now raises ArgumentError. -Wed Jul 22 02:33:57 2009 Keiju Ishitsuka +Wed Jul 22 02:33:57 2009 Keiju Ishitsuka * lib/irb.rb: forget svn commit. diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index b36629b38e..c758f1dcf2 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -1047,6 +1047,8 @@ class RubyLex while ch = getc if @quoted == ch and nest == 0 break + elsif ch == "#" and peek(0) == "{" + identify_string_dvar elsif @ltype != "'" && @ltype != "]" && @ltype != ":" and ch == "#" subtype = true elsif ch == '\\' and @ltype == "'" #' @@ -1083,6 +1085,42 @@ class RubyLex end end + def identify_string_dvar + begin + getc + + reserve_continue = @continue + reserve_ltype = @ltype + reserve_indent = @indent + reserve_indent_stack = @indent_stack + reserve_state = @lex_state + reserve_quoted = @quoted + + @ltype = nil + @quoted = nil + @indent = 0 + @indent_stack = [] + @lex_state = EXPR_BEG + + loop do + @continue = false + prompt + tk = token + if @ltype or @continue or @indent > 0 + next + end + break if tk.kind_of?(TkRBRACE) + end + ensure + @continue = reserve_continue + @ltype = reserve_ltype + @indent = reserve_indent + @indent_stack = reserve_indent_stack + @lex_state = reserve_state + @quoted = reserve_quoted + end + end + def identify_comment @ltype = "#"