tokenType.mli 2.32 KB
Newer Older
1 2
(* This module deals with the definitions of the type(s) that describe
   the tokens and the terminal symbols. *)
3

4 5 6 7
(* By default, following [ocamlyacc], we produce just one type, [token],
   which describes the tokens. A token contains a tag (a terminal symbol)
   and possibly a semantic value. *)

8 9 10
(* In addition to that, in [--inspection] mode only, we produce a GADT which
   describes the terminal symbols. A terminal symbol is just a tag; it does
   not carry a semantic value. *)
11 12 13 14 15 16 17

(* In this module, we also deal with [--only-tokens] and [--external-tokens].
   If [--only-tokens] is specified on the command line, [produce_tokentypes]
   emits the type definition(s) and exit. If [--external-tokens] is specified,
   then the list [tokentypedefs] is empty, and [tokenprefix] produces a
   nontrivial prefix. *)

18
(* The conventional name of the [token] type, for use by the code
19
   generators. If [--external-tokens] is set, this type is qualified. *)
20 21 22

val ttoken: IL.typ

23 24 25 26 27 28
(* [tokendata] maps the name of a token to a data constructor of the [token]
   type. (If [--external-tokens] is set, then it prefixes its argument with an
   appropriate OCaml module name. Otherwise, it is the identity.) *)

val tokendata: string -> string

29 30 31 32
(* The conventional name of the [terminal] type, a.k.a. the token GADT. This
   is an indexed type (i.e., it has one type parameter). Its data constructors
   carry zero value arguments. If [--external-tokens] is set, this type is
   qualified. *)
33

34
val tctokengadt: string
35
val ttokengadt: IL.typ -> IL.typ
36

POTTIER Francois's avatar
POTTIER Francois committed
37 38 39 40 41
(* [tokengadtdata] maps the name of a token to a data constructor of the token
   GADT. *)

val tokengadtdata: string -> string

42 43 44
(* The definitions of the token type and of the token GADT, for use by the
   code generators. Each of these lists may define zero or one type. Indeed,
   both lists are empty when [--external-tokens] is set. Otherwise, only the
45 46
   type [token] is defined always, and the type [terminal] is defined only in
   [--inspection] mode. *)
47

48 49
val tokentypedef: UnparameterizedSyntax.grammar -> IL.interface
val tokengadtdef: UnparameterizedSyntax.grammar -> IL.interface
50

51 52 53
(* If [--only-tokens] is set, then [produce_tokentypes] writes the type
   definitions to the [.ml] and [.mli] files and stops Menhir. Otherwise,
   it does nothing. *)
54

55
val produce_tokentypes: UnparameterizedSyntax.grammar -> unit
56