4 with Ada
.IO_Exceptions
;
12 procedure Step4_If_Fn_Do
is
14 function Read
(Param
: String) return Types
.Mal_Handle
is
16 return Reader
.Read_Str
(Param
);
20 -- Eval can't be here because there are function pointers that point
21 -- at it. Thus it must be at library level. See evaluation.ads
24 function Print
(Param
: Types
.Mal_Handle
) return String is
26 return Printer
.Pr_Str
(Param
);
29 function Rep
(Param
: String) return String is
30 AST
, Evaluated_AST
: Types
.Mal_Handle
;
35 if Types
.Is_Null
(AST
) then
38 Evaluated_AST
:= Evaluation
.Eval
(AST
, Envs
.Get_Current
);
39 return Print
(Evaluated_AST
);
44 S
: String (1..Reader
.Max_Line_Len
);
51 while Ada
.Command_Line
.Argument_Count
> Cmd_Args
loop
52 Cmd_Args
:= Cmd_Args
+ 1;
53 if Ada
.Command_Line
.Argument
(Cmd_Args
) = "-d" then
54 Evaluation
.Debug
:= True;
55 elsif Ada
.Command_Line
.Argument
(Cmd_Args
) = "-e" then
62 Ada
.Text_IO
.Put_Line
(Rep
("(def! not (fn* (a) (if a false true)))"));
66 Ada
.Text_IO
.Put
("user> ");
67 Ada
.Text_IO
.Get_Line
(S
, Last
);
68 Ada
.Text_IO
.Put_Line
(Rep
(S
(1..Last
)));
70 when Ada
.IO_Exceptions
.End_Error
=> raise;
73 (Ada
.Text_IO
.Standard_Error
,
74 Ada
.Exceptions
.Exception_Information
(E
));
79 when Ada
.IO_Exceptions
.End_Error
=> null;
80 -- i.e. exit without textual output