package orsetto

  1. Overview
  2. Docs
A library of assorted structured data interchange languages

Install

Dune Dependency

Authors

Maintainers

Sources

r1.1.1.tar.gz
sha256=81283687ce3204263bc955a332dd7b90bf5b648a990c01160f33aaa77d80962f
md5=7346293aa013c2a8974c6fb7c521166a

doc/orsetto.json/Json_scan/Chain/index.html

Module Json_scan.Chain

The chain scanner module.

type chain = private
  1. | Chain : {
    1. separator : unit t;
    2. header : Cf_chain_scan.ctrl;
    3. trailer : Cf_chain_scan.ctrl;
    4. fail : (mark -> 'x) option;
    } -> chain

The type of a chain discipline.

val mk : ?xf:(mark -> 'x) -> ?a:[< Cf_chain_scan.ctrl ] -> ?b:[< Cf_chain_scan.ctrl ] -> 'r t -> chain

Use mk separator to make a chain discipline with separator to scan for delimiters. Use ~a and/or ~b to control how leading/trailing delimiters are processed (respectively). For example, use ~b:`Opt to specify that a trailing delimiter is optionally permitted.

val sep : ?xf:(mark -> 'x) -> [< Cf_chain_scan.ctrl ] -> 'r -> 'r t -> 'r t

Use sep c r p to make a parser for separator p with optionality control c.

If c is `Non then no input is consumed and r is returned.

If c is `Opt then returns either the value recognized by p, or r if no value is recognized.

If c is `Req then acts as reqf ?xf p.

val sep0 : ?xf:(mark -> 'x) -> [< Cf_chain_scan.ctrl ] -> unit t -> bool t

Use sep0 c p to make a parser for separator p with optionality control c, in the case that p returns the unit type.

If c is `Non then no input is consumed and false is returned.

If c is `Opt then returns a boolean value indicating whether p recognized a separator.

If c is `Req then acts as reqf ?xf p >>= fun () -> return true.

val vis : c:chain -> ?a:int -> ?b:int -> ('r -> 'r t) -> 'r -> 'r t

Use vis ~c ?a ?b f v to compose a parser that recognizes a sequence of symbols in the input stream, delimited according to the chain discipline ~c, by applying a visitor function f at each sequence point to obtain its parser. The first sequence point is visited with the initializer v.

If ~a is used, then it specifies the minimum number of elements in the sequence. If ~b is used then it specifies the maximum number of elements in the sequence. Composition raises Invalid_argument if a < 0 or b < a.

val seq : c:chain -> ?a:int -> ?b:int -> 'r t -> 'r list t

Use seq ?a ?b p to create a new parser that recognizes a sequence of symbols in the input stream with p, delimited according to the chain discipline ~c.

If ~a is used, then it specifies the minimum number of elements in the sequence. If ~b is used then it specifies the maximum number of elements in the sequence. Composition raises Invalid_argument if a < 0 or b < a.

OCaml

Innovation. Community. Security.