1 #include <AD/persist/pstream.h>
5 datatype Exp :: collectable persistent =
8 | LITexp (Literal) => _
9 | ADDexp (Exp, Exp) => "(" _ "+" _ ")"
10 | SUBexp (Exp, Exp) => "(" _ "-" _ ")"
11 | MULexp (Exp, Exp) => "(" _ "*" _ ")"
12 | DIVexp (Exp, Exp) => "(" _ "/" _ ")"
13 | IFexp (Exp, Exp, Exp) => "if" _ "then" { _ } "else " { _ } "endif"
15 and Literal :: collectable persistent
18 | REALlit (double) => _
19 | STRINGlit (const char *) => "\"" _ "\""
21 where type Id = const char *
24 refine persistent Exp => "Expressions"
25 | Literal => "Literals"
28 instantiate datatype Exp, Literal;
32 { ifstream F("persist2.dat");
33 Pistream P(F,GC::get_default_gc());
34 cout << "[Reading object from file 'persist2.dat']\n";
35 e2 = (Exp)read_object(P);
36 e3 = (Exp)read_object(P);
39 cout << "e2 = " << e2 << " aka " << (void*)e2 << '\n';
40 cout << "e3 = " << e3 << " aka " << (void*)e3 << '\n';