Skip to content
This repository
tag: v45
Fetching contributors…

Cannot retrieve contributors at this time

file 79 lines (59 sloc) 2.284 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
(*
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/>.
*)

(**
Abstraction on backend languages : "ml" / "c" / "js"

@author Mathieu Barbin
@author Mehdi Bouaziz
*)

(** The extension corresponding to the language *)
type ext = string

(** The abstract type of a back-end language *)
type t
type format = [ `compiled | `interpreted ]
val compare : t -> t -> int

(** building a value of type [Language.t]. If the string is not recognized, the function returns [None] *)
val of_string : ?format:format -> string -> t option
val to_string : t -> string
val pp : t LangPrint.pprinter
val pp_list : t list LangPrint.pprinter

(** if you don't want to do a map + verification of unicity *)
val of_list : string list -> t list option

(** Get a list of language from a string. use the syntax : ["{ml, js, c}"] *)
val parse : string -> t list option

(** Get a printable representation of a list of languages. e.g. "[{ml, js, c}]" *)
val print : t list -> string

(** Force the format of a language.*)
val formate : format -> t -> t

(** {6 Compiled}*)

val ml : t (** Traditional ocaml code *)
val js : t (** JavaScript code, for use on the client (technically interpreted, but not by us) *)
val c : t (** C code, for use with e.g. LLVM *)

(** {6 Sugar} *)

val is_ml : t -> bool
val is_js : t -> bool
val is_c : t -> bool

(**{6 Interpreted}*)

val mli : t (** Traditional ocaml code, to be used in an interpreter (opatop) *)

(** {6 Code generation} *)
(**
In the generated plugins and loaders, there are reference to languages.
{[
L.ml, L.mli, L.js, etc...
]}
The generated code should contains
{[
module L = BslLanguag
]}
*)
val pp_meta : t LangPrint.pprinter
Something went wrong with that request. Please try again.