Class: TRuby::ParserCombinator::NotFollowedBy

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

Overview

Not followed by

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) ⇒ NotFollowedBy

Returns a new instance of NotFollowedBy.



470
471
472
# File 'lib/t_ruby/parser_combinator.rb', line 470

def initialize(parser)
  @parser = parser
end

Instance Method Details

#parse(input, position = 0) ⇒ Object



474
475
476
477
478
479
480
481
# File 'lib/t_ruby/parser_combinator.rb', line 474

def parse(input, position = 0)
  result = @parser.parse(input, position)
  if result.failure?
    ParseResult.success(nil, input, position)
  else
    ParseResult.failure("Unexpected match", input, position)
  end
end