Commit 11f1064a authored by POTTIER Francois's avatar POTTIER Francois

Updated IL to allow more flexible ordering of interface items.

parent f60e0c73
* Include comments in the generated .mli file (Interface)
* Document the incremental interface
* Confirm and understand why the code back-end slows down by 50%
......
......@@ -34,21 +34,18 @@ type program = {
}
and interface = {
(* Functor parameters. *)
paramdecls: Stretch.t list;
(* Exception definitions. *)
excdecls: excdef list;
and interface =
interface_item list
and interface_item =
(* Functor. Called [Make]. No functor if no parameters. Very ad hoc! *)
| IIFunctor of Stretch.t list * interface
(* Exception declarations. *)
| IIExcDecls of excdef list
(* Algebraic data type declarations (mutually recursive). *)
typedecls: typedef list;
| IITypeDecls of typedef list
(* Value declarations. *)
valdecls: (string * typescheme) list
}
| IIValDecls of (string * typescheme) list
and excdef = {
......
......@@ -35,23 +35,17 @@ let entrytypescheme symbol =
(* This is the interface of the generated parser. *)
let interface = {
paramdecls =
PreFront.grammar.parameters;
excdecls =
[ excdef ];
typedecls =
tokentypedef;
valdecls =
StringSet.fold (fun symbol decls ->
(Misc.normalize symbol, entrytypescheme symbol) :: decls
) PreFront.grammar.start_symbols []
}
let interface = [
IIFunctor (PreFront.grammar.parameters, [
IIExcDecls [ excdef ];
IITypeDecls tokentypedef;
IIValDecls (
StringSet.fold (fun symbol decls ->
(Misc.normalize symbol, entrytypescheme symbol) :: decls
) PreFront.grammar.start_symbols []
)
])
]
(* Writing the interface to a file. *)
......
......@@ -645,14 +645,24 @@ let program f p =
let valdecl f (x, ts) =
fprintf f "val %s: %a" x typ ts.body
let interface f i =
fprintf f "%a%a%a%!" (excdefs true) i.excdecls typedefs i.typedecls (list valdecl nl) i.valdecls
let rec interface_item f = function
| IIFunctor (params, i) ->
functorparams true interface i f params
| IIExcDecls defs ->
excdefs true f defs
| IITypeDecls defs ->
typedefs f defs
| IIValDecls decls ->
list valdecl nl f decls
and interface f i =
list interface_item nothing f i
let program p =
functorparams false program p X.f p.paramdefs
let interface i =
functorparams true interface i X.f i.paramdecls
interface X.f i
let expr e =
expr X.f e
......
......@@ -67,12 +67,11 @@ let tokentypedef, tokenprefix =
let locate_stretches = None
end)
in
P.interface {
paramdecls = PreFront.grammar.parameters;
excdecls = [];
typedecls = [ tokentypedef ];
valdecls = []
};
P.interface [
IIFunctor (PreFront.grammar.parameters, [
IITypeDecls [ tokentypedef ]
])
];
let module P =
Printer.Make (struct
let f = open_out (Settings.base ^ ".ml")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment