-
Notifications
You must be signed in to change notification settings - Fork 0
/
slp.java
51 lines (40 loc) · 972 Bytes
/
slp.java
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
abstract class Stm {}
class CompoundStm extends Stm {
Stm stm1, stm2;
CompoundStm(Stm s1, Stm s2) {stm1=s1; stm2=s2;}
}
class AssignStm extends Stm {
String id; Exp exp;
AssignStm(String i, Exp e) {id=i; exp=e;}
}
class PrintStm extends Stm {
ExpList exps;
PrintStm(ExpList e) {exps=e;}
}
abstract class Exp {}
class IdExp extends Exp {
String id;
IdExp(String i) {id=i;}
}
class NumExp extends Exp {
int num;
NumExp(int n) {num=n;}
}
class OpExp extends Exp {
Exp left, right; int oper;
final static int Plus=1,Minus=2,Times=3,Div=4;
OpExp(Exp l, int o, Exp r) {left=l; oper=o; right=r;}
}
class EseqExp extends Exp {
Stm stm; Exp exp;
EseqExp(Stm s, Exp e) {stm=s; exp=e;}
}
abstract class ExpList {}
class PairExpList extends ExpList {
Exp head; ExpList tail;
public PairExpList(Exp h, ExpList t) {head=h; tail=t;}
}
class LastExpList extends ExpList {
Exp head;
public LastExpList(Exp h) {head=h;}
}