зеркало из https://github.com/github/ruby.git
Use Ripper for IRB
The debug option of IRB is deleted because it's just for IRB's pure Ruby parser.
This commit is contained in:
Родитель
567cb1ae1d
Коммит
94b740b249
|
@ -70,8 +70,6 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
|
|||
--back-trace-limit n
|
||||
バックトレース表示をバックトレースの頭から n, 後ろ
|
||||
からnだけ行なう. デフォルトは16
|
||||
--irb_debug n irbのデバッグデバッグレベルをnに設定する(利用しな
|
||||
い方が無難でしょう).
|
||||
-v, --version irbのバージョンを表示する
|
||||
|
||||
= コンフィギュレーション
|
||||
|
@ -97,7 +95,6 @@ irb起動時に``~/.irbrc''を読み込みます. もし存在しない場合は
|
|||
IRB.conf[:IGNORE_EOF] = false
|
||||
IRB.conf[:PROMPT_MODE] = :DEFAULT
|
||||
IRB.conf[:PROMPT] = {...}
|
||||
IRB.conf[:DEBUG_LEVEL]=0
|
||||
IRB.conf[:VERBOSE]=true
|
||||
|
||||
== プロンプトの設定
|
||||
|
@ -183,9 +180,6 @@ irb拡張コマンドは, 簡単な名前と頭に`irb_'をつけた名前と両
|
|||
バックトレース表示をバックトレースの頭からn, 後ろからnだけ行なう.
|
||||
デフォルトは16
|
||||
|
||||
--- conf.debug_level = N
|
||||
irb用のデバッグレベルの設定
|
||||
|
||||
--- conf.ignore_eof = true/false
|
||||
^Dが入力された時の動作を設定する. trueの時は^Dを無視する, falseの
|
||||
時はirbを終了する.
|
||||
|
|
|
@ -74,7 +74,6 @@ require "irb/version"
|
|||
# --back-trace-limit n
|
||||
# Display backtrace top n and tail n. The default
|
||||
# value is 16.
|
||||
# --irb_debug n Set internal debug level to n (not for popular use)
|
||||
# -v, --version Print the version of irb
|
||||
#
|
||||
# == Configuration
|
||||
|
@ -102,7 +101,6 @@ require "irb/version"
|
|||
# IRB.conf[:IGNORE_EOF] = false
|
||||
# IRB.conf[:PROMPT_MODE] = :DEFAULT
|
||||
# IRB.conf[:PROMPT] = {...}
|
||||
# IRB.conf[:DEBUG_LEVEL]=0
|
||||
#
|
||||
# === Auto indentation
|
||||
#
|
||||
|
@ -413,7 +411,6 @@ module IRB
|
|||
@signal_status = :IN_IRB
|
||||
|
||||
@scanner = RubyLex.new
|
||||
@scanner.exception_on_syntax_error = false
|
||||
end
|
||||
|
||||
def run(conf = IRB.conf)
|
||||
|
|
|
@ -101,7 +101,6 @@ module IRB
|
|||
if @echo.nil?
|
||||
@echo = true
|
||||
end
|
||||
self.debug_level = IRB.conf[:DEBUG_LEVEL]
|
||||
end
|
||||
|
||||
# The top-level workspace, see WorkSpace#main
|
||||
|
@ -211,10 +210,6 @@ module IRB
|
|||
#
|
||||
# A copy of the default <code>IRB.conf[:VERBOSE]</code>
|
||||
attr_accessor :verbose
|
||||
# The debug level of irb
|
||||
#
|
||||
# See #debug_level= for more information.
|
||||
attr_reader :debug_level
|
||||
|
||||
# The limit of backtrace lines displayed as top +n+ and tail +n+.
|
||||
#
|
||||
|
@ -361,21 +356,6 @@ module IRB
|
|||
print "Do nothing."
|
||||
end
|
||||
|
||||
# Sets the debug level of irb
|
||||
#
|
||||
# Can also be set using the +--irb_debug+ command line option.
|
||||
#
|
||||
# See IRB@Command+line+options for more command line options.
|
||||
def debug_level=(value)
|
||||
@debug_level = value
|
||||
RubyLex.debug_level = value
|
||||
end
|
||||
|
||||
# Whether or not debug mode is enabled, see #debug_level=.
|
||||
def debug?
|
||||
@debug_level > 0
|
||||
end
|
||||
|
||||
def evaluate(line, line_no, exception: nil) # :nodoc:
|
||||
@line_no = line_no
|
||||
if exception
|
||||
|
|
|
@ -112,8 +112,6 @@ module IRB # :nodoc:
|
|||
@CONF[:LC_MESSAGES] = Locale.new
|
||||
|
||||
@CONF[:AT_EXIT] = []
|
||||
|
||||
@CONF[:DEBUG_LEVEL] = 0
|
||||
end
|
||||
|
||||
def IRB.init_error
|
||||
|
@ -191,8 +189,6 @@ module IRB # :nodoc:
|
|||
@CONF[:CONTEXT_MODE] = ($1 || argv.shift).to_i
|
||||
when "--single-irb"
|
||||
@CONF[:SINGLE_IRB] = true
|
||||
when /^--irb_debug(?:=(.+))?/
|
||||
@CONF[:DEBUG_LEVEL] = ($1 || argv.shift).to_i
|
||||
when "-v", "--version"
|
||||
print IRB.version, "\n"
|
||||
exit 0
|
||||
|
|
|
@ -39,7 +39,6 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|||
--back-trace-limit n
|
||||
Display backtrace top n and tail n. The default
|
||||
value is 16.
|
||||
--irb_debug n Set internal debug level to n (not for popular use)
|
||||
--verbose Show details
|
||||
--noverbose Don't show details
|
||||
-v, --version Print the version of irb
|
||||
|
|
|
@ -41,8 +41,6 @@ Usage: irb.rb [options] [programfile] [arguments]
|
|||
バックトレース表示をバックトレースの頭から n, 後ろ
|
||||
からnだけ行なう. デフォルトは16
|
||||
|
||||
--irb_debug n irbのデバッグレベルをnに設定する(非推奨).
|
||||
|
||||
--verbose 詳細なメッセージを出力する.
|
||||
--noverbose 詳細なメッセージを出力しない(デフォルト).
|
||||
-v, --version irbのバージョンを表示する.
|
||||
|
|
1259
lib/irb/ruby-lex.rb
1259
lib/irb/ruby-lex.rb
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -1,108 +0,0 @@
|
|||
# frozen_string_literal: false
|
||||
require 'test/unit'
|
||||
require 'irb/ruby-lex'
|
||||
require 'stringio'
|
||||
|
||||
module TestIRB
|
||||
class TestRubyLex < Test::Unit::TestCase
|
||||
def setup
|
||||
@scanner = RubyLex.new
|
||||
end
|
||||
|
||||
def teardown
|
||||
RubyLex.debug_level = 0
|
||||
end
|
||||
|
||||
def test_set_input_proc
|
||||
called = false
|
||||
@scanner.set_input(nil) {called = true; nil}
|
||||
@scanner.each_top_level_statement {}
|
||||
assert(called)
|
||||
end
|
||||
|
||||
def test_comment
|
||||
assert_equal([["#\n", 1]], top_level_statement("#\n"))
|
||||
end
|
||||
|
||||
def test_top_level_statement
|
||||
result = top_level_statement("#{<<-"begin;"}#{<<~"end;"}")
|
||||
begin;
|
||||
begin
|
||||
end
|
||||
begin
|
||||
end
|
||||
end;
|
||||
assert_equal([
|
||||
["begin\n""end\n", 1],
|
||||
["begin\n""end\n", 3],
|
||||
],
|
||||
result)
|
||||
end
|
||||
|
||||
def test_immature_statement
|
||||
src = "if false\n"
|
||||
assert_equal([[src, 1]], top_level_statement(src))
|
||||
end
|
||||
|
||||
def test_prompt
|
||||
prompts = []
|
||||
@scanner.set_prompt {|*a|
|
||||
a << @scanner.instance_variable_get(:@lex_state)
|
||||
unless prompts.last == a
|
||||
prompts << a
|
||||
end
|
||||
}
|
||||
src, lineno = "#{<<-"begin;"}#{<<~'end;'}", __LINE__+1
|
||||
begin;
|
||||
# #;# LTYPE:INDENT:CONTINUE
|
||||
x #;# -:0:-
|
||||
x( #;# -:0:-
|
||||
) #;# -:1:*
|
||||
a \ #;# -:0:-
|
||||
#;# -:0:*
|
||||
a; #;# -:0:-
|
||||
a #;# -:0:-
|
||||
#;# -:0:-
|
||||
a #;# -:0:-
|
||||
a = #;# -:0:-
|
||||
' #;# -:0:*
|
||||
' #;# ':0:*
|
||||
if false or #;# -:0:-
|
||||
true #;# -:1:*
|
||||
a #;# -:1:-
|
||||
" #;# -:1:-
|
||||
" #;# ":1:-
|
||||
begin #;# -:1:-
|
||||
a #;# -:2:-
|
||||
a #;# -:2:-
|
||||
end #;# -:2:-
|
||||
else #;# -:1:-
|
||||
nil #;# -:1:-
|
||||
end #;# -:1:-
|
||||
end;
|
||||
top_level_statement(src.gsub(/[ \t]*#;#.*/, ''))
|
||||
src.each_line.with_index(1) do |line, i|
|
||||
p = prompts.shift
|
||||
next unless /#;#\s*(?:-|(?<ltype>\S)):(?<indent>\d+):(?:(?<cont>\*)|-)(?:.*FIXME:(?<fixme>.*))?/ =~ line
|
||||
indent = indent.to_i
|
||||
cont = (fixme && /`continue'/.match?(fixme)) ^ cont
|
||||
assert_equal([ltype, indent, cont, i], p[0..3], "#{lineno+i}:#{p[4]}: #{line}")
|
||||
end
|
||||
end
|
||||
|
||||
def top_level_statement(lines)
|
||||
input = InputLines.new(lines, "r")
|
||||
scanned = []
|
||||
@scanner.set_input(input)
|
||||
@scanner.each_top_level_statement {|*e|
|
||||
scanned << e
|
||||
yield(*e) if defined?(yield)
|
||||
}
|
||||
scanned
|
||||
end
|
||||
|
||||
class InputLines < StringIO
|
||||
alias encoding external_encoding
|
||||
end
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче