ENTRY Go Prout Calc Numbers Card Check DoCheck 0123456789 DoCheck DoCh

 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$ENTRY Go {
= <Prout <Calc <Numbers <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;
}
Numbers {
e.1 = <N1 ('0123456789')e.1>;
}
N1 {
(e.L s.X e.R) s.X e.1 =
<N2 (e.L s.X e.R) (s.X) e.1>;
(e.S) s.X e.1 = s.X <N1 (e.S) e.1>;
(e.S) = ;
}
N2 {
(e.L s.X e.R) (e.N) s.X e.1 =
<N2 (e.L s.X e.R) (e.N s.X) e.1>;
(e.S) (e.N) e.1 =
<Numb e.N><N1 (e.S) e.1>;
}
Calc {
' ' e.1 = <Prout e.1> <Calc e.1>;
'+' e.1 = <Prout e.1> <AddMy e.1>;
'*' e.1 = <Prout e.1> <MulMy e.1>;
'(' e.1 ')' = <Prout e.1> <Calc e.1>;
s.1 = s.1;
}
AddMy {
' ' e.1 = <AddMy e.1>;
'(' e.1 ')' = <Calc e.1>;
t.1 = <Prout t.1> t.1;
t.1 e.2 = <Prout 'Mul'> <Add t.1 <AddMy e.2>>;
}
MulMy {
' ' e.1 = <MulMy e.1> <Prout 'Mul'>;
'(' e.1 ')' = <Calc e.1> <Prout 'Mul'>;
t.1 = <Prout t.1> t.1 <Prout 'Mul'>;
t.1 e.2 = <Prout 'Mul'> <Mul t.1 <MulMy e.2>>;
}