-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
24 lines (21 loc) · 829 Bytes
/
Main.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
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.text.ParseException;
public class Main {
public static void main(String[] args) {
String text = "for (int i = 0; i < 10; i++)";
ByteArrayInputStream bais = new ByteArrayInputStream(text.getBytes());
BufferedInputStream bis = new BufferedInputStream(bais);
System.out.println(text);
System.out.println("============================");
try {
LexicalAnalyzer la = new LexicalAnalyzer(bis);
while (la.getCurToken() != Token.END) {
System.out.println(la.getCurToken());
la.nextToken();
}
} catch (ParseException e) {
System.out.println(e.getMessage() + " Offset: " + e.getErrorOffset());
}
}
}