Module: Yaparc::Parsable

Overview

of module Result

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

IS_LOWER =
lambda {|c| c >= 'a' and c <= 'z'}
IS_ALPHANUM =
lambda {|c| (c >= 'a' and c <= 'z') or (c >= '0' and c <= '9')}
IS_DIGIT =
lambda {|i| i >= '0' and i <= '9'}
IS_SPACE =
lambda {|i| i == ' '}
IS_WHITESPACE =
lambda {|i| i == ' ' or i == "\n" or i == "\t"}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#treeObject

Returns the value of attribute tree.



23
24
25
# File 'lib/yaparc.rb', line 23

def tree
  @tree
end

Class Method Details

.included(mod) ⇒ Object



31
32
33
# File 'lib/yaparc.rb', line 31

def self.included(mod)
  mod.extend ClassMethods
end

Instance Method Details

#evalObject



51
52
53
# File 'lib/yaparc.rb', line 51

def eval
  tree = parse(input)
end

#parse(input, &block) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/yaparc.rb', line 35

def parse(input, &block)
  result = @parser.call(input)

  if result.respond_to? :parse
    result = result.parse(input)
  else
    if block_given?
      result.value = yield result.value
      @tree = result
    else
      @tree = result.value
    end
    result
  end
end