diff options
author | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-04 10:06:17 +0000 |
---|---|---|
committer | keiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-04 10:06:17 +0000 |
commit | c5f550c06918c7a0158f8f4e843b4a16dfb03c8a (patch) | |
tree | bb11a122fb28b83f64305c69ec10a3b986961216 /lib/irb/ruby-lex.rb | |
parent | d040c69a585f2a05385a81b5a3d34d80bc7118fa (diff) | |
download | ruby-c5f550c06918c7a0158f8f4e843b4a16dfb03c8a.tar.gz |
* lib/irb/{init.rb,ruby-lex.rb,slex.rb}: can't input '\c' for
[ruby-core: 7122]. and support for ruby1.8.X
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb/ruby-lex.rb')
-rw-r--r-- | lib/irb/ruby-lex.rb | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index c9b9f10392..ab584d5253 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -338,23 +338,23 @@ class RubyLex def lex_init() @OP = IRB::SLex.new - @OP.def_rules("\0", "\004", "\032") do + @OP.def_rules("\0", "\004", "\032") do |op, io| Token(TkEND_OF_SCRIPT) end - @OP.def_rules(" ", "\t", "\f", "\r", "\13") do + @OP.def_rules(" ", "\t", "\f", "\r", "\13") do |op, io| @space_seen = true while getc =~ /[ \t\f\r\13]/; end ungetc Token(TkSPACE) end - @OP.def_rule("#") do - |op, io| + @OP.def_rule("#") do |op, io| identify_comment end - @OP.def_rule("=begin", proc{@prev_char_no == 0 && peek(0) =~ /\s/}) do + @OP.def_rule("=begin", + proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do |op, io| @ltype = "=" until getc == "\n"; end @@ -366,7 +366,7 @@ class RubyLex Token(TkRD_COMMENT) end - @OP.def_rule("\n") do + @OP.def_rule("\n") do |op, io| print "\\n\n" if RubyLex.debug? case @lex_state when EXPR_BEG, EXPR_FNAME, EXPR_DOT @@ -478,13 +478,13 @@ class RubyLex Token(TkOPASGN, $1) end - @OP.def_rule("+@", proc{@lex_state == EXPR_FNAME}) do + @OP.def_rule("+@", proc{|op, io| @lex_state == EXPR_FNAME}) do |op, io| @lex_state = EXPR_ARG Token(op) end - @OP.def_rule("-@", proc{@lex_state == EXPR_FNAME}) do + @OP.def_rule("-@", proc{|op, io| @lex_state == EXPR_FNAME}) do |op, io| @lex_state = EXPR_ARG Token(op) @@ -509,6 +509,7 @@ class RubyLex end @OP.def_rule(".") do + |op, io| @lex_state = EXPR_BEG if peek(0) =~ /[0-9]/ ungetc @@ -539,6 +540,7 @@ class RubyLex end @OP.def_rule(":") do + |op, io| if @lex_state == EXPR_END || peek(0) =~ /\s/ @lex_state = EXPR_BEG Token(TkCOLON) @@ -549,6 +551,7 @@ class RubyLex end @OP.def_rule("::") do + |op, io| # p @lex_state.id2name, @space_seen if @lex_state == EXPR_BEG or @lex_state == EXPR_ARG && @space_seen @lex_state = EXPR_BEG @@ -576,6 +579,7 @@ class RubyLex end @OP.def_rules("^") do + |op, io| @lex_state = EXPR_BEG Token("^") end @@ -603,16 +607,19 @@ class RubyLex end @OP.def_rule("~") do + |op, io| @lex_state = EXPR_BEG Token("~") end - @OP.def_rule("~@", proc{@lex_state == EXPR_FNAME}) do + @OP.def_rule("~@", proc{|op, io| @lex_state == EXPR_FNAME}) do + |op, io| @lex_state = EXPR_BEG Token("~") end @OP.def_rule("(") do + |op, io| @indent += 1 if @lex_state == EXPR_BEG || @lex_state == EXPR_MID @lex_state = EXPR_BEG @@ -625,17 +632,20 @@ class RubyLex tk = Token(tk_c) end - @OP.def_rule("[]", proc{@lex_state == EXPR_FNAME}) do + @OP.def_rule("[]", proc{|op, io| @lex_state == EXPR_FNAME}) do + |op, io| @lex_state = EXPR_ARG Token("[]") end - @OP.def_rule("[]=", proc{@lex_state == EXPR_FNAME}) do + @OP.def_rule("[]=", proc{|op, io| @lex_state == EXPR_FNAME}) do + |op, io| @lex_state = EXPR_ARG Token("[]=") end @OP.def_rule("[") do + |op, io| @indent += 1 if @lex_state == EXPR_FNAME tk_c = TkfLBRACK @@ -654,6 +664,7 @@ class RubyLex end @OP.def_rule("{") do + |op, io| @indent += 1 if @lex_state != EXPR_END && @lex_state != EXPR_ARG tk_c = TkLBRACE @@ -666,6 +677,7 @@ class RubyLex end @OP.def_rule('\\') do + |op, io| if getc == "\n" @space_seen = true @continue = true @@ -692,10 +704,12 @@ class RubyLex end @OP.def_rule('$') do + |op, io| identify_gvar end @OP.def_rule('@') do + |op, io| if peek(0) =~ /[\w_@]/ ungetc identify_identifier |