Class: Farseer::Many

Inherits:
Object
  • Object
show all
Includes:
MapFactory
Defined in:
lib/farseer/many.rb

Instance Method Summary collapse

Methods included from MapFactory

#map

Constructor Details

#initialize(parser) ⇒ Many

Returns a new instance of Many.



7
8
9
10
# File 'lib/farseer/many.rb', line 7

def initialize(parser)
  @parser = parser
  freeze
end

Instance Method Details

#helper(input, tokens) ⇒ Object



17
18
19
20
21
# File 'lib/farseer/many.rb', line 17

def helper(input, tokens)
  parse(input)
    .bind { |r| helper(r.rest, tokens + r.token) }
    .map_none { Result.new(tokens, input) }
end

#parse(input) ⇒ Object



12
13
14
15
# File 'lib/farseer/many.rb', line 12

def parse(input)
  @parser.parse(input)
         .bind { |r| helper(r.rest, r.token) }
end