package pyre-ast

  1. Overview
  2. Docs

This module provides a type that represents Python constant value.

type 'a t = private {
  1. none : 'a;
    (*

    Represents the value None.

    *)
  2. false_ : 'a;
    (*

    Represents the value False.

    *)
  3. true_ : 'a;
    (*

    Represents the value True.

    *)
  4. ellipsis : 'a;
    (*

    Represents the value ....

    *)
  5. integer : int -> 'a;
    (*

    Represents integer literals whose value can be represented by OCaml int type (e.g. 42).

    *)
  6. big_integer : string -> 'a;
    (*

    Represents integer literals whose value cannot be represented by OCaml int type. The integer will be stored as a string instead.

    *)
  7. float_ : float -> 'a;
    (*

    Represents Python float literals (e.g. 4.2).

    *)
  8. complex : float -> 'a;
    (*

    Represents Python complex literals (e.g. 4.2j). The float argument is the imaginary part of the complex number.

    The reason why we do not need to keep track of the real part is that in Python, complex numbers with non-zero real part are represented as compound expressions (e.g. 1+2j will be parsed as a binary expression that adds up constant 1 and 2j) as opposed to literals

    *)
  9. string_ : string -> 'a;
    (*

    Represents Python string literals (e.g. "derp").

    Unlike non-ascii identifiers, non-ascii string literals can be parsed properly by this library. That also means it has no trouble handling strings with embedded null bytes.

    *)
  10. byte_string : string -> 'a;
    (*

    Represents Python string literals (e.g. b"derp").

    Unlike non-ascii identifiers, non-ascii bytestring literals can be parsed properly by this library. That also means it has no trouble handling strings with embedded null bytes.

    *)
}
val make : none:'a -> false_:'a -> true_:'a -> ellipsis:'a -> integer:(int -> 'a) -> big_integer:(string -> 'a) -> float_:(float -> 'a) -> complex:(float -> 'a) -> string_:(string -> 'a) -> byte_string:(string -> 'a) -> unit -> 'a t

Constructor of t.

OCaml

Innovation. Community. Security.