Class: IRB::SLex

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/parser/ruby/legacy/irb/slex.rb

Defined Under Namespace

Classes: Node

Constant Summary collapse

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: ")

Instance Method Summary collapse

Constructor Details

#initializeSLex

Returns a new instance of SLex.



25
26
27
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 25

def initialize
  @head = Node.new("")
end

Instance Method Details

#create(token, preproc = nil, postproc = nil) ⇒ Object



60
61
62
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 60

def create(token, preproc = nil, postproc = nil)
  @head.create_subnode(token.split(//), preproc, postproc)
end

#def_rule(token, preproc = nil, postproc = nil, &block) ⇒ Object



29
30
31
32
33
34
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 29

def def_rule(token, preproc = nil, postproc = nil, &block)
  D_DETAIL.pp token

  postproc = block if block_given?
  create(token, preproc, postproc)
end

#def_rules(*tokens, &block) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 36

def def_rules(*tokens, &block)
  if block_given?
    p = block
  end
  for token in tokens
    def_rule(token, nil, p)
  end
end

#inspectObject



77
78
79
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 77

def inspect
  format("<SLex: @head = %s>", @head.inspect)
end

#match(token) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 64

def match(token)
  case token
  when Array
  when String
    return match(token.split(//))
  else
    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

#postproc(token) ⇒ Object

need a check?



51
52
53
54
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 51

def postproc(token)
  node = search(token, proc)
  node.postproc=proc
end

#preproc(token, proc) ⇒ Object



45
46
47
48
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 45

def preproc(token, proc)
  node = search(token)
  node.preproc=proc
end

#search(token) ⇒ Object



56
57
58
# File 'lib/yard/parser/ruby/legacy/irb/slex.rb', line 56

def search(token)
  @head.search(token.split(//))
end