Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions lib/yard/parser/ruby/legacy/irb/slex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,14 @@
#
#

require "irb/notifier"

# @private
module IRB
class SLex
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: ")

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?
create(token, preproc, postproc)
end
Expand Down Expand Up @@ -70,7 +59,6 @@ def match(token)
return @head.match_io(token)
end
ret = @head.match(token)
D_DETAIL.exec_if{D_DETAIL.printf "match end: %s:%s\n", ret, token.inspect}
ret
end

Expand Down Expand Up @@ -113,10 +101,8 @@ def search(chrs, opt = nil)
def create_subnode(chrs, preproc = nil, postproc = nil)
if chrs.empty?
if @postproc
D_DETAIL.pp node
raise "node already exists"
else
D_DEBUG.puts "change abstract node to real node."
@preproc = preproc
@postproc = postproc
end
Expand All @@ -127,13 +113,8 @@ def create_subnode(chrs, preproc = nil, postproc = nil)
if node = @Tree[ch]
if chrs.empty?
if node.postproc
DebugLogger.pp node
DebugLogger.pp self
DebugLogger.pp ch
DebugLogger.pp chrs
raise "node already exists"
else
D_WARN.puts "change abstract node to real node"
node.preproc = preproc
node.postproc = postproc
end
Expand All @@ -159,10 +140,8 @@ def create_subnode(chrs, preproc = nil, postproc = nil)
# 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
Expand All @@ -175,7 +154,6 @@ def match(chrs, op = "")
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
Expand All @@ -185,7 +163,6 @@ def match(chrs, op = "")
else
chrs.unshift ch
if @postproc and @preproc.nil? || @preproc.call(op, chrs)
DOUT.printf(D_DETAIL, "op3: %s\n", op)
@postproc.call(op, chrs)
return ""
else
Expand All @@ -206,7 +183,6 @@ def match_io(io, op = "")
end
if ch.nil?
if @preproc.nil? || @preproc.call(op, io)
D_DETAIL.printf("op1: %s\n", op)
@postproc.call(op, io)
else
nil
Expand All @@ -218,7 +194,6 @@ def match_io(io, op = "")
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
Expand All @@ -227,7 +202,6 @@ def match_io(io, op = "")
else
io.ungetc ch
if @postproc and @preproc.nil? || @preproc.call(op, io)
D_DETAIL.printf("op3: %s\n", op)
@postproc.call(op, io)
else
nil
Expand Down