Class: Yaparc::Tokenize

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 collapse

Attributes included from Parsable

#tree

Instance Method Summary collapse

Methods included from Parsable

#parse

Constructor Details

#initialize(parser, args = {}, &block) ⇒ Tokenize

Returns a new instance of Tokenize.



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/yaparc.rb', line 386

def initialize(parser, args = {}, &block)
  @parser = lambda do |input|
    @prefix = args[:prefix] ? args[:prefix] : WhiteSpace.new
    @postfix = args[:postfix] ? args[:postfix] : WhiteSpace.new
    if block_given?
      yield self
      Seq.new(@prefix, parser, @postfix) do |_, vs, _|
        vs
      end
    else
      Seq.new(@prefix, parser, @postfix) do |_, vs, _|
        vs
      end
    end
  end
end

Instance Attribute Details

#postfixObject

Returns the value of attribute postfix.



384
385
386
# File 'lib/yaparc.rb', line 384

def postfix
  @postfix
end

#prefixObject

Returns the value of attribute prefix.



384
385
386
# File 'lib/yaparc.rb', line 384

def prefix
  @prefix
end