2016-03-19 17:01:14 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
// -*- javascript -*-
|
|
|
|
|
|
|
|
var fs = require('fs');
|
|
|
|
var compiler = require('../compiler/compiler.js');
|
|
|
|
|
|
|
|
function compileAndPrint(inputSource) {
|
|
|
|
var translatedSource = compiler.compileSyndicateSource(inputSource);
|
|
|
|
if (translatedSource) {
|
|
|
|
console.log(translatedSource);
|
2016-05-17 17:26:50 +00:00
|
|
|
} else {
|
|
|
|
process.exit(1);
|
2016-03-19 17:01:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.argv.length < 3 || process.argv[2] === '-') {
|
|
|
|
var inputSource = '';
|
|
|
|
process.stdin.resume();
|
|
|
|
process.stdin.setEncoding('utf8');
|
|
|
|
process.stdin.on('data', function(buf) { inputSource += buf; });
|
|
|
|
process.stdin.on('end', function() { compileAndPrint(inputSource); });
|
|
|
|
} else {
|
|
|
|
var inputSource = fs.readFileSync(process.argv[2]).toString();
|
|
|
|
compileAndPrint(inputSource);
|
|
|
|
}
|