package parsley

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type integer_kind =
  1. | Native
  2. | Int32
  3. | Int64
  4. | Int

the different kinds of litteral corresponding to the (Pconst_int) ast node

type base_kind =
  1. | Hexadecimal
  2. | Decimal
  3. | Octal
  4. | Binary

the different kinds of base for litteral numbers

type float_notation =
  1. | Regular of string
  2. | Scientific of string * string

the different kind of notation for floats

exception BadFormat of string

raised when a string does not match the format defined by OCaml's lexer for floats and integer litterals

val bad_prefix : string -> string

error msg utility

val bad_suffix : char -> string

error msg utility

val remove__ : string -> string

Removes all occurences of the character '_'

val categorize_repr : string -> string * integer_kind

Categorizes a non-empty string into an integer_kind. Returns the pair formed by the string where the suffixes (n,l,L) where removed if present, and the corresponding integer_kind

val categorize_base : string -> string * base_kind

categorizes a non-empty string into a base. Returns the pair formed by the string where the prefixes (0o,0x,0b) where removed if present, and the corresponding base

val categorize_notation : string -> base_kind -> float_notation

Given a non-empty string representation of a float, and a base (either hexa or decimal), computes the associated float_notation

val i_of_char : char -> int
val q_of_char : char -> Q.t
val int_of_base : base_kind -> int
val parse_base : int -> string -> Q.t

Computes exactly the rational corresponding to the litteral in the given base. Works for both integers and floats, for all bases

val parse_mant_exp : base_kind -> string -> Q.t

Computes exactly the rational corresponding to the litteral in the given base. Works for both integers and floats, for all bases, and for both scientific and regular notation

val positive_rat_of_string : string -> Q.t

builds the rationnal corresponding to a string following OCaml's lexical conventions : | (0…9) 0…9 ∣ _ | (0x) (0…9∣ A…F∣ a…f) 0…9∣ A…F∣ a…f∣ _ | (0o) (0…7) 0…7∣ _ | (0b) (0…1) 0…1∣ _

val rat_of_string : string -> Q.t

builds the rationnal corresponding to a string following OCaml's lexical conventions : | - (0…9) 0…9 ∣ _ | - (0x) (0…9∣ A…F∣ a…f) 0…9∣ A…F∣ a…f∣ _ | - (0o) (0…7) 0…7∣ _ | - (0b) (0…1) 0…1∣ _

val build_os : (string -> 'a option) -> ('a -> Q.t) -> string -> ('a, 'a option) result

builds an 'of_string' that convert a string representation of a value of a numeric type, to its corresponding value, while indicating if a loss of precision occured during the conversion

val exact_int_of_string : string -> (int, int option) result
val exact_int32_of_string : string -> (int32, int32 option) result
val exact_int64_of_string : string -> (int64, int64 option) result
val exact_native_of_string : string -> (nativeint, nativeint option) result
val exact_float_of_string : string -> (float, float option) result
val exact_string_of_float : float -> string

exactish string_of_float

OCaml

Innovation. Community. Security.