mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/irb.rb lib/irb/* doc/irb: IRB 0.9.5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									40906c5d5d
								
							
						
					
					
						commit
						f9fb21448b
					
				
					 34 changed files with 477 additions and 302 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,7 @@
 | 
			
		|||
Wed Apr 20 04:15:27 2005  Keiju Ishitsuka  <keiju@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* lib/irb.rb lib/irb/* doc/irb: IRB 0.9.5
 | 
			
		||||
 | 
			
		||||
Tue Apr 19 23:37:09 2005  WATANABE Hirofumi  <eban@ruby-lang.org>
 | 
			
		||||
 | 
			
		||||
	* lib/ftools.rb (File.safe_unlink): do not modify a symlinked file.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										4
									
								
								bin/irb
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								bin/irb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
#!/usr/bin/env ruby
 | 
			
		||||
#
 | 
			
		||||
#   irb.rb - intaractive ruby
 | 
			
		||||
#   	$Release Version: 0.7.3 $
 | 
			
		||||
#   	$Release Version: 0.9.5 $
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,8 @@
 | 
			
		|||
irb -- interactive ruby
 | 
			
		||||
				$Release Version: 0.9 $
 | 
			
		||||
				$Release Version: 0.9.5 $
 | 
			
		||||
			   	$Revision$
 | 
			
		||||
			   	$Date$
 | 
			
		||||
			   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
			   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
=begin
 | 
			
		||||
= irbとは?
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -112,6 +112,7 @@ irb
 | 
			
		|||
 | 
			
		||||
   IRB.conf[:PROMPT][:MY_PROMPT] = { # プロンプトモードの名前
 | 
			
		||||
     :PROMPT_I => nil,		  # 通常のプロンプト
 | 
			
		||||
     :PROMPT_N => nil,		  # 継続行のプロンプト
 | 
			
		||||
     :PROMPT_S => nil,		  # 文字列などの継続行のプロンプト
 | 
			
		||||
     :PROMPT_C => nil,		  # 式が継続している時のプロンプト
 | 
			
		||||
     :RETURN => "    ==>%s\n"	  # リターン時のプロンプト
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +127,7 @@ OK
 | 
			
		|||
 | 
			
		||||
  IRB.conf[:PROMPT_MODE] = :MY_PROMPT
 | 
			
		||||
 | 
			
		||||
PROMPT_I, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
 | 
			
		||||
PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
 | 
			
		||||
 | 
			
		||||
  %N	起動しているコマンド名が出力される.
 | 
			
		||||
  %m	mainオブジェクト(self)がto_sで出力される.
 | 
			
		||||
| 
						 | 
				
			
			@ -141,6 +142,7 @@ PROMPT_I, PROMPT_S, PROMPT_C
 | 
			
		|||
 | 
			
		||||
  IRB.conf[:PROMPT_MODE][:DEFAULT] = {
 | 
			
		||||
      :PROMPT_I => "%N(%m):%03n:%i> ",
 | 
			
		||||
      :PROMPT_N => "%N(%m):%03n:%i> ",
 | 
			
		||||
      :PROMPT_S => "%N(%m):%03n:%i%l ",
 | 
			
		||||
      :PROMPT_C => "%N(%m):%03n:%i* ",
 | 
			
		||||
      :RETURN => "%s\n"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										10
									
								
								lib/irb.rb
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								lib/irb.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb.rb - irb main module
 | 
			
		||||
#   	$Release Version: 0.9 $
 | 
			
		||||
#   	$Release Version: 0.9.5 $
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -88,8 +88,8 @@ module IRB
 | 
			
		|||
  # irb interpriter main routine 
 | 
			
		||||
  #
 | 
			
		||||
  class Irb
 | 
			
		||||
    def initialize(workspace = nil, input_method = nil)
 | 
			
		||||
      @context = Context.new(self, workspace, input_method)
 | 
			
		||||
    def initialize(workspace = nil, input_method = nil, output_method = nil)
 | 
			
		||||
      @context = Context.new(self, workspace, input_method, output_method)
 | 
			
		||||
      @context.main.extend ExtendCommandBundle
 | 
			
		||||
      @signal_status = :IN_IRB
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -106,6 +106,8 @@ module IRB
 | 
			
		|||
	  f = @context.prompt_s
 | 
			
		||||
	elsif continue
 | 
			
		||||
	  f = @context.prompt_c
 | 
			
		||||
	elsif indent > 0
 | 
			
		||||
	  f = @context.prompt_n
 | 
			
		||||
	else @context.prompt_i
 | 
			
		||||
	  f = @context.prompt_i
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   change-ws.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,23 @@
 | 
			
		|||
#
 | 
			
		||||
#   fork.rb - 
 | 
			
		||||
#   	$Release Version: 0.9.5 $
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
@RCS_ID='-$Id$-'
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
  module ExtendCommand
 | 
			
		||||
    class Fork<Nop
 | 
			
		||||
      def execute(&block)
 | 
			
		||||
	pid = send(ExtendCommand.irb_original_method_name("fork"))
 | 
			
		||||
	pid = send ExtendCommand.irb_original_method_name("fork")
 | 
			
		||||
	unless pid 
 | 
			
		||||
	  class<<self
 | 
			
		||||
	    alias_method :exit, ExtendCommand.irb_original_method_name('exit')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   load.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   nop.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   change-ws.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
#!/usr/local/bin/ruby
 | 
			
		||||
#
 | 
			
		||||
#   multi.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/context.rb - irb context
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ module IRB
 | 
			
		|||
    #		      String -- File
 | 
			
		||||
    #		      other -- using this as InputMethod
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(irb, workspace = nil, input_method = nil)
 | 
			
		||||
    def initialize(irb, workspace = nil, input_method = nil, output_method = nil)
 | 
			
		||||
      @irb = irb
 | 
			
		||||
      if workspace
 | 
			
		||||
	@workspace = workspace
 | 
			
		||||
| 
						 | 
				
			
			@ -71,6 +71,13 @@ module IRB
 | 
			
		|||
      else
 | 
			
		||||
	@io = input_method
 | 
			
		||||
      end
 | 
			
		||||
      self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
 | 
			
		||||
 | 
			
		||||
      if output_method
 | 
			
		||||
	@output_method = output_method
 | 
			
		||||
      else
 | 
			
		||||
	@output_method = StdioOutputMethod.new
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      @verbose = IRB.conf[:VERBOSE] 
 | 
			
		||||
      @echo = IRB.conf[:ECHO]
 | 
			
		||||
| 
						 | 
				
			
			@ -96,13 +103,14 @@ module IRB
 | 
			
		|||
    attr_accessor :irb_name
 | 
			
		||||
    attr_accessor :irb_path
 | 
			
		||||
 | 
			
		||||
    attr_accessor :use_readline
 | 
			
		||||
    attr_reader :use_readline
 | 
			
		||||
    attr_reader :inspect_mode
 | 
			
		||||
 | 
			
		||||
    attr_reader :prompt_mode
 | 
			
		||||
    attr_accessor :prompt_i
 | 
			
		||||
    attr_accessor :prompt_s
 | 
			
		||||
    attr_accessor :prompt_c
 | 
			
		||||
    attr_accessor :prompt_n
 | 
			
		||||
    attr_accessor :auto_indent_mode
 | 
			
		||||
    attr_accessor :return_format
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -141,6 +149,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    def set_last_value(value)
 | 
			
		||||
      @last_value = value
 | 
			
		||||
      @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    attr_reader :irb_name
 | 
			
		||||
| 
						 | 
				
			
			@ -151,6 +160,7 @@ module IRB
 | 
			
		|||
      @prompt_i = pconf[:PROMPT_I]
 | 
			
		||||
      @prompt_s = pconf[:PROMPT_S]
 | 
			
		||||
      @prompt_c = pconf[:PROMPT_C]
 | 
			
		||||
      @prompt_n = pconf[:PROMPT_N]
 | 
			
		||||
      @return_format = pconf[:RETURN]
 | 
			
		||||
      if ai = pconf.include?(:AUTO_INDENT)
 | 
			
		||||
	@auto_indent_mode = ai
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +187,6 @@ module IRB
 | 
			
		|||
      @inspect_mode
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    undef use_readline=
 | 
			
		||||
    def use_readline=(opt)
 | 
			
		||||
      @use_readline = opt
 | 
			
		||||
      print "use readline module\n" if @use_readline
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ext/cb.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   history.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -21,8 +21,8 @@ module IRB
 | 
			
		|||
    def set_last_value(value)
 | 
			
		||||
      _set_last_value(value)
 | 
			
		||||
 | 
			
		||||
      @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
 | 
			
		||||
      if (@eval_history ||= nil) #and !@eval_history_values.equal?(llv)
 | 
			
		||||
#      @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
 | 
			
		||||
      if @eval_history #and !@eval_history_values.equal?(llv)
 | 
			
		||||
 	@eval_history_values.push @line_no, @last_value
 | 
			
		||||
 	@workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -33,7 +33,7 @@ module IRB
 | 
			
		|||
    attr_reader :eval_history
 | 
			
		||||
    def eval_history=(no)
 | 
			
		||||
      if no
 | 
			
		||||
	if (@eval_history ||= nil)
 | 
			
		||||
	if defined?(@eval_history) && @eval_history
 | 
			
		||||
	  @eval_history_values.size(no)
 | 
			
		||||
	else
 | 
			
		||||
	  @eval_history_values = History.new(no)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,22 @@
 | 
			
		|||
#
 | 
			
		||||
#   loader.rb - 
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
  class LoadAbort < Exception;end
 | 
			
		||||
 | 
			
		||||
  module IrbLoader
 | 
			
		||||
    @RCS_ID='-$Id$-'
 | 
			
		||||
 | 
			
		||||
    alias ruby_load load
 | 
			
		||||
    alias ruby_require require
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   math-mode.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/multi-irb.rb - multiple irb module
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lib/tracer.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   use-loader.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   push-ws.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/extend-command.rb - irb command extend
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   irb/extend-command.rb - irb extend command 
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -100,6 +100,10 @@ module IRB
 | 
			
		|||
	[:fg, NO_OVERRIDE]],
 | 
			
		||||
      [:irb_kill, :Kill, "irb/cmd/subirb", 
 | 
			
		||||
	[:kill, OVERRIDE_PRIVATE_ONLY]],
 | 
			
		||||
 | 
			
		||||
      [:irb_help, :Help, "irb/cmd/help",
 | 
			
		||||
        [:help, NO_OVERRIDE]],
 | 
			
		||||
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    def EXCB.install_extend_commands
 | 
			
		||||
| 
						 | 
				
			
			@ -189,6 +193,7 @@ module IRB
 | 
			
		|||
      [:use_tracer=, "irb/ext/tracer.rb"],
 | 
			
		||||
      [:math_mode=, "irb/ext/math-mode.rb"],
 | 
			
		||||
      [:use_loader=, "irb/ext/use-loader.rb"],
 | 
			
		||||
      [:save_history=, "irb/ext/save-history.rb"],
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    def CE.install_extend_commands
 | 
			
		||||
| 
						 | 
				
			
			@ -212,5 +217,48 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    CE.install_extend_commands
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  module MethodExtender
 | 
			
		||||
    def def_pre_proc(base_method, extend_method)
 | 
			
		||||
      base_method = base_method.to_s
 | 
			
		||||
      extend_method = extend_method.to_s
 | 
			
		||||
 | 
			
		||||
      alias_name = new_alias_name(base_method)
 | 
			
		||||
      module_eval %[
 | 
			
		||||
        alias_method alias_name, base_method
 | 
			
		||||
        def #{base_method}(*opts)
 | 
			
		||||
	  send :#{extend_method}, *opts
 | 
			
		||||
	  send :#{alias_name}, *opts
 | 
			
		||||
	end
 | 
			
		||||
      ]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def def_post_proc(base_method, extend_method)
 | 
			
		||||
      base_method = base_method.to_s
 | 
			
		||||
      extend_method = extend_method.to_s
 | 
			
		||||
 | 
			
		||||
      alias_name = new_alias_name(base_method)
 | 
			
		||||
      module_eval %[
 | 
			
		||||
        alias_method alias_name, base_method
 | 
			
		||||
        def #{base_method}(*opts)
 | 
			
		||||
	  send :#{alias_name}, *opts
 | 
			
		||||
	  send :#{extend_method}, *opts
 | 
			
		||||
	end
 | 
			
		||||
      ]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # return #{prefix}#{name}#{postfix}<num>
 | 
			
		||||
    def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
 | 
			
		||||
      base_name = "#{prefix}#{name}#{postfix}"
 | 
			
		||||
      all_methods = instance_methods(true) + private_instance_methods(true)
 | 
			
		||||
      same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
 | 
			
		||||
      return base_name if same_methods.empty?
 | 
			
		||||
      no = same_methods.size
 | 
			
		||||
      while !same_methods.include?(alias_name = base_name + no)
 | 
			
		||||
	no += 1
 | 
			
		||||
      end
 | 
			
		||||
      alias_name
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/help.rb - print usase module
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/init.rb - irb initialize module
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -54,36 +54,43 @@ module IRB
 | 
			
		|||
    @CONF[:VERBOSE] = nil
 | 
			
		||||
 | 
			
		||||
    @CONF[:EVAL_HISTORY] = nil
 | 
			
		||||
    @CONF[:SAVE_HISTORY] = nil
 | 
			
		||||
 | 
			
		||||
    @CONF[:BACK_TRACE_LIMIT] = 16
 | 
			
		||||
 | 
			
		||||
    @CONF[:PROMPT] = {
 | 
			
		||||
      :NULL => {
 | 
			
		||||
	:PROMPT_I => nil,
 | 
			
		||||
	:PROMPT_N => nil,
 | 
			
		||||
	:PROMPT_S => nil,
 | 
			
		||||
	:PROMPT_C => nil,
 | 
			
		||||
	:RETURN => "%s\n"
 | 
			
		||||
      },
 | 
			
		||||
      :DEFAULT => {
 | 
			
		||||
	:PROMPT_I => "%N(%m):%03n:%i> ",
 | 
			
		||||
	:PROMPT_N => "%N(%m):%03n:%i> ",
 | 
			
		||||
	:PROMPT_S => "%N(%m):%03n:%i%l ",
 | 
			
		||||
	:PROMPT_C => "%N(%m):%03n:%i* ",
 | 
			
		||||
	:RETURN => "=> %s\n"
 | 
			
		||||
      },
 | 
			
		||||
      :CLASSIC => {
 | 
			
		||||
	:PROMPT_I => "%N(%m):%03n:%i> ",
 | 
			
		||||
	:PROMPT_N => "%N(%m):%03n:%i> ",
 | 
			
		||||
	:PROMPT_S => "%N(%m):%03n:%i%l ",
 | 
			
		||||
	:PROMPT_C => "%N(%m):%03n:%i* ",
 | 
			
		||||
	:RETURN => "%s\n"
 | 
			
		||||
      },
 | 
			
		||||
      :SIMPLE => {
 | 
			
		||||
	:PROMPT_I => ">> ",
 | 
			
		||||
	:PROMPT_N => ">> ",
 | 
			
		||||
	:PROMPT_S => nil,
 | 
			
		||||
	:PROMPT_C => "?> ",
 | 
			
		||||
	:RETURN => "=> %s\n"
 | 
			
		||||
      },
 | 
			
		||||
      :INF_RUBY => {
 | 
			
		||||
	:PROMPT_I => "%N(%m):%03n:%i> ",
 | 
			
		||||
#	:PROMPT_N => "%N(%m):%03n:%i> ",
 | 
			
		||||
	:PROMPT_N => nil,
 | 
			
		||||
	:PROMPT_S => nil,
 | 
			
		||||
	:PROMPT_C => nil,
 | 
			
		||||
	:RETURN => "%s\n",
 | 
			
		||||
| 
						 | 
				
			
			@ -91,6 +98,7 @@ module IRB
 | 
			
		|||
      },
 | 
			
		||||
      :XMP => {
 | 
			
		||||
	:PROMPT_I => nil,
 | 
			
		||||
	:PROMPT_N => nil,
 | 
			
		||||
	:PROMPT_S => nil,
 | 
			
		||||
	:PROMPT_C => nil,
 | 
			
		||||
	:RETURN => "    ==>%s\n"
 | 
			
		||||
| 
						 | 
				
			
			@ -186,31 +194,45 @@ module IRB
 | 
			
		|||
  # running config
 | 
			
		||||
  def IRB.run_config
 | 
			
		||||
    if @CONF[:RC]
 | 
			
		||||
      rcs = []
 | 
			
		||||
      rcs.push File.expand_path("~/.irbrc") if ENV.key?("HOME")
 | 
			
		||||
      rcs.push ".irbrc"
 | 
			
		||||
      rcs.push "irb.rc"
 | 
			
		||||
      rcs.push "_irbrc"
 | 
			
		||||
      rcs.push "$irbrc"
 | 
			
		||||
      catch(:EXIT) do
 | 
			
		||||
	for rc in rcs
 | 
			
		||||
	  begin
 | 
			
		||||
	    load rc
 | 
			
		||||
	    throw :EXIT
 | 
			
		||||
	  rescue LoadError, Errno::ENOENT
 | 
			
		||||
	  rescue
 | 
			
		||||
	    print "load error: #{rc}\n"
 | 
			
		||||
	    print $!.class, ": ", $!, "\n"
 | 
			
		||||
	    for err in $@[0, $@.size - 2]
 | 
			
		||||
	      print "\t", err, "\n"
 | 
			
		||||
	    end
 | 
			
		||||
	    throw :EXIT
 | 
			
		||||
	  end
 | 
			
		||||
      begin
 | 
			
		||||
	load rc_file
 | 
			
		||||
      rescue LoadError, Errno::ENOENT
 | 
			
		||||
      rescue
 | 
			
		||||
	print "load error: #{rc_file}\n"
 | 
			
		||||
	print $!.class, ": ", $!, "\n"
 | 
			
		||||
	for err in $@[0, $@.size - 2]
 | 
			
		||||
	  print "\t", err, "\n"
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  IRBRC_EXT = "rc"
 | 
			
		||||
  def IRB.rc_file(ext = IRBRC_EXT)
 | 
			
		||||
    if !@CONF[:RC_NAME_GENERATOR]
 | 
			
		||||
      rc_file_generators do |rcgen|
 | 
			
		||||
	@CONF[:RC_NAME_GENERATOR] ||= rcgen
 | 
			
		||||
	if File.exist?(rcgen.call(IRBRC_EXT))
 | 
			
		||||
	  @CONF[:RC_NAME_GENERATOR] = rcgen
 | 
			
		||||
	  break
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    @CONF[:RC_NAME_GENERATOR].call ext
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # enumerate possible rc-file base name generators
 | 
			
		||||
  def IRB.rc_file_generators
 | 
			
		||||
    if home = ENV["HOME"]
 | 
			
		||||
      yield proc{|rc| home+"/.irb#{rc}"} 
 | 
			
		||||
    end
 | 
			
		||||
    home = Dir.pwd
 | 
			
		||||
    yield proc{|rc| home+"/.irb#{rc}"}
 | 
			
		||||
    yield proc{|rc| home+"/irb#{rc.sub(/\A_?/, '.')}"}
 | 
			
		||||
    yield proc{|rc| home+"/_irb#{rc}"}
 | 
			
		||||
    yield proc{|rc| home+"/$irb#{rc}"}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # loading modules
 | 
			
		||||
  def IRB.load_modules
 | 
			
		||||
    for m in @CONF[:LOAD_MODULES]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/input-method.rb - input methods using irb
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   irb/input-method.rb - input methods used irb
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lc/error.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lc/help-message.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lc/ja/error.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -25,5 +25,3 @@ module IRB
 | 
			
		|||
  def_exception :CantChangeBinding, '$B%P%$%s%G%#%s%0(B(%s)$B$KJQ99$G$-$^$;$s(B.'
 | 
			
		||||
  def_exception :UndefinedPromptMode, '$B%W%m%s%W%H%b!<%I(B(%s)$B$ODj5A$5$l$F$$$^$;$s(B.'
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lc/ja/help-message.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/locale.rb - internationalization module
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ruby-lex.rb - ruby lexcal analizer
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -51,13 +51,18 @@ class RubyLex
 | 
			
		|||
 | 
			
		||||
    @indent = 0
 | 
			
		||||
    @indent_stack = []
 | 
			
		||||
    @lex_state = EXPR_BEG
 | 
			
		||||
    @space_seen = false
 | 
			
		||||
    @here_header = false
 | 
			
		||||
    
 | 
			
		||||
    @continue = false
 | 
			
		||||
    @line = ""
 | 
			
		||||
 | 
			
		||||
    @skip_space = false
 | 
			
		||||
    @readed_auto_clean_up = false
 | 
			
		||||
    @exception_on_syntax_error = true
 | 
			
		||||
 | 
			
		||||
    @prompt = nil
 | 
			
		||||
    @here_header = nil
 | 
			
		||||
    @lex_state = nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  attr_accessor :skip_space
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +100,8 @@ class RubyLex
 | 
			
		|||
 | 
			
		||||
  def getc
 | 
			
		||||
    while @rests.empty?
 | 
			
		||||
      return nil unless buf_input
 | 
			
		||||
#      return nil unless buf_input
 | 
			
		||||
      @rests.push nil unless buf_input
 | 
			
		||||
    end
 | 
			
		||||
    c = @rests.shift
 | 
			
		||||
    if @here_header
 | 
			
		||||
| 
						 | 
				
			
			@ -116,9 +122,10 @@ class RubyLex
 | 
			
		|||
  def gets
 | 
			
		||||
    l = ""
 | 
			
		||||
    while c = getc
 | 
			
		||||
      l.concat c
 | 
			
		||||
      l.concat(c)
 | 
			
		||||
      break if c == "\n"
 | 
			
		||||
    end
 | 
			
		||||
    return nil if l == "" and c.nil?
 | 
			
		||||
    l
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +193,7 @@ class RubyLex
 | 
			
		|||
  end
 | 
			
		||||
  private :buf_input
 | 
			
		||||
 | 
			
		||||
  def set_prompt(p=nil, &block)
 | 
			
		||||
  def set_prompt(p = nil, &block)
 | 
			
		||||
    p = block if block_given?
 | 
			
		||||
    if p.respond_to?(:call)
 | 
			
		||||
      @prompt = p
 | 
			
		||||
| 
						 | 
				
			
			@ -280,7 +287,7 @@ class RubyLex
 | 
			
		|||
	tk = @OP.match(self)
 | 
			
		||||
	@space_seen = tk.kind_of?(TkSPACE)
 | 
			
		||||
      rescue SyntaxError
 | 
			
		||||
	abort if @exception_on_syntax_error
 | 
			
		||||
	raise if @exception_on_syntax_error
 | 
			
		||||
	tk = TkError.new(@seek, @line_no, @char_no)
 | 
			
		||||
      end
 | 
			
		||||
    end while @skip_space and tk.kind_of?(TkSPACE)
 | 
			
		||||
| 
						 | 
				
			
			@ -330,7 +337,7 @@ class RubyLex
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  def lex_init()
 | 
			
		||||
    @OP = SLex.new
 | 
			
		||||
    @OP = IRB::SLex.new
 | 
			
		||||
    @OP.def_rules("\0", "\004", "\032") do
 | 
			
		||||
      Token(TkEND_OF_SCRIPT)
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -429,6 +436,7 @@ class RubyLex
 | 
			
		|||
    @OP.def_rules("`") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      if @lex_state == EXPR_FNAME
 | 
			
		||||
	@lex_state = EXPR_END
 | 
			
		||||
	Token(op)
 | 
			
		||||
      else
 | 
			
		||||
	identify_string(op)
 | 
			
		||||
| 
						 | 
				
			
			@ -472,11 +480,13 @@ class RubyLex
 | 
			
		|||
 | 
			
		||||
    @OP.def_rule("+@", proc{@lex_state == EXPR_FNAME}) do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @lex_state = EXPR_ARG
 | 
			
		||||
      Token(op)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @OP.def_rule("-@", proc{@lex_state == EXPR_FNAME}) do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @lex_state = EXPR_ARG
 | 
			
		||||
      Token(op)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -616,10 +626,12 @@ class RubyLex
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    @OP.def_rule("[]", proc{@lex_state == EXPR_FNAME}) do
 | 
			
		||||
      @lex_state = EXPR_ARG
 | 
			
		||||
      Token("[]")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @OP.def_rule("[]=", proc{@lex_state == EXPR_FNAME}) do
 | 
			
		||||
      @lex_state = EXPR_ARG
 | 
			
		||||
      Token("[]=")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -790,14 +802,13 @@ class RubyLex
 | 
			
		|||
	else
 | 
			
		||||
	  if @lex_state != EXPR_FNAME
 | 
			
		||||
	    if ENINDENT_CLAUSE.include?(token)
 | 
			
		||||
	      # check for ``class = val''.
 | 
			
		||||
	      # check for ``class = val'' etc.
 | 
			
		||||
	      valid = true
 | 
			
		||||
	      case token
 | 
			
		||||
	      when "class"
 | 
			
		||||
		valid = false unless peek_match?(/^\s*(<<|\w|::)/)
 | 
			
		||||
	      when "def"
 | 
			
		||||
		valid = false if peek_match?(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)=|\&\&|\|\|)/)
 | 
			
		||||
#		valid = false if peek_match?(/^\s*(([+-\/*&\|^]|<<|>>|\|\||\&\&)?=|\&\&|\|\|)/)
 | 
			
		||||
	      when "do"
 | 
			
		||||
		valid = false if peek_match?(/^\s*([+-\/*]?=|\*|<|>|\&)/)
 | 
			
		||||
	      when *ENINDENT_CLAUSE
 | 
			
		||||
| 
						 | 
				
			
			@ -885,7 +896,11 @@ class RubyLex
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    @here_header = false
 | 
			
		||||
    while (l = gets.chomp) && (indent ? l.strip : l) != quoted
 | 
			
		||||
    while l = gets
 | 
			
		||||
      l = l.sub(/(:?\r)?\n\z/, '')
 | 
			
		||||
      if (indent ? l.strip : l) == quoted
 | 
			
		||||
 	break
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @here_header = true
 | 
			
		||||
| 
						 | 
				
			
			@ -920,19 +935,43 @@ class RubyLex
 | 
			
		|||
  def identify_number
 | 
			
		||||
    @lex_state = EXPR_END
 | 
			
		||||
 | 
			
		||||
    if ch = getc
 | 
			
		||||
    if peek(0) == "0" && peek(1) !~ /[.eE]/
 | 
			
		||||
      getc
 | 
			
		||||
      if /[xX]/ =~ peek(0)
 | 
			
		||||
	ch = getc
 | 
			
		||||
	match = /[0-9a-fA-F_]/
 | 
			
		||||
      elsif /[bB]/ =~ peek(0)
 | 
			
		||||
	ch = getc
 | 
			
		||||
	match = /[01_]/
 | 
			
		||||
      elsif /[oO]/ =~ peek(0)
 | 
			
		||||
	ch = getc
 | 
			
		||||
	match = /[0-7_]/
 | 
			
		||||
      else
 | 
			
		||||
	match = /[0-7_]/
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      len0 = true
 | 
			
		||||
      non_digit = false
 | 
			
		||||
      while ch = getc
 | 
			
		||||
	if ch !~ match
 | 
			
		||||
	if match =~ ch
 | 
			
		||||
	  if ch == "_"
 | 
			
		||||
	    if non_digit
 | 
			
		||||
	      RubyLex.fail SyntaxError, "trailing `#{ch}' in number"
 | 
			
		||||
	    else
 | 
			
		||||
	      non_digit = ch
 | 
			
		||||
	    end
 | 
			
		||||
	  else
 | 
			
		||||
	    non_digit = false
 | 
			
		||||
	    len0 = false
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  ungetc
 | 
			
		||||
	  if len0
 | 
			
		||||
	    RubyLex.fail SyntaxError, "numeric literal without digits"
 | 
			
		||||
	  end
 | 
			
		||||
	  if non_digit
 | 
			
		||||
	    RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
 | 
			
		||||
	  end
 | 
			
		||||
	  break
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -942,24 +981,39 @@ class RubyLex
 | 
			
		|||
    type = TkINTEGER
 | 
			
		||||
    allow_point = true
 | 
			
		||||
    allow_e = true
 | 
			
		||||
    non_digit = false
 | 
			
		||||
    while ch = getc
 | 
			
		||||
      case ch
 | 
			
		||||
      when /[0-9_]/
 | 
			
		||||
      when /[0-9]/
 | 
			
		||||
	non_digit = false
 | 
			
		||||
      when "_"
 | 
			
		||||
	non_digit = ch
 | 
			
		||||
      when allow_point && "."
 | 
			
		||||
	if non_digit
 | 
			
		||||
	  RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
 | 
			
		||||
	end
 | 
			
		||||
	type = TkFLOAT
 | 
			
		||||
	if peek(0) !~ /[0-9]/
 | 
			
		||||
	  type = TkINTEGER
 | 
			
		||||
	  ungetc
 | 
			
		||||
	  break
 | 
			
		||||
	end
 | 
			
		||||
	allow_point = false
 | 
			
		||||
      when allow_e && "e", allow_e && "E"
 | 
			
		||||
	if non_digit
 | 
			
		||||
	  RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
 | 
			
		||||
	end
 | 
			
		||||
	type = TkFLOAT
 | 
			
		||||
	if peek(0) =~ /[+-]/
 | 
			
		||||
	  getc
 | 
			
		||||
	end
 | 
			
		||||
	allow_e = false
 | 
			
		||||
	allow_point = false
 | 
			
		||||
	non_digit = ch
 | 
			
		||||
      else
 | 
			
		||||
	if non_digit
 | 
			
		||||
	  RubyLex.fail SyntaxError, "trailing `#{non_digit}' in number"
 | 
			
		||||
	end
 | 
			
		||||
	ungetc
 | 
			
		||||
	break
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ruby-token.rb - ruby tokens 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ module RubyToken
 | 
			
		|||
  class TkOPASGN < TkOp
 | 
			
		||||
    def initialize(seek, line_no, char_no, op)
 | 
			
		||||
      super(seek, line_no, char_no)
 | 
			
		||||
      op = TkReading2Token[op] unless op.kind_of?(Symbol)
 | 
			
		||||
      op = TkReading2Token[op][0] unless op.kind_of?(Symbol)
 | 
			
		||||
      @op = op
 | 
			
		||||
    end
 | 
			
		||||
    attr :op
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										396
									
								
								lib/irb/slex.rb
									
										
									
									
									
								
							
							
						
						
									
										396
									
								
								lib/irb/slex.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/slex.rb - symple lex analizer
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishituska.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -11,235 +11,242 @@
 | 
			
		|||
#
 | 
			
		||||
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
require "irb/notifier"
 | 
			
		||||
 | 
			
		||||
class SLex
 | 
			
		||||
  @RCS_ID='-$Id$-'
 | 
			
		||||
module IRB
 | 
			
		||||
  class SLex
 | 
			
		||||
    @RCS_ID='-$Id$-'
 | 
			
		||||
 | 
			
		||||
  extend Exception2MessageMapper
 | 
			
		||||
  def_exception :ErrNodeNothing, "node nothing"
 | 
			
		||||
  def_exception :ErrNodeAlreadyExists, "node already exists"
 | 
			
		||||
    extend Exception2MessageMapper
 | 
			
		||||
    def_exception :ErrNodeNothing, "node nothing"
 | 
			
		||||
    def_exception :ErrNodeAlreadyExists, "node already exists"
 | 
			
		||||
 | 
			
		||||
  class << self
 | 
			
		||||
    attr_accessor :debug_level
 | 
			
		||||
    def debug?
 | 
			
		||||
      debug_level > 0
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  @debug_level = 0
 | 
			
		||||
 | 
			
		||||
  def initialize
 | 
			
		||||
    @head = Node.new("")
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def def_rule(token, preproc = nil, postproc = nil, &block)
 | 
			
		||||
    #      print node.inspect, "\n" if SLex.debug?
 | 
			
		||||
    postproc = block if block_given?
 | 
			
		||||
    node = create(token, preproc, postproc)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def def_rules(*tokens, &block)
 | 
			
		||||
    if block_given?
 | 
			
		||||
      p = block
 | 
			
		||||
    end
 | 
			
		||||
    for token in tokens
 | 
			
		||||
      def_rule(token, nil, p)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def preproc(token, proc)
 | 
			
		||||
    node = search(token)
 | 
			
		||||
    node.preproc=proc
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def postproc(token)
 | 
			
		||||
    node = search(token, proc)
 | 
			
		||||
    node.postproc=proc
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def search(token)
 | 
			
		||||
    @head.search(token.split(//))
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def create(token, preproc = nil, postproc = nil)
 | 
			
		||||
    @head.create_subnode(token.split(//), preproc, postproc)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def match(token)
 | 
			
		||||
    case token
 | 
			
		||||
    when Array
 | 
			
		||||
    when String
 | 
			
		||||
      return match(token.split(//))
 | 
			
		||||
    else
 | 
			
		||||
      return @head.match_io(token)
 | 
			
		||||
    end
 | 
			
		||||
    ret = @head.match(token)
 | 
			
		||||
    printf "match end: %s:%s", ret, token.inspect if SLex.debug?
 | 
			
		||||
    ret
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  def inspect
 | 
			
		||||
    format("<SLex: @head = %s>", @head.inspect)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  #----------------------------------------------------------------------
 | 
			
		||||
  #
 | 
			
		||||
  #   class Node - 
 | 
			
		||||
  #
 | 
			
		||||
  #----------------------------------------------------------------------
 | 
			
		||||
  class Node
 | 
			
		||||
    # if postproc is nil, this node is an abstract node.
 | 
			
		||||
    # if postproc is non-nil, this node is a real node.
 | 
			
		||||
    def initialize(preproc = nil, postproc = nil)
 | 
			
		||||
      @Tree = {}
 | 
			
		||||
      @preproc = preproc
 | 
			
		||||
      @postproc = postproc
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    attr_accessor :preproc
 | 
			
		||||
    attr_accessor :postproc
 | 
			
		||||
    DOUT = Notifier::def_notifier("SLex::")
 | 
			
		||||
    D_WARN = DOUT::def_notifier(1, "Warn: ")
 | 
			
		||||
    D_DEBUG = DOUT::def_notifier(2, "Debug: ")
 | 
			
		||||
    D_DETAIL = DOUT::def_notifier(4, "Detail: ")
 | 
			
		||||
    
 | 
			
		||||
    def search(chrs, opt = nil)
 | 
			
		||||
      return self if chrs.empty?
 | 
			
		||||
      ch = chrs.shift
 | 
			
		||||
      if node = @Tree[ch]
 | 
			
		||||
	node.search(chrs, opt)
 | 
			
		||||
    DOUT.level = Notifier::D_NOMSG
 | 
			
		||||
 | 
			
		||||
    def initialize
 | 
			
		||||
      @head = Node.new("")
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    def def_rule(token, preproc = nil, postproc = nil, &block)
 | 
			
		||||
      D_DETAIL.pp token
 | 
			
		||||
 | 
			
		||||
      postproc = block if block_given?
 | 
			
		||||
      node = create(token, preproc, postproc)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    def def_rules(*tokens, &block)
 | 
			
		||||
      if block_given?
 | 
			
		||||
	p = block
 | 
			
		||||
      end
 | 
			
		||||
      for token in tokens
 | 
			
		||||
	def_rule(token, nil, p)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    def preproc(token, proc)
 | 
			
		||||
      node = search(token)
 | 
			
		||||
      node.preproc=proc
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    #$BMW%A%'%C%/(B? 
 | 
			
		||||
    def postproc(token)
 | 
			
		||||
      node = search(token, proc)
 | 
			
		||||
      node.postproc=proc
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    def search(token)
 | 
			
		||||
      @head.search(token.split(//))
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def create(token, preproc = nil, postproc = nil)
 | 
			
		||||
      @head.create_subnode(token.split(//), preproc, postproc)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    def match(token)
 | 
			
		||||
      case token
 | 
			
		||||
      when Array
 | 
			
		||||
      when String
 | 
			
		||||
	return match(token.split(//))
 | 
			
		||||
      else
 | 
			
		||||
	if opt
 | 
			
		||||
	  chrs.unshift ch
 | 
			
		||||
	  self.create_subnode(chrs)
 | 
			
		||||
	else
 | 
			
		||||
	  SLex.fail ErrNodeNothing
 | 
			
		||||
	end
 | 
			
		||||
	return @head.match_io(token)
 | 
			
		||||
      end
 | 
			
		||||
      ret = @head.match(token)
 | 
			
		||||
      D_DETAIL.exec_if{D_DEATIL.printf "match end: %s:%s\n", ret, token.inspect}
 | 
			
		||||
      ret
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    def create_subnode(chrs, preproc = nil, postproc = nil)
 | 
			
		||||
      if chrs.empty?
 | 
			
		||||
	if @postproc
 | 
			
		||||
	  SLex.fail ErrNodeAlreadyExists
 | 
			
		||||
	else
 | 
			
		||||
	  print "Warn: change abstract node to real node\n" if SLex.debug?
 | 
			
		||||
	  @preproc = preproc
 | 
			
		||||
	  @postproc = postproc
 | 
			
		||||
	end
 | 
			
		||||
	return self
 | 
			
		||||
    def inspect
 | 
			
		||||
      format("<SLex: @head = %s>", @head.inspect)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    #----------------------------------------------------------------------
 | 
			
		||||
    #
 | 
			
		||||
    #   class Node - 
 | 
			
		||||
    #
 | 
			
		||||
    #----------------------------------------------------------------------
 | 
			
		||||
    class Node
 | 
			
		||||
      # if postproc is nil, this node is an abstract node.
 | 
			
		||||
      # if postproc is non-nil, this node is a real node.
 | 
			
		||||
      def initialize(preproc = nil, postproc = nil)
 | 
			
		||||
	@Tree = {}
 | 
			
		||||
	@preproc = preproc
 | 
			
		||||
	@postproc = postproc
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      attr_accessor :preproc
 | 
			
		||||
      attr_accessor :postproc
 | 
			
		||||
      
 | 
			
		||||
      ch = chrs.shift
 | 
			
		||||
      if node = @Tree[ch]
 | 
			
		||||
	if chrs.empty?
 | 
			
		||||
	  if node.postproc
 | 
			
		||||
	    p node
 | 
			
		||||
	    p self
 | 
			
		||||
	    p ch
 | 
			
		||||
	    p chrs
 | 
			
		||||
	    SLex.fail ErrNodeAlreadyExists
 | 
			
		||||
	  else
 | 
			
		||||
	    print "Warn: change abstract node to real node\n" if SLex.debug?
 | 
			
		||||
	    node.preproc = preproc
 | 
			
		||||
	    node.postproc = postproc
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  node.create_subnode(chrs, preproc, postproc)
 | 
			
		||||
	end
 | 
			
		||||
      else
 | 
			
		||||
	if chrs.empty?
 | 
			
		||||
	  node = Node.new(preproc, postproc)
 | 
			
		||||
	else
 | 
			
		||||
	  node = Node.new
 | 
			
		||||
	  node.create_subnode(chrs, preproc, postproc)
 | 
			
		||||
	end
 | 
			
		||||
	@Tree[ch] = node
 | 
			
		||||
      end
 | 
			
		||||
      node
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # chrs: String
 | 
			
		||||
    #       character array
 | 
			
		||||
    #       io must have getc()/ungetc(); and ungetc() must be
 | 
			
		||||
    #       able to be called arbitrary number of times. 
 | 
			
		||||
    #
 | 
			
		||||
    def match(chrs, op = "")
 | 
			
		||||
      print "match>: ", chrs, "op:", op, "\n" if SLex.debug?
 | 
			
		||||
      if chrs.empty?
 | 
			
		||||
	if @preproc.nil? || @preproc.call(op, chrs)
 | 
			
		||||
	  printf "op1: %s\n", op if SLex.debug?
 | 
			
		||||
	  @postproc.call(op, chrs)
 | 
			
		||||
	else
 | 
			
		||||
	  nil
 | 
			
		||||
	end
 | 
			
		||||
      else
 | 
			
		||||
      def search(chrs, opt = nil)
 | 
			
		||||
	return self if chrs.empty?
 | 
			
		||||
	ch = chrs.shift
 | 
			
		||||
	if node = @Tree[ch]
 | 
			
		||||
	  if ret = node.match(chrs, op+ch)
 | 
			
		||||
	    return ret
 | 
			
		||||
	  node.search(chrs, opt)
 | 
			
		||||
	else
 | 
			
		||||
	  if opt
 | 
			
		||||
	    chrs.unshift ch
 | 
			
		||||
	    self.create_subnode(chrs)
 | 
			
		||||
	  else
 | 
			
		||||
	    SLex.fail ErrNodeNothing
 | 
			
		||||
	  end
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
      def create_subnode(chrs, preproc = nil, postproc = nil)
 | 
			
		||||
	if chrs.empty?
 | 
			
		||||
	  if @postproc
 | 
			
		||||
	    D_DETAIL.pp node
 | 
			
		||||
	    SLex.fail ErrNodeAlreadyExists
 | 
			
		||||
	  else
 | 
			
		||||
	    D_DEBUG.puts "change abstract node to real node."
 | 
			
		||||
	    @preproc = preproc
 | 
			
		||||
	    @postproc = postproc
 | 
			
		||||
	  end
 | 
			
		||||
	  return self
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	ch = chrs.shift
 | 
			
		||||
	if node = @Tree[ch]
 | 
			
		||||
	  if chrs.empty?
 | 
			
		||||
	    if node.postproc
 | 
			
		||||
	      DebugLogger.pp node
 | 
			
		||||
	      DebugLogger.pp self
 | 
			
		||||
	      DebugLogger.pp ch
 | 
			
		||||
	      DebugLogger.pp chrs
 | 
			
		||||
	      SLex.fail ErrNodeAlreadyExists
 | 
			
		||||
	    else
 | 
			
		||||
	      D_WARN.puts "change abstract node to real node"
 | 
			
		||||
	      node.preproc = preproc
 | 
			
		||||
	      node.postproc = postproc
 | 
			
		||||
	    end
 | 
			
		||||
	  else
 | 
			
		||||
	    node.create_subnode(chrs, preproc, postproc)
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  if chrs.empty?
 | 
			
		||||
	    node = Node.new(preproc, postproc)
 | 
			
		||||
	  else
 | 
			
		||||
	    node = Node.new
 | 
			
		||||
	    node.create_subnode(chrs, preproc, postproc)
 | 
			
		||||
	  end
 | 
			
		||||
	  @Tree[ch] = node
 | 
			
		||||
	end
 | 
			
		||||
	node
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      #
 | 
			
		||||
      # chrs: String
 | 
			
		||||
      #       character array
 | 
			
		||||
      #       io must have getc()/ungetc(); and ungetc() must be
 | 
			
		||||
      #       able to be called arbitrary number of times. 
 | 
			
		||||
      #
 | 
			
		||||
      def match(chrs, op = "")
 | 
			
		||||
	D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
 | 
			
		||||
	if chrs.empty?
 | 
			
		||||
	  if @preproc.nil? || @preproc.call(op, chrs)
 | 
			
		||||
	    DOUT.printf(D_DETAIL, "op1: %s\n", op)
 | 
			
		||||
	    @postproc.call(op, chrs)
 | 
			
		||||
	  else
 | 
			
		||||
	    nil
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  ch = chrs.shift
 | 
			
		||||
	  if node = @Tree[ch]
 | 
			
		||||
	    if ret = node.match(chrs, op+ch)
 | 
			
		||||
	      return ret
 | 
			
		||||
	    else
 | 
			
		||||
	      chrs.unshift ch
 | 
			
		||||
	      if @postproc and @preproc.nil? || @preproc.call(op, chrs)
 | 
			
		||||
		DOUT.printf(D_DETAIL, "op2: %s\n", op.inspect)
 | 
			
		||||
		ret = @postproc.call(op, chrs)
 | 
			
		||||
		return ret
 | 
			
		||||
	      else
 | 
			
		||||
		return nil
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
	  else
 | 
			
		||||
	    chrs.unshift ch
 | 
			
		||||
	    if @postproc and @preproc.nil? || @preproc.call(op, chrs)
 | 
			
		||||
	      printf "op2: %s\n", op.inspect if SLex.debug?
 | 
			
		||||
	      ret = @postproc.call(op, chrs)
 | 
			
		||||
	      return ret
 | 
			
		||||
	      DOUT.printf(D_DETAIL, "op3: %s\n", op)
 | 
			
		||||
	      @postproc.call(op, chrs)
 | 
			
		||||
	      return ""
 | 
			
		||||
	    else
 | 
			
		||||
	      return nil
 | 
			
		||||
	    end
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  chrs.unshift ch
 | 
			
		||||
	  if @postproc and @preproc.nil? || @preproc.call(op, chrs)
 | 
			
		||||
	    printf "op3: %s\n", op if SLex.debug?
 | 
			
		||||
	    @postproc.call(op, chrs)
 | 
			
		||||
	    return ""
 | 
			
		||||
	  else
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def match_io(io, op = "")
 | 
			
		||||
	if op == ""
 | 
			
		||||
	  ch = io.getc
 | 
			
		||||
	  if ch == nil
 | 
			
		||||
	    return nil
 | 
			
		||||
	  end
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def match_io(io, op = "")
 | 
			
		||||
      if op == ""
 | 
			
		||||
	ch = io.getc
 | 
			
		||||
	if ch == nil
 | 
			
		||||
	  return nil
 | 
			
		||||
	end
 | 
			
		||||
      else
 | 
			
		||||
	ch = io.getc_of_rests
 | 
			
		||||
      end
 | 
			
		||||
      if ch.nil?
 | 
			
		||||
	if @preproc.nil? || @preproc.call(op, io)
 | 
			
		||||
	  printf "op1: %s\n", op if SLex.debug?
 | 
			
		||||
	  @postproc.call(op, io)
 | 
			
		||||
	else
 | 
			
		||||
	  nil
 | 
			
		||||
	  ch = io.getc_of_rests
 | 
			
		||||
	end
 | 
			
		||||
      else
 | 
			
		||||
	if node = @Tree[ch]
 | 
			
		||||
	  if ret = node.match_io(io, op+ch)
 | 
			
		||||
	    ret
 | 
			
		||||
	if ch.nil?
 | 
			
		||||
	  if @preproc.nil? || @preproc.call(op, io)
 | 
			
		||||
	    D_DETAIL.printf("op1: %s\n", op)
 | 
			
		||||
	    @postproc.call(op, io)
 | 
			
		||||
	  else
 | 
			
		||||
	    nil
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  if node = @Tree[ch]
 | 
			
		||||
	    if ret = node.match_io(io, op+ch)
 | 
			
		||||
	      ret
 | 
			
		||||
	    else
 | 
			
		||||
	      io.ungetc ch
 | 
			
		||||
	      if @postproc and @preproc.nil? || @preproc.call(op, io)
 | 
			
		||||
		DOUT.exec_if{D_DETAIL.printf "op2: %s\n", op.inspect}
 | 
			
		||||
		@postproc.call(op, io)
 | 
			
		||||
	      else
 | 
			
		||||
		nil
 | 
			
		||||
	      end
 | 
			
		||||
	    end
 | 
			
		||||
	  else
 | 
			
		||||
	    io.ungetc ch
 | 
			
		||||
	    if @postproc and @preproc.nil? || @preproc.call(op, io)
 | 
			
		||||
	      printf "op2: %s\n", op.inspect if SLex.debug?
 | 
			
		||||
	      D_DETAIL.printf("op3: %s\n", op)
 | 
			
		||||
	      @postproc.call(op, io)
 | 
			
		||||
	    else
 | 
			
		||||
	      nil
 | 
			
		||||
	    end
 | 
			
		||||
	  end
 | 
			
		||||
	else
 | 
			
		||||
	  io.ungetc ch
 | 
			
		||||
	  if @postproc and @preproc.nil? || @preproc.call(op, io)
 | 
			
		||||
	    printf "op3: %s\n", op if SLex.debug?
 | 
			
		||||
	    @postproc.call(op, io)
 | 
			
		||||
	  else
 | 
			
		||||
	    nil
 | 
			
		||||
	  end
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
SLex=IRB::SLex
 | 
			
		||||
 | 
			
		||||
if $0 == __FILE__
 | 
			
		||||
  #    Tracer.on
 | 
			
		||||
  case $1
 | 
			
		||||
| 
						 | 
				
			
			@ -275,3 +282,4 @@ if $0 == __FILE__
 | 
			
		|||
  end
 | 
			
		||||
  exit
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/version.rb - irb version definition file
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
| 
						 | 
				
			
			@ -11,6 +11,6 @@
 | 
			
		|||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
  @RELEASE_VERSION = "0.9"
 | 
			
		||||
  @LAST_UPDATE_DATE = "02/07/03"
 | 
			
		||||
  @RELEASE_VERSION = "0.9.5"
 | 
			
		||||
  @LAST_UPDATE_DATE = "05/04/13"
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/workspace-binding.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,9 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ws-for-case-2.rb - 
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
 | 
			
		||||
#   	by Keiju ISHITSUKA(keiju@ruby-lang.org)
 | 
			
		||||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue