forked from julioCROS/Prova1_LLP-miniPascal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miniPascal.java
49 lines (42 loc) · 1.58 KB
/
miniPascal.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
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
import lexical.LexicalAnalysis;
import syntatic.SyntaticAnalysis;
import lexical.TokenType;
import lexical.Lexeme;
public class miniPascal {
public static void main(String[] args) {
if (args.length != 1) {
System.out.println("Usage: java mli [miniPascal file]");
return;
}
try (LexicalAnalysis l = new LexicalAnalysis(args[0])) {
// O código a seguir é dado para testar o interpretador.
// TODO: descomentar depois que o analisador léxico estiver OK.
SyntaticAnalysis s = new SyntaticAnalysis(l);
s.start();
System.out.println("Sim");
// // O código a seguir é usado apenas para testar o analisador léxico.
// // TODO: depois de pronto, comentar o código abaixo.
/*
* Lexeme lex;
* do {
* lex = l.nextToken();
* System.out.printf("%02d: (\"%s\", %s)\n", l.getLine(),
* lex.token, lex.type);
* } while (lex.type != TokenType.END_OF_FILE &&
* lex.type != TokenType.INVALID_TOKEN);
*
* switch (lex.type) {
* case INVALID_TOKEN:
* System.out.printf("%02d: Lexema invalido [%s]\n", l.getLine(), lex.token);
* break;
* default:
* System.out.printf("(\"%s\", %s)\n", lex.token, lex.type);
* break;
*
* }
*/
} catch (Exception e) {
System.err.println("Internal error: " + e.getMessage());
}
}
}