Module Cf_parser.X

module X: sig .. end
A module of parser extensions for working with input sequences that require position information in the parse function.

type ('x #Cf_parser.cursor, 'i, 'o) t = ('i * ('x #Cf_parser.cursor as 'a)) Cf_seq.t ->
('o * ('i * 'a) Cf_seq.t) option
A parser where every token in the input sequence is accompanied by a Cf_parser.cursor class object.
exception Error of int
Generic parser error with one positional parameter.
val err : ?f:(('i * ('b #Cf_parser.cursor as 'a)) Cf_seq.t -> exn) ->
unit -> ('a, 'i, 'o) t
Use err ?f () to compose parser that applies the input token stream to the optional function f to obtain an Objective Caml exception, then raises the exception. The default function simply raises Error.
val req : ?f:(('i * ('b #Cf_parser.cursor as 'a)) Cf_seq.t -> exn) ->
('a, 'i, 'o) t -> ('a, 'i, 'o) t
Use req ?f p to create a parser that requires the input stream to match the parser p or it will be passed to the parser err ?f () instead.
val sat : ('i -> bool) -> ('a #Cf_parser.cursor, 'i, 'i) t
Use sat f to create a parser that recognizes, shifts and reduces input tokens for which the satisfier function f returns true.
val tok : ('i -> 'o option) -> ('a #Cf_parser.cursor, 'i, 'o) t
Use tok f to recognize and shift input tokens for which the tokenizer function f reduces an output value.
val lit : string -> 'o -> ('a #Cf_parser.cursor, char, 'o) t
Use lit s obj to obtain a parser on character input sequences that produces the output obj when it recognizes the literal s in the input.
val weave : c:('i #Cf_parser.cursor as 'c) -> 'i Cf_seq.t -> ('i * 'c) Cf_seq.t
Use weave ~c i with an initial cursor c and an input sequence i to create an input sequence with accompanying cursor.
val unfold : ('b #Cf_parser.cursor as 'a, 'i, 'o) t ->
('i * 'a) Cf_seq.t -> ('o * 'a) Cf_seq.t
Use unfold p i to create a sequence of output values recognized by applying the input token sequence i to the parser p until no more input is recognized. The cursor objects in the output sequence elements correspond to the positions of the input sequence at the start of where the output was recognized.