aboutsummaryrefslogtreecommitdiff
path: root/lib/node.js
blob: 9dba3c1867d0c59b8213ff16e1b3fccdd1418d51 (about) (plain)
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
#! /usr/bin/env node

(function(){

    var fs = require("fs");
    var vm = require("vm");
    var sys = require("util");

    function load_global(file) {
        var code = fs.readFileSync(file, "utf8");
        return vm.runInThisContext(code, file);
    };

    load_global("./utils.js");
    load_global("./ast.js");
    load_global("./parse.js");
    load_global("./output.js");

    ///

    var filename = process.argv[2];
    console.time("parse");
    var ast = parse(fs.readFileSync(filename, "utf8"));
    console.timeEnd("parse");

    // console.time("walk");
    // var w = new TreeWalker(function(node){
    //     console.log(node.TYPE + " [ start: " + node.start.line + ":" + node.start.col + ", end: " + node.end.line + ":" + node.end.col + "] " + node.name);
    // });
    // ast.walk(w);
    // console.timeEnd("walk");

    //console.log(JSON.stringify(ast));

})();