рефал

 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
$ENTRY Go {
= <Prout <Calc <Card>>>;
}
Check {
e.1 = <DoCheck('0123456789+* ()') e.1>;
}
DoCheck {
(e.L s.X e.R) s.X e.1 =
<DoCheck (e.L s.X e.R) e.1>;
(e.S) = ;
e.1 = INVALID INPUT;
}
Spar { e.1 = <Spar1 (L) e.1>; }
Spar1 {
(e.S) '(' e.T = <Spar1 ((e.S)) e.T>;
((e.S) e.1) ')' e.T =
<Spar1 (e.S (e.1)) e.T>;
(L e.S) ')' e.T = ERROR;
(e.S) s.X e.T =
<Spar1 (e.S s.X) e.T>;
(L e.S) = e.S;
(e.S) = ERROR;
}
Calc {
e.1 '+' e.2 = <Add <Calc e.1> <Calc e.2>>;
( e.1 ) = <Calc e.1>;
s.1 = s.1;
}