Commit db42fd1c authored by POTTIER Francois's avatar POTTIER Francois

More kinds of structure items.

parent cf91bf03
...@@ -282,12 +282,14 @@ and structure = ...@@ -282,12 +282,14 @@ and structure =
structure_item list structure_item list
and structure_item = and structure_item =
(* Functor. Called [Make]. No functor if no parameters. Very ad hoc! *)
| SIFunctor of Stretch.t list * structure
(* Exception definitions. *) (* Exception definitions. *)
| SIExcDefs of excdef list | SIExcDefs of excdef list
(* Algebraic data type definitions (mutually recursive). *) (* Algebraic data type definitions (mutually recursive). *)
| SITypeDefs of typedef list | SITypeDefs of typedef list
(* Value definitions (not mutually recursive). *) (* Value definitions (mutually recursive or not, as per the flag). *)
| SINonRecValDefs of valdef list | SIValDefs of bool * valdef list
(* Raw OCaml code. *) (* Raw OCaml code. *)
| SIStretch of Stretch.t list | SIStretch of Stretch.t list
(* Sub-module definition. *) (* Sub-module definition. *)
......
...@@ -589,11 +589,8 @@ let valdef f = function ...@@ -589,11 +589,8 @@ let valdef f = function
| { valpat = p; valval = e } -> | { valpat = p; valval = e } ->
fprintf f "%a =%a%t%t" pat p (indent 2 expr) e nl nl fprintf f "%a =%a%t%t" pat p (indent 2 expr) e nl nl
let valdefs = let valdefs recursive =
pdefs valdef letrec et pdefs valdef (if recursive then letrec else letnonrec) et
let nonrecvaldefs =
pdefs valdef letnonrec et
let typedefs = let typedefs =
pdefs typedef keytyp et pdefs typedef keytyp et
...@@ -635,12 +632,16 @@ let functorparams intf body b f params = ...@@ -635,12 +632,16 @@ let functorparams intf body b f params =
nl nl
let rec structure_item f = function let rec structure_item f = function
| SIFunctor ([], s) ->
structure f s
| SIFunctor (_ :: _ as params, s) ->
functorparams false structure s f params
| SIExcDefs defs -> | SIExcDefs defs ->
excdefs false f defs excdefs false f defs
| SITypeDefs defs -> | SITypeDefs defs ->
typedefs f defs typedefs f defs
| SINonRecValDefs defs -> | SIValDefs (recursive, defs) ->
nonrecvaldefs f defs valdefs recursive f defs
| SIStretch stretches -> | SIStretch stretches ->
List.iter (stretch false f) stretches List.iter (stretch false f) stretches
| SIModuleDef (name, rhs) -> | SIModuleDef (name, rhs) ->
...@@ -666,9 +667,9 @@ let program f p = ...@@ -666,9 +667,9 @@ let program f p =
typedefs p.typedefs; typedefs p.typedefs;
List.iter (stretch false f) p.prologue; List.iter (stretch false f) p.prologue;
fprintf f "%a%a%a" fprintf f "%a%a%a"
nonrecvaldefs p.nonrecvaldefs (valdefs false) p.nonrecvaldefs
(list moduledef nothing) p.moduledefs (list moduledef nothing) p.moduledefs
valdefs p.valdefs; (valdefs true) p.valdefs;
List.iter (stretch false f) p.postlogue List.iter (stretch false f) p.postlogue
let valdecl f (x, ts) = let valdecl f (x, ts) =
...@@ -697,7 +698,9 @@ and with_type f (name, wk, t) = ...@@ -697,7 +698,9 @@ and with_type f (name, wk, t) =
typ t typ t
and interface_item f = function and interface_item f = function
| IIFunctor (params, i) -> | IIFunctor ([], i) ->
interface f i
| IIFunctor (_ :: _ as params, i) ->
functorparams true interface i f params functorparams true interface i f params
| IIExcDecls defs -> | IIExcDecls defs ->
excdefs true f defs excdefs true f defs
......
...@@ -669,7 +669,7 @@ let application = { ...@@ -669,7 +669,7 @@ let application = {
MStruct [ MStruct [
SIExcDefs [ excredef ]; SIExcDefs [ excredef ];
SITypeDefs [ tokendef2 ]; SITypeDefs [ tokendef2 ];
SINonRecValDefs [ SIValDefs (false, [
token2terminal; token2terminal;
define ("error_terminal", EIntConst (Terminal.t2i Terminal.error)); define ("error_terminal", EIntConst (Terminal.t2i Terminal.error));
token2value; token2value;
...@@ -680,7 +680,7 @@ let application = { ...@@ -680,7 +680,7 @@ let application = {
goto; goto;
semantic_action; semantic_action;
trace; 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