diff options
author | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-08 09:28:19 +0000 |
---|---|---|
committer | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-05-08 09:28:19 +0000 |
commit | 3c1264113ea52594940ce970fba2dc4eb83d5075 (patch) | |
tree | ea224162e950ca78a2c749bec583d74f7b256038 /lib/irb/ruby-lex.rb | |
parent | 6ea874604879ce674ac54fb519489d427e3749a2 (diff) | |
download | ruby-3c1264113ea52594940ce970fba2dc4eb83d5075.tar.gz |
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb/ruby-lex.rb')
-rw-r--r-- | lib/irb/ruby-lex.rb | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index e92b45b151..3a862002a6 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 |