From 0e3d292739e9ee4e2010941243e181f7ea1177b6 Mon Sep 17 00:00:00 2001 From: Zhifei Fang Date: Tue, 9 Feb 2016 11:57:35 -0500 Subject: [PATCH 1/2] Add detail grammar error output Add detail grammar error output, which will help developer find the yacc grammar error quickly. --- lib/cli.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/cli.js b/lib/cli.js index 338a23827..9342867ae 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -168,6 +168,7 @@ cli.processGrammars = function processGrammars(file, lexFile, jsonMode) { grammar = ebnfParser.parse(file); } } catch (e) { + console.log(e); throw new Error('Could not parse jison grammar'); } try { @@ -175,6 +176,7 @@ cli.processGrammars = function processGrammars(file, lexFile, jsonMode) { grammar.lex = require('lex-parser').parse(lexFile); } } catch (e) { + console.log(e); throw new Error('Could not parse lex grammar'); } return grammar; From 5f4344dbea04364c5d7514d3b20fab90e57d5620 Mon Sep 17 00:00:00 2001 From: Zhifei Fang Date: Tue, 9 Feb 2016 16:55:01 -0500 Subject: [PATCH 2/2] add the parse error to the exception message --- lib/cli.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index 9342867ae..d03381d2d 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -168,16 +168,14 @@ cli.processGrammars = function processGrammars(file, lexFile, jsonMode) { grammar = ebnfParser.parse(file); } } catch (e) { - console.log(e); - throw new Error('Could not parse jison grammar'); + throw new Error(e.message + '\nCould not parse jison grammar.'); } try { if (lexFile) { grammar.lex = require('lex-parser').parse(lexFile); } } catch (e) { - console.log(e); - throw new Error('Could not parse lex grammar'); + throw new Error(e.message + '\nCould not parse lex grammar.'); } return grammar; };