Class: Yaparc::String

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

Constant Summary

Constants included from Parsable

Parsable::IS_ALPHANUM, Parsable::IS_CR, 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

#parse

Constructor Details

#initialize(string, case_sensitive = true) ⇒ String

Returns a new instance of String.



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/yaparc.rb', line 246

def initialize(string, case_sensitive = true)
  @parser = lambda do |input|
    result = Item.new.parse(string)
    if result.instance_of?(Result::OK)
      Seq.new(
              Char.new(result.value, case_sensitive),
              Yaparc::String.new(result.input, case_sensitive),
              Succeed.new(result.value + result.input)
#                  ) do |char_result, string_result, succeed_result|
              ) do |_, _, succeed_result|
        succeed_result
      end
    else
      Succeed.new(result)
    end
  end
end