Class: TRuby::ParserCombinator::Map

Inherits:
Parser
  • Object
show all
Defined in:
lib/t_ruby/parser_combinator.rb

Overview

Map result

Instance Method Summary collapse

Methods inherited from Parser

#<<, #>>, #between, #flat_map, #label, #lookahead, #many, #many1, #map, #not_followed_by, #optional, #sep_by, #sep_by1, #|

Constructor Details

#initialize(parser, func) ⇒ Map

Returns a new instance of Map.



264
265
266
267
# File 'lib/t_ruby/parser_combinator.rb', line 264

def initialize(parser, func)
  @parser = parser
  @func = func
end

Instance Method Details

#parse(input, position = 0) ⇒ Object



269
270
271
# File 'lib/t_ruby/parser_combinator.rb', line 269

def parse(input, position = 0)
  @parser.parse(input, position).map(&@func)
end