FParsec-Pipes reference
Default Parsers
%
The default parser for a given value is %value
.
This is implicitly used by several other FParsec-Pipes operators.
For the rest of this document, the phrase "parserish value" will refer to a value that
either is a parser or can be converted to one using %
.
Here is the list of what %
means based on the type given to it.
Note that when given a list of values, %
applies itself to each value in the list then passes the result to choice
.
Type |
Expression |
Parser Type |
Equivalent Function |
---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Pipes
pipe
pipe
begins a pipeline. This is not useful on its own.
%%
%% parserish
begins a pipeline with a parserish value.
It is equivalent to pipe -- parserish
.
--
myPipe -- parserish
adds a parserish value to a pipeline.
?-
myPipe ?- parserish
adds a parserish value to a pipeline, backtracking the entire pipeline if
anything within myPipe
fails.
-?
myPipe -? parserish
adds a parserish value to a pipeline, backtracking the entire piplime
if myPipe
fails or if parserish
and following values in the pipeline fail without consuming input.
+.
+. parserish
marks a parserish value as captured.
If added to a pipeline, this captured value will need to be consumed by the function passed to -|>
.
-|>
myPipe -|> myFunction
terminates a pipeline with a function consuming the captured outputs of the pipeline.
If the pipeline has no outputs (no captured values), then myFunction
can be of any type, and will be returned
on a successful parse (as if used with preturn
).
-%> auto
myPipe -%> auto
terminates a pipeline which has 1 to 5 captured outputs with a function combining them
into a tuple of the appropriate arity.
Repetition
qty
qty
is an object which can be indexed or sliced into to get a Range
.
qty.[min..max]
qty.[min..max]
indicates that the associated parser should be consumed at least min
and at most max
times.
qty.[..max]
qty.[..max]
indicates that the associated parser should be consumed at least 0 and at most max
times.
qty.[min..]
qty.[min..]
indicates that the associated parser should be consumed at least min
times.
qty.[n]
qty.[n]
indicates that the associated parser should be consumed exactly n
times.
The resulting parser will return an array, not a ResizeArray
.
Range * parserish
range * parserish
consumes parserish
range
times and returns the result as a ResizeArray.
parserish * Range
parserish * range
is equivalent to range * parserish
.
Range / parserish
range / parserish
indicates that the parser that will be consumed range
times should be separated by parserish
.
Range /. parserish
range / parserish
indicates that the parser that will be consumed range
times should be separated by parserish
,
and that a trailing parserish
may occur at the end of the list.