Extfun and the syntax to be loaded is
"pa_extfun.cmo". The empty function is Extfun.empty.
You can extend a function using the statement extfun whose
syntax is:extfun expression with |
[ pattern-1 -> expression-1 |
| pattern-2 -> expression-2 |
| ... |
| pattern-n -> expression-n ] |
pat1 | pat2 -> expr
The binding is split into two cases (the expr is duplicated):
pat1 -> expr
| pat2 -> expr
Internal ``or'' patterns inside patterns are not accepted.extfun returns another extensible function. The
type of extensible functions is ('a, 'b) Extfun.t. To use an
extensible function, one must use the function Extfun.apply
which transforms it in a function of type 'a -> 'b. If matching
failed, such a function raises the exception Extfun.Failure.Extfun.print.Fstream and the syntax to be loaded is
"pa_fstream.cmo". The syntax of a functional stream is:| functional-stream ::= | |
fstream
[: list-of-components-separated-by-semicolon :] |
|
| component ::= | |
` stream-element |
|
| stream |
| functional-parser ::= | |
fparser |
|
[ stream-pattern-1 -> expression-1 |
|
| stream-pattern-2 -> expression-2 |
|
| .. | |
| stream-pattern-n ->
expression-n ] |
|
| stream-pattern ::= | |
[: list-of-components-separated-by-semicolon :] |
|
| component ::= | |
` stream-pattern-element |
|
| pattern = expression |
|
| stream-pattern |
'a Fstream.t and a functional
stream parser of type
'a Fstream.t -> ('a * 'a Fstream.t) option. When a parser
fails, it returns None, otherwise Some of the result and
the remaining stream. The elements in the initial stream are not
removed.None. There is no Error exception causing the parsing to be
abandoned.[: p1 = e1; p2 = e2 :], if e2 fails, the rule is
abandoned: there is no attempt to try the next possible rule inside
e1 (which would suppose continuations).Fstream are like the ones
in Stream. But there is no function ``Fstream.peek'', only
Fstream.next.Fstream.count_frozen returns the number of unfrozen tokens in
the stream, allowing to find the location of the error, providing a
location array have been used (which is normal usage in stream parsing
and grammars). It works if the stream had not been unfrozen before.