diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-20 11:07:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-20 11:07:02 +0000 |
commit | f14f0d34641ece73d77781856eed70de760f9d9f (patch) | |
tree | 365baa7371d35c633c88f27fccdff162fd08cc9b /lib | |
parent | 716ce65138a8faf2e1226eafe42b2ffb39ebfd67 (diff) |
ruby-lex.rb: fix continued line conditions
* lib/irb/ruby-lex.rb (RubyLex#lex): fix conditions for continued
line; empty lines, a semicolon, first line in `begin` block,
just after `else` are not continued.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irb/ruby-lex.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 3329c02284..fb7e08099f 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -262,9 +262,18 @@ class RubyLex end def lex - until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) && - !@continue or - tk.nil?) + continue = @continue + while tk = token + case tk + when TkNL, TkEND_OF_SCRIPT + @continue = continue unless continue.nil? + break unless @continue + when TkSPACE, TkCOMMENT + when TkSEMICOLON, TkBEGIN, TkELSE + @continue = continue = false + else + continue = nil + end end line = get_readed if line == "" and tk.kind_of?(TkEND_OF_SCRIPT) || tk.nil? |