blob: c4a3b29198305db958bd067fb097146442768311 (
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
|
'use strict';
var fs = require('fs');
var RuleCompiler = require('./rule-compiler.js');
if (process.argv.length < 3) {
console.log('Usage: node cli.js <rules script>');
process.exit(1);
}
var src = fs.readFileSync(process.argv[2]).toString();
var rules = [];
var caps = {};
var tags = {};
var err = RuleCompiler.compile(src,rules,caps,tags);
if (err) {
console.log('ERROR parsing '+process.argv[2]+' line '+err[0]+' column '+err[1]+': '+err[2]);
process.exit(1);
} else {
console.log(JSON.stringify({
rules: rules,
caps: caps,
tags: tags
},null,2));
process.exit(0);
}
|