Common Lisp: Add documentation
[jackhill/mal.git] / ada / step2_eval.adb
index d66f163..6f0e281 100644 (file)
@@ -1,7 +1,6 @@
 with Ada.Containers.Hashed_Maps;
 with Ada.Strings.Unbounded.Hash;
 with Ada.Text_IO;
-with Ada.IO_Exceptions;
 with Ada.Exceptions;
 with Printer;
 with Reader;
@@ -155,7 +154,15 @@ procedure Step2_Eval is
          declare
             Evaled_H, First_Param : Mal_Handle;
             Evaled_List : List_Mal_Type;
+            Param_List : List_Mal_Type;
          begin
+            Param_List := Deref_List (Param).all;
+
+            -- Deal with empty list..
+            if Param_List.Length = 0 then
+               return Param;
+            end if;
+
             Evaled_H := Eval_Ast (Param, Env);
             Evaled_List := Deref_List (Evaled_H).all;
             First_Param := Car (Evaled_List);
@@ -190,11 +197,7 @@ procedure Step2_Eval is
         return Print (Evaluated_AST);
      end if;
 
-   end Rep; 
-
-
-   S : String (1..Reader.Max_Line_Len);
-   Last : Natural;
+   end Rep;
 
 begin
 
@@ -221,18 +224,13 @@ begin
    loop
       begin
          Ada.Text_IO.Put ("user> ");
-         Ada.Text_IO.Get_Line (S, Last);
-         Ada.Text_IO.Put_Line (Rep (S (1..Last), Repl_Env));
+         exit when Ada.Text_IO.End_Of_File;
+         Ada.Text_IO.Put_Line (Rep (Ada.Text_IO.Get_Line, Repl_Env));
       exception
-         when Ada.IO_Exceptions.End_Error => raise;
          when E : others =>
             Ada.Text_IO.Put_Line
               (Ada.Text_IO.Standard_Error,
                Ada.Exceptions.Exception_Information (E));
       end;
    end loop;
-
-exception
-   when Ada.IO_Exceptions.End_Error => null;
-   -- i.e. exit without textual output
 end Step2_Eval;