Class: Yaparc::Char

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

Overview

case result = Yaparc::Alt.new(*keyword_parsers).parse(input)

        when Yaparc::Result::OK
          Yaparc::Fail.new
        else # Result::Fail or Result::Error
          Tokenize.new(@@identifier_regex)
        end
      end
    end
  end
end

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(char, case_sensitive = true) ⇒ Char

Returns a new instance of Char.



522
523
524
525
526
527
528
529
530
531
532
# File 'lib/yaparc.rb', line 522

def initialize(char, case_sensitive = true)
  raise unless char.length == 1
  if case_sensitive
    equal_char = lambda {|i| i == char}
  else # in case of case-insentive
    equal_char = lambda {|i| i.casecmp(char) == 0}
  end
  @parser =  lambda do |input|
    Satisfy.new(equal_char)
  end
end