Skip to content
This repository
tag: v1841
Fetching contributors…

Cannot retrieve contributors at this time

file 82 lines (58 sloc) 2.386 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(**
Keys for manipulating bypass in the bsl.

Since the apparition of the bsl, we use keys instead of row code for bypassing qml compilers by adding some primitives
form target languages (ocaml, js, llvm). Primitives need to be registred using the application {b bslregister},
which produces some plugins containing the definition of bypass, indexed by their {b keys}.

@author Mathieu Barbin
@author Mehdi Bouaziz
*)

(** {6 Guidelines} *)

(**
Whenever you use a value of type [BslKey.t] in your code,
you should use [key] or [bslkey] as variable identifier.

When you are manipulating a key after a [to_string] manipulation,
you should use [skey] as variable identifier.

{[
match expr with
| Bypass key ->
let skey = BslKey.to_string key in
.....
]}

*)

(** {6 Standard utilisation} *)

(** The abstract type of bsl keys.*)
type t

(** comparing 2 keys. returned value as usual compare functions *)
val compare : t -> t -> int

(** Convert a key to a printable representation *)
external to_string : t -> string = "%identity"

val pp : t LangPrint.pprinter

(** Normalization of key in the Bsl : lowercase, and replace . with '_' *)
val normalize : string -> t
val normalize_string : string -> string

(** {6 Internal utilisation} *)
(**
Not for casual users.

Since every bypass is normalized, if you transform directly
a string into a key, you may not found a bypass because
the unnormalized string does not correspond to the normalized one.

Essentially, this function is used whenever you know that the
string has already be normalized.
*)
external of_string : string -> t = "%identity"

(** {6 Hash} *)

val equal : t -> t -> bool

val hash : t -> int
Something went wrong with that request. Please try again.