Class: Yaparc::NoFail

Inherits:
Object
  • Object
show all
Includes:
Parsable
Defined in:
lib/yaparc.rb

Constant Summary

Constants included from Parsable

Parsable::IS_ALPHANUM, Parsable::IS_DIGIT, Parsable::IS_LOWER, Parsable::IS_SPACE, Parsable::IS_WHITESPACE

Instance Attribute Summary

Attributes included from Parsable

#tree

Instance Method Summary collapse

Methods included from Parsable

#eval, included, #parse

Constructor Details

#initialize(parser, &block) ⇒ NoFail

Returns a new instance of NoFail.



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/yaparc.rb', line 168

def initialize(parser, &block)
  @parser = lambda do |input|
    case result = parser.parse(input)
    when Result::Fail
      Result::Error.new(:value => result.value, :input => result.input)
    when Result::OK
      Succeed.new(result.value)
    else
      Succeed.new(result.value)
#          Result::OK.new(:value => result.value,:input => result.input)
    end
  end
end