package orsetto

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parser combinators for numeric types.

Overview

This module implements functional combinators for parsing common numeric types in typical textual presentations.

Types and Constants

In this section various utility types are defined for use in specializing the general number scanning engine.

type radix = private
  1. | Radix of int

The type of available radixes.

type digit =
  1. | Digit of int

The type of a scanned digit value

val binary : radix

The binary (base 2) radix.

val octal : radix

The octal (base 8) radix.

val decimal : radix

The decimal (base 10) radix.

val hexadecimal : radix

The hexadecimal (base 16) radix.

type iopt

The type qualifier for integer scanning options.

type fopt

The type qualifier for floating point scanning options.

type _ opt =
  1. | O_radix : radix -> iopt opt
  2. | O_leading : iopt opt
  3. | O_signed : iopt opt
  4. | O_width : int -> 'a opt
  5. | O_scientific : fopt opt

The generalized algebraic data type (GADT) representing scanning options qualified by option type.

type (_, _) ret =
  1. | R_int : (int, iopt) ret
  2. | R_int32 : (int32, iopt) ret
  3. | R_int64 : (int64, iopt) ret
  4. | R_native : (nativeint, iopt) ret
  5. | R_float : (float, fopt) ret

The generalized algebraic data type (GADT) representing return value types qualified by option type.

type 'r ctrl

The abstract type representing scanner controllers comprising a return type and the option qualifiers.

val ctrl : ?opt:'x opt list -> ('r, 'x) ret -> 'r ctrl

Use ctrl ?opt ret to make a scanner control that for the return type represented by ret. If ~opt is used then it specifies a list of options for scanning the input stream accordingly.

Functor
module type Basis = sig ... end

Define a module of this type to specialize the number scanner for specific underlying symbol types.

module type Profile = sig ... end

The signature of a general number scanner module.

module Create (B : Basis) : Profile with type 'a t := 'a B.Scan.t and type 'a form := 'a B.form

Use Create(B) to specialize the number scanner according to B.

module ASCII : Profile with type 'a t := 'a Cf_scan.ASCII.t and type 'a form := 'a

A distinguished number scanner for simple ASCII character symbols.