module Cf_scan_parser:sig
..end
Scanf
scanners.
This module implements and extension to the Cf_parser
module for mixing
calls to the standard library Scanf
functions with functional parsers.
exception No_match
cscanf
function (below) can be signaled
to transform its answer with the effect that the parser stack is unwound
until an alternative production can be matched.class virtual['i]
scanner :'i Cf_seq.t ->
object
..end
cscanf
function (below) for constructing
a scanning buffer from an input sequence.
val cscanf : ('i Cf_seq.t -> ('i #scanner as 's)) ->
('s -> exn -> 'o) ->
('f, Scanf.Scanning.scanbuf, 'u, 'f -> 'o, 'f -> 'o, 'o) format6 ->
'f -> ('i, 'o) Cf_parser.t
cscanf cf ef fmt rf
to
construct a parser that applies cf
to the input sequence to acquire a
scanner object s
, invokes the s#init
method to obtain a scanning buffer
with which to apply Scanf.kscanf
, using the exception function ef
, the
scanning format fmt
and the return continuation rf
. If the exception
function raises No_match
then the resulting parser unwinds to the next
production alternative, otherwise the parser answers with the result of the
return continuation.val scanf : ('f, Scanf.Scanning.scanbuf, 'u, 'f -> 'o, 'f -> 'o, 'o) format6 ->
'f -> (char, 'o) Cf_parser.t
scanf fmt rf
to construct a lexical parser that scans the input text
according to the scanning format fmt
and produces the value returned by
the return continuation. If the scanner raises an exception, then the
parser unwinds to the next production alternative.val scanfx : ('f, Scanf.Scanning.scanbuf, 'u, 'f -> 'o, 'f -> 'o, 'o) format6 ->
'f -> (char #Cf_parser.cursor, char, 'o) Cf_parser.X.t
scanfx
in place of scanf
to construct a parser with a cursor weaved
into the input stream.