Class: DParse::Parsers::EOF

Inherits:
DParse::Parser show all
Defined in:
lib/d-parse/parsers/primitives/eof.rb

Instance Method Summary collapse

Methods inherited from DParse::Parser

#apply, #bind, #capture, #compact, #first, #flatten, #ignore, #map, #match?, #second, #select_even, #select_odd, #to_s

Instance Method Details

#expectation_messageObject



16
17
18
# File 'lib/d-parse/parsers/primitives/eof.rb', line 16

def expectation_message
  'end of input'
end

#inspectObject



12
13
14
# File 'lib/d-parse/parsers/primitives/eof.rb', line 12

def inspect
  'eof()'
end

#read(input, pos) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/d-parse/parsers/primitives/eof.rb', line 4

def read(input, pos)
  if input.size == pos.index
    Success.new(input, pos)
  else
    Failure.new(input, pos, origin: self)
  end
end