module Op: sig
.. end
Open this module to take the parser operators into the current scope.
val (>>=) : ('i, 'a) Cf_parser.t -> ('a -> ('i, 'b) Cf_parser.t) -> ('i, 'b) Cf_parser.t
The binding operator. Use p >>= f
to compose a parser that passes
output of parser p
to the bound function f
which returns the parser
for the next symbol in a parsing rule.
val (~:) : 'o -> ('i, 'o) Cf_parser.t
The return operator. Use ~:obj
to create a parser that produces the
value obj
as its result without processing any more input.
val ? : 'i -> ('i, 'i) Cf_parser.t
The unit operator. Use ?.token
to create a parser that recognizes
token
at the head of the input stream and produces it as its output.
val ?: : 'i -> ('a #Cf_parser.cursor, 'i, 'i) Cf_parser.X.t
The unit operator with a cursor. Use ?:token
to create a parser that
recognizes token
at the head of a position attributed input stream
and produces it as its output.
val ?/ : ('i, 'o) Cf_parser.t -> ('i, 'o option) Cf_parser.t
The option operator. Use ?/p
to create a parser that recognizes an
optional symbol in the input stream with the parser p
. If the symbol
is recognized, its tokens are shifted and reduced as Some obj
,
otherwise no tokens are shifted and the reduced value is None
.
Parser functions created with this operator always return Some r
,
where r
is the reduced value, i.e. either Some obj
or None
.
val ( ?* ) : ('i, 'o) Cf_parser.t -> ('i, 'o list) Cf_parser.t
The zero-or-more operator. Use ?*p
to create a parser that
recognizes zero or more symbols in the input stream with the parser
p
. The tokens of all the symbols recognized are shifted and reduced
as a list of objects in the order of their appearance in the input
stream. Parser functions created with this operator always return
Some r
, where r
is the reduced list of symbols, which may be the
empty list if there are no symbols recognized.
val ?+ : ('i, 'o) Cf_parser.t -> ('i, 'o * 'o list) Cf_parser.t
The one-or-more operator. Use ?+p
to create a parser that recognizes
one or more symbols in the input stream with the parser p
. If the
symbols are recognized in the input stream, then their tokens are
shifted and reduced into a list of objects in the order of their
appearance in the input stream. Otherwise, no tokens are shifted and
no output is reduced.
val (%=) : ('b #Cf_parser.cursor as 'a, 'i, 'x) Cf_parser.X.t ->
('a, 'x, 'o) Cf_parser.X.t -> ('a, 'i, 'o) Cf_parser.X.t
The serial composition operator. Use
p1 %= p2
to unfold the output
token stream of parser
p1
and use it as the input token stream for
parser
p2
. This is useful in the case that
p1
is a lexical
analyzer created with the
Cf_lex
module, and
p2
is a grammar that
operates at the level of lexical tokens output by
p1
.