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