Learn R Programming

qmrparser (version 0.1.6)

eofMark: End of file token

Description

Recognises the end of input flux as a token.

When applied, it does not make use of character and, therefore, end of input can be recognised several times.

Usage

eofMark(action = function(s) list(type="eofMark",value=s), 
          error  = function(p) list(type="eofMark",pos  =p ) )

Arguments

action

Function to be executed if recognition succeeds. Character stream making up the token is passed as parameter to this function

error

Function to be executed if recognition does not succeed. Position of streamParser obtained with streamParserPosition is passed as parameter to this function

Value

Anonymous function, returning a list.

function(stream) --> list(status,node,stream)

From input parameters, an anonymous function is defined. This function admits just one parameter, stream, with type streamParser, and returns a three-field list:

  • status "ok" or "fail"

  • node With action or error function output, depending on the case

  • stream With information about the input, after success or failure in recognition

Details

When succeeds, parameter s takes the value "".

Examples

Run this code
# NOT RUN {
# fail
stream  <- streamParserFromString("Hello world")
( eofMark()(stream) )[c("status","node")]

# ok 
stream  <- streamParserFromString("")
( eofMark()(stream) )[c("status","node")]

# }

Run the code above in your browser using DataLab