-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIn.java
More file actions
44 lines (39 loc) · 1.23 KB
/
In.java
File metadata and controls
44 lines (39 loc) · 1.23 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
class In{
String name;
void parse(Scanner s){
//Checks if Current Token is IN Token, NEXT TOKEN
if(s.currentToken()!=Core.IN){
System.out.println("ERROR: Expected IN Token");
System.exit(1);
}
s.nextToken();
//Checks if Current Token is LPAREN, NEXT TOKEN
if(s.currentToken()!=Core.LPAREN){
System.out.println("ERROR: Expected LPAREN Token");
System.exit(1);
}
s.nextToken();
//Checks if token is and ID, NEXT TOKEN
if(s.currentToken() != Core.ID){
System.out.println("Error: Expected ID Token");
System.exit(1);
}
name = s.getId();
s.nextToken();
//Checks if token is RPAREN, NEXT TOKEN
if(s.currentToken()!=Core.RPAREN){
System.out.println("ERROR: Expected RPAREN Token");
System.exit(1);
}
s.nextToken();
//Checks if Token is Semicolon, NEXT TOKEN
if(s.currentToken()!= Core.SEMICOLON){
System.out.println("Error: Expeceted SEMICOLON Token");
System.exit(1);
}
s.nextToken();
}
void print(){
System.out.println("in( "+ name + " );");
}
}