From cb7f49faaa88948ed4bba752847bd2e6b9d81dc4 Mon Sep 17 00:00:00 2001 From: keiju Date: Tue, 8 May 2001 09:28:19 +0000 Subject: *** empty log message *** git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/irb/ruby-lex.rb | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'lib/irb/ruby-lex.rb') diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index e92b45b15..3a862002a 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -24,6 +24,8 @@ class RubyLex def_exception(:TkReading2TokenDuplicateError, "key duplicate(token_n='%s', key='%s')") def_exception(:SyntaxError, "%s") + + def_exception(:TerminateLineInput, "Terminate Line Input") include RubyToken @@ -211,27 +213,35 @@ class RubyLex def each_top_level_statement initialize_input - loop do - @continue = false - prompt - unless l = lex - break if @line == '' - else - # p l - @line.concat l - if @ltype or @continue or @indent > 0 - next + catch(:TERM_INPUT) do + loop do + begin + @continue = false + prompt + unless l = lex + throw :TERM_INPUT if @line == '' + else + #p l + @line.concat l + if @ltype or @continue or @indent > 0 + next + end + end + if @line != "\n" + yield @line, @exp_line_no + end + break unless l + @line = '' + @exp_line_no = @line_no + + @indent = 0 + prompt + rescue TerminateLineInput + initialize_input + prompt + get_readed end end - if @line != "\n" - yield @line, @exp_line_no - end - break unless l - @line = '' - @exp_line_no = @line_no - - @indent = 0 - prompt end end -- cgit