Debian Codegraph @

lib/mlrisc-lib/MLRISC/Tools/FakeSMLAst/ast-trans.sig

raw
1 (*
2 * Translation from one sort to another
3 *)
4 signature MDL_AST_TRANSLATION =
5 sig
6
7 structure Ast : MDL_AST
8
9 type 'a map = {origName : Ast.id, (* original name *)
10 newName : Ast.id, (* new name (for duplicates) *)
11 ty : Ast.ty (* the type associated with it *)
12 } -> 'a
13
14 type 'a folder = {origName : Ast.id,
15 newName : Ast.id,
16 ty : Ast.ty} * 'a -> 'a
17
18
19 (* Simplify an expression, declaration etc. *)
20 val simplifyExp : Ast.exp -> Ast.exp
21 val simplifyDecl : Ast.decl -> Ast.decl
22 val simplifyPat : Ast.pat -> Ast.pat
23 val simplifyTy : Ast.ty -> Ast.ty
24 val simplifySexp : Ast.structexp -> Ast.structexp
25
26 (* Strip away all location markings *)
27 val stripMarks : Ast.decl -> Ast.decl
28
29 (* Translate a type to a pattern. Apply the map function on each binding
30 *)
31 val mapTyToPat : Ast.pat map -> Ast.ty -> Ast.pat
32
33 (* Translate a type to an expression. Apply the map function on
34 * each identifier.
35 *)
36 val mapTyToExp : Ast.exp map -> Ast.ty -> Ast.exp
37
38 (* Fold functions that does similar things as the ones above, i.e.,
39 * it enumerates all the bindings and their types.
40 *)
41 val foldTy : 'a folder -> 'a -> Ast.ty -> 'a
42 val foldCons : 'a folder -> 'a -> Ast.consbind -> 'a
43
44 (* Translate a constructor to a pattern *)
45 val mapConsToPat : {prefix : Ast.id list, (* path prefix *)
46 id : Ast.pat map (* how to map identifiers *)
47 } -> Ast.consbind -> Ast.pat
48
49 (* Translate a constructor to an expression representing its arguments *)
50 val mapConsArgToExp : Ast.exp map -> (* how to map identifiers *)
51 Ast.consbind -> Ast.exp
52
53 (* Translate a constructor to a constructor expression *)
54 val mapConsToExp : {prefix : Ast.id list, (* path prefix *)
55 id : Ast.exp map (* how to map identifiers *)
56 } -> Ast.consbind -> Ast.exp
57
58 (* Translate a constructor to a clause *)
59 val mapConsToClause : {prefix : Ast.id list, (* path prefix *)
60 pat : Ast.pat -> Ast.pat,
61 exp : Ast.exp
62 } -> Ast.consbind -> Ast.clause
63
64 (* Given a constructor, return a function that looks up the pattern
65 * variables and their types
66 *)
67 val consBindings : Ast.consbind -> (Ast.id -> Ast.exp * Ast.ty)
68
69 end