# Module Cf_scan_parser

    module Cf_scan_parser: sig .. end

Lexical analysis with functional composition using `Scanf` scanners.

###### Overview

This module implements and extension to the `Cf_parser` module for mixing calls to the standard library `Scanf` functions with functional parsers.

###### Classes and Types

    exception No_match

An exception provided so that the `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

A virtual base class used in the `cscanf` function (below) for constructing a scanning buffer from an input sequence.

###### Functions

    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

This is the primitive function in the module. Use `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

Use `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

Use `scanfx` in place of `scanf` to construct a parser with a cursor weaved into the input stream.