forked from nikolajk00/Rational_Reckoner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rational_reckoner-process.adb
38 lines (38 loc) · 1005 Bytes
/
rational_reckoner-process.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
with Ada.Text_IO;
use Ada.Text_IO;
with Rational_Numbers.IO;
with Rat_Stack.Print; use Rat_Stack;
with Rational_Numbers; use Rational_Numbers;
separate(Rational_Reckoner)-- It points that the next
-- unit is a subunit
procedure Process(C: Character)
is
R, temp: Rational;
procedure Get_Rational(R: out Rational) is separate; -- the stub for Get_Rational
begin
if C = '#' then
Get_Rational(R); -- Let Get_Rational be
-- the new slave procedure
Push(R);
elsif C = '-' then
temp := -Pop;
Push(temp);
elsif C = '!' then
Rational_Numbers.IO.Put(Pop);
Put_Line("");
elsif C = '?' then
temp := Pop;
Rational_Numbers.IO.Put(temp);
Put_Line("");
Push(temp);
elsif C = '*' then
Push(Pop * Pop);
elsif C = '/' then
Push(Pop / Pop);
elsif C = '+' then
Push(Pop + Pop);
else
Put_Line("Unknown operation");
-- and so on for
end if;
end Process;