-
Notifications
You must be signed in to change notification settings - Fork 2
/
rebuild.js
30 lines (27 loc) · 1018 Bytes
/
rebuild.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
/* nodejs only file which re-builds lex and examples*/
var fs = require('fs');
var PEG = require("pegjs");
var template = require('./lib/template.js');
fs.readFile('lib/el.pegjs', 'utf8', function (err,data) {
if (err) return console.log(err);
var parser = PEG.buildParser(data, {output:"source"});
fs.writeFile('lib/lex.js', 'try { module = module || {}; } ' +
'catch (e) { module = {}; } module.exports = ' +
parser + ';', function (err) {
if (err) return console.log(err);
console.log('lex has been rebuilt');
});
});
fs.readdir('templates', function(err, data) {
if (err) return console.log(err);
for (var i = 0; i<data.length; i++) {
var examples = require("./templates/" + data[i]);
for (var j = 0; j< examples.length; j++) {
fs.writeFile('examples/' + (examples[j].name.split(" ").join("_")) + ".eli",
template.encode(examples[j].program), function (err) {
if (err) return console.log(err);
console.log('ok');
});
}
}
});