
Last chance! 50% off unlimited learning
Sale ends in
Any character sequence, by default using simple or double quotation marks.
string(isQuote= function(c) switch(c,'"'=,"'"=TRUE,FALSE),
action = function(s) list(type="string",value=s),
error = function(p) list(type="string",pos =p))
Predicate indicating whether a character begins and ends a string
Function to be executed if recognition succeeds. Character stream making up the token is passed as parameter to this function
Function to be executed if recognition does not succeed. Position of streamParser
obtained with streamParserPosition
is passed as parameter to this function
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
Characters preceded by \ are not considered as part of string end.
# NOT RUN {
# fail
stream <- streamParserFromString("Hello world")
( string()(stream) )[c("status","node")]
# ok
stream <- streamParserFromString("'Hello world'")
( string()(stream) )[c("status","node")]
# }
Run the code above in your browser using DataLab