forked from pattersonzUTD/Example-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLexerTest.java
More file actions
28 lines (22 loc) · 685 Bytes
/
Copy pathLexerTest.java
File metadata and controls
28 lines (22 loc) · 685 Bytes
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
import java.io.*;
import java_cup.runtime.*;
public class LexerTest {
public static void main(String[] argv) {
Symbol sym;
final String format = "%-7s %2s, %-8s %-10s\n";
System.out.format(
format,
"TYPE", "LN", "COL", "VALUE"
);
try {
Lexer lexer = new Lexer(new FileReader(argv[0]));
for (sym = lexer.next_token(); sym.sym != 0; sym = lexer.next_token()) {
System.out.format(
format,
sym, sym.left+1, sym.right, sym.value
);
}
} catch (Exception e) {
}
}
}