class DParse::Parsers::Bind

Public Class Methods

new(parser, &block) click to toggle source
# File lib/d-parse/parsers/primitives/bind.rb, line 4
def initialize(parser, &block)
  @parser = parser
  @block = block
end

Public Instance Methods

inspect() click to toggle source
# File lib/d-parse/parsers/primitives/bind.rb, line 20
def inspect
  "bind(#{@parser}, <proc>)"
end
read(input, pos) click to toggle source
# File lib/d-parse/parsers/primitives/bind.rb, line 9
def read(input, pos)
  res = @parser.read(input, pos)
  case res
  when Success
    other_parser = @block.call(res.data)
    other_parser.read(input, res.pos)
  when Failure
    res
  end
end