mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Merge from irb 0.7.3.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f8ab487e4d
commit
859a7a9277
8 changed files with 64 additions and 59 deletions
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# input-method.rb - input methods using irb
|
||||
# $Release Version: 0.6$
|
||||
# irb/input-method.rb - input methods using irb
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
@ -23,9 +23,9 @@ module IRB
|
|||
def initialize(file = STDIN_FILE_NAME)
|
||||
@file_name = file
|
||||
end
|
||||
attr :file_name
|
||||
attr_reader :file_name
|
||||
|
||||
attr :prompt, true
|
||||
attr_accessor :prompt
|
||||
|
||||
def gets
|
||||
IRB.fail NotImplementError, "gets"
|
||||
|
@ -67,7 +67,7 @@ module IRB
|
|||
super
|
||||
@io = open(file)
|
||||
end
|
||||
attr :file_name
|
||||
attr_reader :file_name
|
||||
|
||||
def eof?
|
||||
@io.eof?
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# irb-loader.rb -
|
||||
# $Release Version: 0.6$
|
||||
# irb/loader.rb - irb loader
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# multi-irb.rb - multiple irb module
|
||||
# $Release Version: 0.6$
|
||||
# irb/multi-irb.rb - multiple irb module(JP: $BJ#?t(Birb$BBP1~%b%8%e!<%k(B)
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
@ -14,6 +14,7 @@ require "thread"
|
|||
|
||||
module IRB
|
||||
# job management class
|
||||
# (JP: job$B4IM}%/%i%9(B)
|
||||
class JobManager
|
||||
@RCS_ID='-$Id$-'
|
||||
|
||||
|
@ -23,7 +24,7 @@ module IRB
|
|||
@current_job = nil
|
||||
end
|
||||
|
||||
attr :current_job, true
|
||||
attr_accessor :current_job
|
||||
|
||||
def n_jobs
|
||||
@jobs.size
|
||||
|
@ -140,20 +141,16 @@ module IRB
|
|||
@JobManager
|
||||
end
|
||||
|
||||
# invoke multiple irb
|
||||
# invoke multi-irb
|
||||
# (JP: irb$B5/F0(B)
|
||||
def IRB.irb(file = nil, *main)
|
||||
workspace = IRB.workspace_binding(*main)
|
||||
if main.empty?
|
||||
main = eval("self", workspace)
|
||||
else
|
||||
main = main[0]
|
||||
end
|
||||
workspace = WorkSpace.new(*main)
|
||||
parent_thread = Thread.current
|
||||
Thread.start do
|
||||
begin
|
||||
irb = Irb.new(main, workspace, file)
|
||||
irb = Irb.new(workspace, file)
|
||||
rescue
|
||||
print "Subirb can't start with context(self): ", main.inspect, "\n"
|
||||
print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
|
||||
print "return to main irb\n"
|
||||
Thread.pass
|
||||
Thread.main.wakeup
|
||||
|
@ -190,7 +187,7 @@ module IRB
|
|||
class Context
|
||||
def _=(value)
|
||||
@_ = value
|
||||
eval "_ = IRB.JobManager.irb(Thread.current).context._", @bind
|
||||
@workspace.evaluate "_ = IRB.JobManager.irb(Thread.current).context._"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -198,7 +195,7 @@ module IRB
|
|||
def irb_context
|
||||
IRB.JobManager.irb(Thread.current).context
|
||||
end
|
||||
alias conf irb_context
|
||||
# alias conf irb_context
|
||||
end
|
||||
|
||||
@CONF[:SINGLE_IRB_MODE] = false
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# ruby-lex.rb - ruby lexcal analizer
|
||||
# $Release Version: 0.6$
|
||||
# irb/ruby-lex.rb - ruby lexcal analizer
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
@ -202,8 +202,8 @@ class RubyLex
|
|||
@space_seen = false
|
||||
@here_header = false
|
||||
|
||||
prompt
|
||||
@continue = false
|
||||
prompt
|
||||
|
||||
@line = ""
|
||||
@exp_line_no = @line_no
|
||||
|
@ -239,8 +239,8 @@ class RubyLex
|
|||
until (((tk = token).kind_of?(TkNL) || tk.kind_of?(TkEND_OF_SCRIPT)) &&
|
||||
!@continue or
|
||||
tk.nil?)
|
||||
# p tk
|
||||
# p self
|
||||
#p tk
|
||||
#p self
|
||||
end
|
||||
line = get_readed
|
||||
# print self.inspect
|
||||
|
@ -333,7 +333,7 @@ class RubyLex
|
|||
until peek_equal?("=end") && peek(4) =~ /\s/
|
||||
until getc == "\n"; end
|
||||
end
|
||||
getc; getc; getc; getc
|
||||
gets
|
||||
@ltype = nil
|
||||
Token(TkRD_COMMENT)
|
||||
end
|
||||
|
@ -459,6 +459,7 @@ class RubyLex
|
|||
identify_number
|
||||
else
|
||||
# for obj.if
|
||||
# (JP: obj.if $B$J$I$NBP1~(B)
|
||||
@lex_state = EXPR_DOT
|
||||
Token(TkDOT)
|
||||
end
|
||||
|
@ -691,7 +692,8 @@ class RubyLex
|
|||
if ch == "!" or ch == "?"
|
||||
token.concat getc
|
||||
end
|
||||
# fix token
|
||||
# almost fix token
|
||||
# (JP: $BBgBN(Bfix token)
|
||||
|
||||
case token
|
||||
when /^\$/
|
||||
|
@ -707,11 +709,13 @@ class RubyLex
|
|||
token_c, *trans = TkReading2Token[token]
|
||||
if token_c
|
||||
# reserved word?
|
||||
# (JP: $BM=Ls8l$+$I$&$+(B?)
|
||||
|
||||
if (@lex_state != EXPR_BEG &&
|
||||
@lex_state != EXPR_FNAME &&
|
||||
trans[1])
|
||||
# modifiers
|
||||
# (JP: $B=$>~;R(B)
|
||||
token_c = TkSymbol2Token[trans[1]]
|
||||
@lex_state = trans[0]
|
||||
else
|
||||
|
@ -752,6 +756,7 @@ class RubyLex
|
|||
|
||||
def identify_here_document
|
||||
ch = getc
|
||||
# if lt = PERCENT_LTYPE[ch]
|
||||
if ch == "-"
|
||||
ch = getc
|
||||
indent = true
|
||||
|
@ -954,7 +959,8 @@ class RubyLex
|
|||
read_escape(chrs)
|
||||
end
|
||||
else
|
||||
# other characters
|
||||
# other characters
|
||||
#(JP:$B$=$NB>$NJ8;z(B)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# ruby-token.rb - ruby tokens
|
||||
# $Release Version: 0.6$
|
||||
# irb/ruby-token.rb - ruby tokens
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
@ -17,6 +17,11 @@ module RubyToken
|
|||
EXPR_FNAME = :EXPR_FNAME
|
||||
EXPR_DOT = :EXPR_DOT
|
||||
EXPR_CLASS = :EXPR_CLASS
|
||||
|
||||
# for ruby 1.4X
|
||||
if !defined?(Symbol)
|
||||
Symbol = Integer
|
||||
end
|
||||
|
||||
class Token
|
||||
def initialize(seek, line_no, char_no)
|
||||
|
@ -241,7 +246,7 @@ module RubyToken
|
|||
TkSymbol2Token = {}
|
||||
|
||||
def RubyToken.def_token(token_n, super_token = Token, reading = nil, *opts)
|
||||
token_n = token_n.id2name unless token_n.kind_of?(String)
|
||||
token_n = token_n.id2name if token_n.kind_of?(Symbol)
|
||||
if RubyToken.const_defined?(token_n)
|
||||
IRB.fail AlreadyDefinedToken, token_n
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# irb-slex.rb - symple lex analizer
|
||||
# $Release Version: 0.6$
|
||||
# irb/slex.rb - symple lex analizer
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
# by Keiju ISHITSUKA(keiju@ishituska.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
@ -20,7 +20,7 @@ class SLex
|
|||
def_exception :ErrNodeAlreadyExists, "node already exists"
|
||||
|
||||
class << self
|
||||
attr :debug_level, TRUE
|
||||
attr_accessor :debug_level
|
||||
def debug?
|
||||
debug_level > 0
|
||||
end
|
||||
|
@ -90,14 +90,15 @@ class SLex
|
|||
class Node
|
||||
# if postproc no exist, this node is abstract node.
|
||||
# if postproc isn't nil, this node is real node.
|
||||
# (JP: postproc$B$,$J$1$l$PCj>]%N!<%I(B, nil$B$8$c$J$1$l$P6q>]%N!<%I(B)
|
||||
def initialize(preproc = nil, postproc = nil)
|
||||
@Tree = {}
|
||||
@preproc = preproc
|
||||
@postproc = postproc
|
||||
end
|
||||
|
||||
attr :preproc, TRUE
|
||||
attr :postproc, TRUE
|
||||
attr_accessor :preproc
|
||||
attr_accessor :postproc
|
||||
|
||||
def search(chrs, opt = nil)
|
||||
return self if chrs.empty?
|
||||
|
@ -158,9 +159,11 @@ class SLex
|
|||
|
||||
#
|
||||
# chrs: String
|
||||
# character array
|
||||
# character array (JP: $B0lJ8;z$E$D$N(BArray)
|
||||
# io It must have getc()/ungetc(), and ungetc() can be
|
||||
# called any number of times.
|
||||
# (JP:$B$@$@$7(B, getc/ungetc$B$,Hw$o$C$F$$$J$1$l$P$J$i$J$$(B.
|
||||
# $B$5$i$K(B, ungetc$B$OJ#?t2s2DG=$G$J$/$F$O$J$i$J$$(B.)
|
||||
#
|
||||
def match(chrs, op = "")
|
||||
print "match>: ", chrs, "op:", op, "\n" if SLex.debug?
|
||||
|
@ -265,7 +268,7 @@ if $0 == __FILE__
|
|||
print "0: ", tr.inspect, "\n"
|
||||
tr.def_rule("=") {print "=\n"}
|
||||
print "1: ", tr.inspect, "\n"
|
||||
tr.def_rule("==", proc{FALSE}) {print "==\n"}
|
||||
tr.def_rule("==", proc{false}) {print "==\n"}
|
||||
print "2: ", tr.inspect, "\n"
|
||||
|
||||
print "case 1:\n"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#
|
||||
# version.rb - irb version definition file
|
||||
# $Release Version: 0.6.1$
|
||||
# irb/version.rb - irb version definition file
|
||||
# $Release Version: 0.7.3$
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
# --
|
||||
#
|
||||
|
@ -11,6 +11,6 @@
|
|||
#
|
||||
|
||||
module IRB
|
||||
@RELEASE_VERSION = "0.6.1"
|
||||
@LAST_UPDATE_DATE = "99/09/16"
|
||||
@RELEASE_VERSION = "0.7.3"
|
||||
@LAST_UPDATE_DATE = "01/04/16"
|
||||
end
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# irb.rb - intaractive ruby
|
||||
# $Release Version: 0.6 $
|
||||
# $Release Version: 0.7.3 $
|
||||
# $Revision$
|
||||
# $Date$
|
||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
||||
#
|
||||
# --
|
||||
# Usage:
|
||||
#
|
||||
# irb.rb [options] file_name opts
|
||||
#
|
||||
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||
#
|
||||
|
||||
require "irb/main"
|
||||
require "irb"
|
||||
|
||||
if __FILE__ == $0
|
||||
IRB.start(__FILE__)
|
||||
|
|
Loading…
Add table
Reference in a new issue