eof {parcr}R Documentation

Detect end of input

Description

Tests whether the end of the input character vector has been reached, which boils down to detection of character(0) in the R-element (see succeed()). Since the intended application of this parser is parsing of text files the function has been called after the end of file (EOF) signal. To indicate that an end of file has been detected, the R-element side of the parser output will be converted to an empty list.

Usage

eof()

Value

A parser.

Pseudocode

eof()(x):
  if x==null then succeed(x)(list())
  else fail()(x)

Examples

(literal("a") %then% eof())("a") # success
# Notice the difference on the R-side with
literal("a")("a")
eof()(character(0)) # success
eof()("a") # failure


[Package parcr version 0.5.2 Index]