Module: Yaparc::Parsable
- Included in:
- AbstractParser, Alt, Apply, Char, Digit, Fail, Ident, Identifier, Item, Literal, Many, ManyOne, Nat, Natural, NoFail, Regex, Satisfy, Seq, Space, String, Succeed, Symbol, Tokenize, WhiteSpace, ZeroOne
- Defined in:
- lib/yaparc.rb
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
-
#tree ⇒ Object
Returns the value of attribute tree.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#tree ⇒ Object
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
#eval ⇒ Object
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 |