View source: R/concatenation.R
concatenation | R Documentation |
Applies to the recognition a parsers sequence. Recognition will succeed as long as all of them succeed.
concatenation(..., action = function(s) list(type="concatenation",value=s), error = function(p,h) list(type="concatenation",pos=p ,h=h))
... |
list of parsers to be executed |
action |
Function to be executed if recognition succeeds. It takes as input parameters information derived from parsers involved as parameters |
error |
Function to be executed if recognition does not succeed. I takes two parameters:
|
In case of success, parameter s
from action
gets a list with information about node
from all parsers processed.
In case of failure, parameter h
from error
gets the value returned by the failing parser.
Anonymous functions, returning a list.
function(stream)
–> list(status,node,stream)
From these input parameters, an anonymous function is constructed. This function admits just one parameter, stream, with streamParser
class, 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
# ok stream <- streamParserFromString("123Hello world") ( concatenation(numberNatural(),symbolic())(stream) )[c("status","node")] # fail stream <- streamParserFromString("123 Hello world") ( concatenation(string(),symbolic())(stream) )[c("status","node")]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.