Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ cli.main = function cliMain(opts) {
function processGrammar(raw, lex, opts) {
var grammar,
parser;
grammar = cli.processGrammars(raw, lex, opts.json);
grammar = cli.processGrammars(raw, lex, opts.json, opts.debug);
parser = cli.generateParserString(opts, grammar);
return parser;
}
Expand Down Expand Up @@ -154,7 +154,7 @@ cli.generateParserString = function generateParserString(opts, grammar) {
return generator.generate(settings);
};

cli.processGrammars = function processGrammars(file, lexFile, jsonMode) {
cli.processGrammars = function processGrammars(file, lexFile, jsonMode, debugMode) {
"use strict";
lexFile = lexFile || false;
jsonMode = jsonMode || false;
Expand All @@ -168,13 +168,19 @@ cli.processGrammars = function processGrammars(file, lexFile, jsonMode) {
grammar = ebnfParser.parse(file);
}
} catch (e) {
if (debugMode === true) {
console.log(e);
}
throw new Error('Could not parse jison grammar');
}
try {
if (lexFile) {
grammar.lex = require('lex-parser').parse(lexFile);
}
} catch (e) {
if (debugMode === true) {
console.log(e);
}
throw new Error('Could not parse lex grammar');
}
return grammar;
Expand Down