-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGOLex.java
More file actions
50 lines (32 loc) · 1.09 KB
/
GOLex.java
File metadata and controls
50 lines (32 loc) · 1.09 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
50
import java_cup.runtime.ComplexSymbolFactory;
import java_cup.runtime.SymbolFactory;
import java.io.*;
public class GOLex {
private static final int MAX_TOKENS = 1000;
public static void main(String[] args) throws IOException {
int i,n;
java_cup.runtime.Symbol [] token = new java_cup.runtime.Symbol[MAX_TOKENS];
SymbolFactory symbolFactory = new ComplexSymbolFactory();
GOLexer lexer = new GOLexer(new InputStreamReader(System.in),symbolFactory);
System.out.println("Source Program");
System.out.println("--------------");
System.out.println();
n = -1;
do {
if(n < MAX_TOKENS) {
token[++n] = lexer.next_token();
}
else {
ErrorMessage.print(0,"Maximum number of tokens exceeded");
}
}while(token[n].sym != Symbol.EOF);
System.out.println();
System.out.println("List of Tokens");
System.out.println("--------------");
System.out.println();
for(i = 0; i < n; i++) {
System.out.println(token[i]);
}
System.out.println();
}
}