package containers

  1. Overview
  2. Docs
On This Page
  1. Utils
Legend:
Library
Module
Module type
Parameter
Class
Class type

Utils

This is useful to parse OCaml-like values in a simple way. All the parsers are whitespace-insensitive (they skip whitespace).

val list : ?start:string -> ?stop:string -> ?sep:string -> 'a t -> 'a list t

list p parses a list of p, with the OCaml conventions for start token "[", stop token "]" and separator ";". Whitespace between items are skipped.

val int : int t

Parse an int in decimal representation.

val in_paren : 'a t -> 'a t

in_paren p parses an opening "(",p , and then ")".

  • since 3.6
val in_parens_opt : 'a t -> 'a t

in_parens_opt p parses p in an arbitrary number of nested parenthesis (possibly 0).

  • since 3.6
val option : 'a t -> 'a option t

option p parses "Some <x>" into Some x if p parses "<x>" into x, and parses "None" into None.

  • since 3.6
val hexa_int : int t

Parse an int int hexadecimal format. Accepts an optional 0x prefix, and ignores capitalization.

  • since 3.6
val word : string t

Non empty string of alpha num, start with alpha.

val bool : bool t

Accepts "true" or "false"

  • since 3.6
val pair : ?start:string -> ?stop:string -> ?sep:string -> 'a t -> 'b t -> ('a * 'b) t

Parse a pair using OCaml syntactic conventions. The default is "(a, b)".

val triple : ?start:string -> ?stop:string -> ?sep:string -> 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t

Parse a triple using OCaml syntactic conventions. The default is "(a, b, c)".

OCaml

Innovation. Community. Security.