Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

codeBits.mli 3.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
(******************************************************************************)
(*                                                                            *)
(*                                   Menhir                                   *)
(*                                                                            *)
(*                       François Pottier, Inria Paris                        *)
(*              Yann Régis-Gianas, PPS, Université Paris Diderot              *)
(*                                                                            *)
(*  Copyright Inria. All rights reserved. This file is distributed under the  *)
(*  terms of the GNU General Public License version 2, as described in the    *)
(*  file LICENSE.                                                             *)
(*                                                                            *)
(******************************************************************************)

14 15 16 17 18
(* This module provides a number of tiny functions that help produce
   [IL] code. *)

open IL

19 20
(* A list subject to a condition. (Be careful, though: the list is
   of course constructed even if the condition is false.) *)
21 22 23 24

val listif: bool -> 'a list -> 'a list
val elementif: bool -> 'a -> 'a list

25 26 27 28 29
(* A lazy version of [listif], where the list is constructed only
   if the condition is true. *)

val listiflazy: bool -> (unit -> 'a list) -> 'a list

30 31 32
(* Standard types. *)

val tunit: typ
33
val tbool: typ
34 35 36 37
val tint: typ
val tstring: typ
val texn: typ
val tposition: typ
Frédéric Bour's avatar
Frédéric Bour committed
38 39
val default_tlocation: typ
val tlocation: public:bool -> UnparameterizedSyntax.grammar -> typ
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
val tlexbuf: typ
val tobj : typ

(* Building a type variable. *)

val tvar: string -> typ

(* Building a type scheme. *)

val scheme: string list -> typ -> typescheme
val type2scheme: typ -> typescheme

(* Projecting out of a [PVar] pattern. *)

val pat2var: pattern -> string

(* Building a [let] construct, with on-the-fly simplification. *)

val blet: (pattern * expr) list * expr -> expr
val mlet: pattern list -> expr list -> expr -> expr

POTTIER Francois's avatar
POTTIER Francois committed
61 62 63 64
(* Simulating a [let/and] construct. *)

val eletand: (pattern * expr) list * expr -> expr

65 66 67 68
(* [eraisenotfound] is an expression that raises [Not_found]. *)

val eraisenotfound: expr

69 70 71 72 73 74 75 76 77 78 79
(* [bottom] is an expression that has every type. Its semantics is
   irrelevant. *)

val bottom: expr

(* Boolean constants. *)

val etrue: expr
val efalse: expr
val eboolconst: bool -> expr

80 81 82 83 84 85 86 87 88
(* Option constructors. *)

val enone: expr
val esome: expr -> expr

(* List constructors. *)

val elist: expr list -> expr

POTTIER Francois's avatar
POTTIER Francois committed
89 90 91 92
(* Integer constants as patterns. *)

val pint: int -> pattern

93 94 95 96 97 98 99 100 101 102
(* These help build function types. *)

val arrow: typ -> typ -> typ
val arrowif: bool -> typ -> typ -> typ
val marrow: typ list -> typ -> typ

(* These functions are used to generate names in menhir's namespace. *)
val prefix: string -> string
val dataprefix: string -> string
val tvprefix: string -> string
103

104 105 106
(* Converting an interface to a structure. Only exception and type definitions
   go through. *)
val interface_to_structure: interface -> structure
107

108 109
(* Constructing a named module type together with a list of "with type"
   constraints. *)
110
val with_types: IL.with_kind -> string -> (string list * string * IL.typ) list -> IL.module_type
111 112 113

(* Functor applications. *)
val mapp: IL.modexpr -> IL.modexpr list -> IL.modexpr