Skip to content

Commit

Permalink
Allow multiple grammar paths to be specified to inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Sep 9, 2016
1 parent 1202742 commit 5aadb4e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/inspect.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
if (process.argv.length !== 4) {
console.log('usage: node index.js <grammarPath> <filePath>');
if (process.argv.length < 4) {
console.log('usage: node index.js <mainGrammarPath> [<additionalGrammarPath1> ...] <filePath>');
process.exit(0);
}

var GRAMMAR_PATH = process.argv[2];
var FILE_PATH = process.argv[3];
var GRAMMAR_PATHS = process.argv.slice(2, process.argv.length - 1);
var FILE_PATH = process.argv[process.argv.length - 1];

var Registry = require('../out/main').Registry;
var registry = new Registry();
var grammar = registry.loadGrammarFromPathSync(GRAMMAR_PATH);

console.log('LOADING GRAMMAR' + GRAMMAR_PATHS[0]);
var grammar = registry.loadGrammarFromPathSync(GRAMMAR_PATHS[0]);
for (var i = 1; i < GRAMMAR_PATHS.length; i++) {
console.log('LOADING GRAMMAR' + GRAMMAR_PATHS[i]);
registry.loadGrammarFromPathSync(GRAMMAR_PATHS[i]);
}

var fileContents = require('fs').readFileSync(FILE_PATH).toString();
var lines = fileContents.split(/\r\n|\r|\n/);
Expand Down

0 comments on commit 5aadb4e

Please sign in to comment.