Created
June 26, 2017 10:20
-
-
Save pepa65/31cb9f445c0e5237c3740d160ed3825f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
const fs = require('fs'); | |
const parser = require('./grammar.js').parse; | |
function main() { | |
const args = require('process').argv; | |
if (args.length != 3) { | |
console.error("Only 1 argument needed: file-path") | |
return 1; | |
} | |
const filename = args[2]; | |
fs.readFile(filename, {encoding: 'utf8'}, function(err, data) { | |
if (err) { | |
console.log("Error reading file", filename); | |
console.error(err); | |
return 1; | |
} | |
try { | |
let output = parser(data); | |
console.log(output); | |
} | |
catch (e) { | |
console.error(e.message); | |
} | |
}); | |
} | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment