Class: TRuby::ParserCombinator::EndOfInput

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

Overview

Parse end of input

Instance Method Summary collapse

Methods inherited from Parser

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

Instance Method Details

#parse(input, position = 0) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/t_ruby/parser_combinator/primitives/end_of_input.rb', line 7

def parse(input, position = 0)
  if position >= input.length
    ParseResult.success(nil, input, position)
  else
    ParseResult.failure("Expected end of input", input, position)
  end
end