Debian Codegraph @

lib/mlrisc-lib/MLRISC/Tools/RewriteGen/poly-gen.sig

raw
1 (*
2 * This module abstracts out the process of generating a polytypic function,
3 * from a set of datatype definitions and transformation rules.
4 *)
5 signature POLY_GEN =
6 sig
7 structure Ast : MDL_AST
8
9 datatype hook =
10 HOOK of
11 { name : string, (* name of function *)
12 factor: bool, (* factor rules by constructor? *)
13 args : string list, (* function arguments *)
14 ret : string, (* return argument name *)
15 (* what is the unit transform of this function *)
16 unit : Ast.exp -> Ast.exp,
17 (* how to generate code for a constructor *)
18 gen : (Ast.ty * Ast.exp -> Ast.exp) * Ast.consbind -> Ast.exp
19 }
20
21 (* translate a set of rules into an declaration *)
22 val gen : hook -> (* hook *)
23 (Ast.id -> bool) -> (* is it a non-terminal type id? *)
24 (* rules for each datatype *)
25 (Ast.datatypebind * Ast.clause list) list ->
26 Ast.decl
27 end