commentParser {qmrparser} | R Documentation |
Comment token.
Description
Recognises a comment, a piece of text delimited by two predefined tokens.
Usage
commentParser(beginComment,endComment,
action = function(s) list(type="commentParser",value=s),
error = function(p) list(type="commentParser",pos =p))
Arguments
beginComment |
String indicating comment beginning |
endComment |
String indicating comment end |
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
Characters preceded by \ are not considered as part of beginning of comment end.
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
# fail
stream <- streamParserFromString("123")
( commentParser("(*","*)")(stream) )[c("status","node")]
# ok
stream <- streamParserFromString("(*123*)")
( commentParser("(*","*)")(stream) )[c("status","node")]