-
Notifications
You must be signed in to change notification settings - Fork 1
/
compiler.js
85 lines (73 loc) · 4.14 KB
/
compiler.js
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import antlr4 from 'antlr4';
import fs from 'fs';
import ExpLexer from './ExpLexer.js';
import ExpParser from './ExpParser.js';
const compile = async () => {
/* ---------------- VERSION 1 ----------------*/
// const fileName = 'v1/test-01-constant-expressions.exp'; // OK
// const fileName = 'v1/test-02-left-associativity.exp'; // OK
// const fileName = 'v1/test-03-variables.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 2 ----------------*/
// const fileName = 'v2/error-01-undefined-variables.exp'; // OK
// const fileName = 'v2/error-02-unused-variables.exp'; // OK
// const fileName = 'v2/VarSum.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 3 ----------------*/
// const fileName = 'v3/MultiPrint.exp'; // OK
// const fileName = 'v3/Read.exp'; // OK
// const fileName = 'v3/StackSize.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 4 ----------------*/
// const fileName = 'v4/If.exp'; // OK
// const fileName = 'v4/test-07-sequential-if.exp'; // OK
// const fileName = 'v4/test-08-chained-if.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 5 ----------------*/
// const fileName = 'v5/While.exp'; // OK
// const fileName = 'v5/test-09-sequential-while.exp'; // OK
// const fileName = 'v5/test-10-chained-while.exp'; // OK
// const fileName = 'v5/test-11-break-continue.exp'; // OK
// const fileName = 'v5/error-03-break-continue.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 6 ----------------*/
// const fileName = 'v6/IfElse.exp'; // OK
// const fileName = 'v6/test-12-chained-conditionals.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 7 ----------------*/
// const fileName = 'v7/String.exp'; // OK
// const fileName = 'v7/test-13-strings.exp'; // OK
// const fileName = 'v7/error-04-type-checking.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 8 ----------------*/
// const fileName = 'v8/TestArray.exp'; // OK
// const fileName = 'v8/test-14-array.exp'; // OK
// const fileName = 'v8/error-05-array-checking.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 9 ----------------*/
// const fileName = 'v9/SimpleFunction.exp'; // OK
// const fileName = 'v9/test-15-simple-functions.exp'; // OK
// const fileName = 'v9/error-06-simple-functions.exp'; // OK
/* ---------------- END -----------------*/
/* ---------------- VERSION 10 ----------------*/
// const fileName = 'v10/Parameters.exp'; // OK
// const fileName = 'v10/test-16-parameters.exp'; // OK
// const fileName = 'v10/error-07-parameters.exp'; // OK
/* ---------------- END -----------------*/
/* ------------------ FINAL ------------------*/
const fileName = 'vFinal/ReturnValue.exp'; // OK
// const fileName = 'vFinal/test-17-return-value.exp'; // OK
// const fileName = 'vFinal/error-08-return-value.exp'; // OK
/* ---------------- END -----------------*/
if (fileName) {
const input = fs.readFileSync(`./testsFiles/${fileName}`, 'utf-8');
if (input) {
const chars = new antlr4.InputStream(input);
const lexer = new ExpLexer(chars);
const tokens = new antlr4.CommonTokenStream(lexer);
const parser = new ExpParser(tokens);
parser.program();
}
}
};
compile();