ENTRY Go Prout Complex Card Complex Check 0123456789 Check Done Check

 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
$ENTRY Go {
= <Prout <Complex <Card>>>;
}
Complex {
e.1 = <Check ('+-*(),0123456789[]') e.1>
}
Check {
e.Done (e.X) ' ' e.1 = <Check e.Done (e.X) e.1>;
e.Done (e.L s.X e.R) s.X e.1 = <Check e.Done s.X (e.L s.X e.R) e.1>;
e.Done (e.S) = <Numbers ('0123456789') () e.Done>;
e.Done (e.S) s.X e.1 = 'Error: unexpected symbol \'' s.X '\'';
}
Numbers {
e.Done (e.L s.X e.R) (e.Num) s.X e.1 = <Numbers e.Done (e.L s.X e.R) (e.Num s.X) e.1>;
e.Done (e.S) () s.X e.1 = <Numbers e.Done s.X (e.S) () e.1>;
e.Done (e.S) () = <Spar (L) e.Done>;
e.Done (e.S) (e.Num) e.1 = <Numbers e.Done <Numb e.Num> (e.S) () e.1> ;
}
Spar {
(e.S) '(' e.T = <Spar ((e.S)) e.T>;
((e.S) e.1) ')' e.T = <Spar (e.S (e.1)) e.T>;
(L e.S) ')' e.T = 'Error: expected \'(\'';
(e.S) s.X e.T = <Spar (e.S s.X) e.T>;
(L e.S) = <Calc e.S>;
(e.S) = 'Error: expected \')\'';
}
Calc {
e.1 '+' e.2 = <AddC <Calc e.1> '+' <Calc e.2>>;
e.1 '-' e.2 '-' e.3 = <Calc <Calc e.1 '-' e.2> '-' e.3>;
e.1 '-' e.2 = <SubC <Calc e.1> '-' <Calc e.2>>;
e.1 '*' e.2 = <MulC <Calc e.1> '*' <Calc e.2>>;
(e.1) = <Calc e.1>;
'[' s.1 ',' s.2 ']' = '[' s.1 ',' s.2 ']';
"Syntax Error " e.1 = "Syntax Error " e.1;
e.1 = "Syntax Error " e.1;
}
AddC {
'[' s.Re1 ',' s.Im1 ']+[' s.Re2 ',' s.Im2 ']' = '[' <Add s.Re1 s.Re2> ',' <Add s.Im1 s.Im2> ']';
e.1 = <Prout "Syntax Error with Add">;
}
SubC {
'[' s.Re1 ',' s.Im1 ']-[' s.Re2 ',' s.Im2 ']' = '[' <Sub s.Re1 s.Re2> ',' <Sub s.Im1 s.Im2> ']';
e.1 = <Prout "Syntax Error with Sub">;
}
MulC {
'[' s.Re1 ',' s.Im1 ']*[' s.Re2 ',' s.Im2 ']' = '[' <Sub
<Mul s.Re1 s.Re2>
<Mul s.Im1 s.Im2> >
',' <Add
<Mul s.Re1 s.Im2>
<Mul s.Re2 s.Im1> >
']';
e.1 = <Prout "Syntax Error with Mul">;
}