empty {qmrparser} | R Documentation |
Empty token
Description
Recognises a null token. This parser always succeeds.
Usage
empty(action = function(s) list(type="empty",value=s),
error = function(p) list(type="empty",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 |
Details
action
s
parameter is always "".
Error parameters exists for the sake of homogeneity with the rest of functions. It is not used.
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
orerror
function output, depending on the casestream
With information about the input, after success or failure in recognition
Examples
# ok
stream <- streamParserFromString("Hello world")
( empty()(stream) )[c("status","node")]
# ok
stream <- streamParserFromString("")
( empty()(stream) )[c("status","node")]