-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
36 lines (31 loc) · 1.14 KB
/
test.ts
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
import { ErrorReporter } from "./ErrorReporter";
import { InputStream } from "./InputStream";
import { Scanner } from "./SyntacticAnalyzer/Scanner";
import { Parser } from "./SyntacticAnalyzer/Parser";
import { ASTDisplay } from "./AbstractSyntaxTrees/ASTDisplay";
import { readFileSync } from 'fs';
import { SQLGenerator } from "./CodeGeneration/SQLGenerator";
// read in file
// const filePath = './Examples/sn_fb_room_code.bl';
// const filePath = './Examples/sn_fb_global_rooms.bl';
const filePath = './Examples/small.bl';
const file = readFileSync(filePath, 'utf-8');
const myInputStream = new InputStream(file);
// scan file
const myErrorReporter = new ErrorReporter();
const myScanner = new Scanner(myInputStream, myErrorReporter);
// var i = 0
// while(i < 100){
// console.log(myScanner.scan());
// i++;
// }
// parse file
const myParser = new Parser(myScanner, myErrorReporter);
const myAST = myParser.parse();
console.log("done parsing");
const myASTDisplay = new ASTDisplay();
myASTDisplay.showTree(myAST);
// generate code
const mySQLGenerator = new SQLGenerator();
mySQLGenerator.generateCode(myAST);
mySQLGenerator.showGeneratedCode();