-
Notifications
You must be signed in to change notification settings - Fork 1
/
lisp-dump.adb
61 lines (48 loc) · 1.27 KB
/
lisp-dump.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
pragma Ada_2012;
with Ada.Text_IO; use Ada.Text_IO;
procedure Lisp.Dump is
function Left (S : String; Length : Natural) return String is
(if S'Length <= Length then S
else S (S'First .. S'First - 1 + Length));
function Fill (S : String; Width : Positive) return String is
(if S'Length >= Width then S else Fill (S & ' ', Width));
procedure Put (E : Expr; Width : Positive);
procedure Put (E : Expr; Width : Positive) is
S : constant String := E'Img;
begin
for J in S'Length + 1 .. Width loop
Put (' ');
end loop;
Put (S);
end Put;
P : Pair;
N : Atomic := nil;
begin
Put_Line ("*** NAMES ***");
loop
Put_Line (Fill (N'Img, 5) & " | " & Image (N));
N := Next (N);
exit when N = nil;
end loop;
Put_Line ("*** MEMORY ***");
for L in reverse Last_Cons .. nil - 1 loop
P := Memory (L);
Put (nil - L, 5);
Put (" | ");
if P.A in Atomic then
Put (Image (P.A));
else
Put (nil - P.A, 5);
end if;
Set_Col (25);
if P.D in Atomic then
Put (Image (P.D));
else
Put (nil - P.D, 5);
end if;
Set_Col (33);
Put ("| ");
Put (Left (Image (L), 40));
New_Line;
end loop;
end Lisp.Dump;