-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
41 lines (27 loc) · 870 Bytes
/
main.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
const fs = require('fs')
const tokenize = require('./tokenizer.js').tokenize;
const parse = require('./parser.js').parse;
const visualize = require('./visual.js').visualize;
const dfs = require('./dfs.js').dfs;
const sanitize = require('./sanitizer.js').sanitize;
const infile = fs.readFileSync(process.argv[2], 'utf-8');
var tokens = tokenize(infile);
quiet = false;
if(process.argv.includes('-q'))
quiet = true;
if(!quiet)
console.log('Tokenizer: OK');
tokens = sanitize(tokens);
[nodes, links] = parse(tokens);
if(!quiet)
console.log('Parser: OK');
if(!quiet)
console.log('Nodes: ', nodes, '\nLinks: ', links);
links = dfs(nodes, links);
if(!quiet)
console.log('DFS check: OK');
if(!quiet)
console.log('Configured links: ', links);
visualize(nodes, links, process.argv[3]);
if(!quiet)
console.log('Visualisation: OK\nDone.');