class IRB::SLex

def create(token, preproc = nil, postproc = nil)

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

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

def def_rule(token, preproc = nil, postproc = nil, &block)
  D_DETAIL.pp token
  postproc = block if block_given?
  create(token, preproc, postproc)
end

def def_rules(*tokens, &block)

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

def initialize

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

def inspect

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

def match(token)

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

def postproc(token)

need a check?
def postproc(token)
  node = search(token, proc)
  node.postproc=proc
end

def preproc(token, proc)

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

def search(token)

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