diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-10 05:36:35 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-06-10 05:36:35 +0000 |
commit | b114537fbf7ef2ebf5ea51d06ed7404143c3490a (patch) | |
tree | ea11581058e12fcfc1c67be55603efa1b406b58a /lib/irb | |
parent | 10a53d3ef4514b6b50cf716a80981bfa9008f3e1 (diff) | |
download | ruby-b114537fbf7ef2ebf5ea51d06ed7404143c3490a.tar.gz ruby-b114537fbf7ef2ebf5ea51d06ed7404143c3490a.tar.xz ruby-b114537fbf7ef2ebf5ea51d06ed7404143c3490a.zip |
* lib/irb/slex.rb: small cleanups. (ruby-bugs-ja PR#492)
* lib/irb/ruby-lex.rb: ditto.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/irb')
-rw-r--r-- | lib/irb/ruby-lex.rb | 9 | ||||
-rw-r--r-- | lib/irb/slex.rb | 12 |
2 files changed, 11 insertions, 10 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 8d5cb4758..d8f8a1024 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -67,12 +67,12 @@ class RubyLex attr_reader :indent # io functions - def set_input(io, p = nil) + def set_input(io, p = nil, &block) @io = io if p.respond_to?(:call) @input = p - elsif iterator? - @input = Block.new + elsif block_given? + @input = block else @input = Block.new{@io.gets} end @@ -183,7 +183,8 @@ class RubyLex end private :buf_input - def set_prompt(p = Block.new) + def set_prompt(p, &block) + p = block if block_given? if p.respond_to?(:call) @prompt = p else diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb index 5dc496d89..ceee90b3d 100644 --- a/lib/irb/slex.rb +++ b/lib/irb/slex.rb @@ -31,22 +31,22 @@ class SLex @head = Node.new("") end - def def_rule(token, preproc = nil, postproc = nil) + def def_rule(token, preproc = nil, postproc = nil, &block) # print node.inspect, "\n" if SLex.debug? - postproc = Block.new if iterator? + postproc = block if block_given? node = create(token, preproc, postproc) end - def def_rules(*tokens) - if iterator? - p = Block.new + def def_rules(*tokens, &block) + if block_given? + p = block end for token in tokens def_rule(token, nil, p) end end - def preporc(token, proc) + def preproc(token, proc) node = search(token) node.preproc=proc end |