-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStmt.java
More file actions
49 lines (47 loc) · 1.32 KB
/
Stmt.java
File metadata and controls
49 lines (47 loc) · 1.32 KB
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
class Stmt{
Assign ass;
If iff;
Loop loo;
Out ou;
In inn;
Decl d;
void parse(Scanner s){
if(s.currentToken() == Core.ID){
ass = new Assign();
ass.parse(s);
}else if(s.currentToken()==Core.IF){
iff = new If();
iff.parse(s);
}else if(s.currentToken()==Core.WHILE){
loo = new Loop();
loo.parse(s);
}else if(s.currentToken()==Core.OUT){
ou = new Out();
ou.parse(s);
}else if(s.currentToken()==Core.IN){
inn = new In();
inn.parse(s);
}else if(s.currentToken() == Core.INTEGER || s.currentToken() == Core.ARRAY){
d = new Decl();
d.parse(s);
}else{
System.out.println("Error: Expected \"In\", \"Out\", \"ID\", \"IF\", \"While\", \"Integer\", or \"Array\", Token. Received: " + s.currentToken() + " token.");
System.exit(1);
}
}
void print(){
if(ass != null){
ass.print();
}else if(iff != null){
iff.print();
}else if(loo != null){
loo.print();
}else if(ou != null){
ou.print();
}else if(inn != null){
inn.print();
}else if(d != null){
d.print();
}
}
}