@ull-esit-pl/use-parse
Version:
Very simplistic executable that dynamically `requires` a module generated by PEG.js or Jison or any parser-parser that exports an object with a `parse` method and calls it with the `input` provided in the command line
16 lines (12 loc) • 326 B
JavaScript
#!/usr/bin/env node
const path = require('path');
let [peg, input, method] = process.argv.splice(2);
if (!method) method = "parse";
const parse = require(path.join(process.cwd(),peg))[method];
console.log(`Processing <${input}>`);
try {
const r = parse(input);
console.log(r);
} catch(e) {
console.log(e.message)
}