Commit | Line | Data |
---|---|---|
cbbb51b4 | 1 | with Ada.Exceptions; |
cbbb51b4 | 2 | with Ada.Text_IO.Unbounded_IO; |
daffc668 | 3 | |
cbbb51b4 NB |
4 | with Printer; |
5 | with Reader; | |
11932a6c | 6 | with Readline; |
daffc668 | 7 | with Types.Mal; |
cbbb51b4 NB |
8 | |
9 | procedure Step1_Read_Print is | |
10 | ||
daffc668 NB |
11 | use Types; |
12 | ||
11932a6c | 13 | function Read return Mal.T with Inline; |
cbbb51b4 | 14 | |
11932a6c | 15 | function Eval (Ast : in Mal.T) return Mal.T; |
cbbb51b4 | 16 | |
11932a6c | 17 | procedure Print (Ast : in Mal.T) with Inline; |
cbbb51b4 | 18 | |
11932a6c | 19 | procedure Rep with Inline; |
cbbb51b4 NB |
20 | |
21 | ---------------------------------------------------------------------- | |
22 | ||
11932a6c NB |
23 | function Eval (Ast : in Mal.T) return Mal.T is (Ast); |
24 | ||
25 | procedure Print (Ast : in Mal.T) is | |
26 | begin | |
27 | Ada.Text_IO.Unbounded_IO.Put_Line (Printer.Pr_Str (Ast)); | |
28 | end Print; | |
29 | ||
30 | function Read return Mal.T is (Reader.Read_Str (Readline.Input ("user> "))); | |
31 | ||
32 | procedure Rep is | |
cbbb51b4 | 33 | begin |
11932a6c NB |
34 | Print (Eval (Read)); |
35 | end Rep; | |
cbbb51b4 NB |
36 | |
37 | ---------------------------------------------------------------------- | |
38 | ||
39 | begin | |
11932a6c NB |
40 | loop |
41 | begin | |
42 | Rep; | |
43 | exception | |
44 | when Readline.End_Of_File => | |
45 | exit; | |
46 | when Reader.Empty_Source => | |
47 | null; | |
48 | when E : Reader.Reader_Error => | |
49 | Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); | |
50 | -- Other exceptions are unexpected. | |
51 | end; | |
52 | end loop; | |
53 | Ada.Text_IO.New_Line; | |
cbbb51b4 | 54 | end Step1_Read_Print; |