23663
|
1 |
signature ABSTRACT_MACHINE =
|
|
2 |
sig
|
|
3 |
|
|
4 |
datatype term = Var of int | Const of int | App of term * term | Abs of term
|
|
5 |
|
|
6 |
datatype pattern = PVar | PConst of int * (pattern list)
|
|
7 |
|
|
8 |
datatype guard = Guard of term * term
|
|
9 |
|
|
10 |
type program
|
|
11 |
|
|
12 |
exception Compile of string;
|
|
13 |
|
|
14 |
(* The de-Bruijn index 0 occurring on the right hand side refers to the LAST pattern variable, when traversing the pattern from left to right,
|
|
15 |
1 to the second last, and so on. *)
|
|
16 |
val compile : (guard list * pattern * term) list -> program
|
|
17 |
|
|
18 |
val discard : program -> unit
|
|
19 |
|
|
20 |
exception Run of string;
|
|
21 |
val run : program -> term -> term
|
|
22 |
|
|
23 |
end
|
|
24 |
|
|
25 |
structure AbstractMachine : ABSTRACT_MACHINE =
|
|
26 |
struct
|
|
27 |
|
|
28 |
datatype term = Var of int | Const of int | App of term * term | Abs of term
|
|
29 |
|
|
30 |
datatype pattern = PVar | PConst of int * (pattern list)
|
|
31 |
|
|
32 |
datatype guard = Guard of term * term
|
|
33 |
|
|
34 |
type program = unit
|
|
35 |
|
|
36 |
exception Compile of string;
|
|
37 |
|
|
38 |
fun compile _ = raise Compile "abstract machine stub"
|
|
39 |
|
|
40 |
fun discard _ = raise Compile "abstract machine stub"
|
|
41 |
|
|
42 |
exception Run of string;
|
|
43 |
|
|
44 |
fun run p t = raise Run "abstract machine stub"
|
|
45 |
|
|
46 |
end
|