Commit 553d9454 authored by POTTIER Francois's avatar POTTIER Francois

More rational definition of [IL.structure] as a list of structure items.

parent ec1abfe9
......@@ -276,19 +276,16 @@ and modexpr =
| MStruct of structure
| MApp of modexpr * modexpr
(* Structures. This is somewhat redundant with the structure of programs,
but will do for now. *)
(* Structures. *)
and structure = {
and structure =
structure_item list
(* Exception definitions. *)
struct_excdefs: excdef list;
(* Algebraic data type definitions (mutually recursive). *)
struct_typedefs: typedef list;
(* Value definitions (not mutually recursive). *)
struct_nonrecvaldefs: valdef list;
}
and structure_item =
(* Exception definitions. *)
| SIExcDefs of excdef list
(* Algebraic data type definitions (mutually recursive). *)
| SITypeDefs of typedef list
(* Value definitions (not mutually recursive). *)
| SINonRecValDefs of valdef list
......@@ -620,22 +620,28 @@ let functorparams intf body b f params =
(indent 2 body) b
nl nl nl
let structure f p =
fprintf f "struct%aend" (
indent 2 (fun f p ->
fprintf f "%t%a%a%a"
nl
(excdefs false) p.struct_excdefs
typedefs p.struct_typedefs
nonrecvaldefs p.struct_nonrecvaldefs
)
) p
let structure_item f = function
| SIExcDefs defs ->
excdefs false f defs
| SITypeDefs defs ->
typedefs f defs
| SINonRecValDefs defs ->
nonrecvaldefs f defs
let structure f s =
list structure_item nothing f s
let rec modexpr f = function
| MVar x ->
fprintf f "%s" x
| MStruct s ->
structure f s
fprintf f "struct%aend" (
indent 2 (fun f s ->
fprintf f "%t%a"
nl
structure s
)
) s
| MApp (e1, e2) ->
fprintf f "%a (%a)" modexpr e1 modexpr e2
......
......@@ -666,14 +666,10 @@ let application = {
modulerhs =
MApp (
MVar make,
MStruct {
struct_excdefs = [
excredef;
];
struct_typedefs = [
tokendef2;
];
struct_nonrecvaldefs = [
MStruct [
SIExcDefs [ excredef ];
SITypeDefs [ tokendef2 ];
SINonRecValDefs [
token2terminal;
define ("error_terminal", EIntConst (Terminal.t2i Terminal.error));
token2value;
......@@ -684,8 +680,8 @@ let application = {
goto;
semantic_action;
trace;
];
}
]
]
);
}
......
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