kkoch986 / js-parse

A generic node.js based LR(1) shift-reduce parser.
12 stars 1 forks source link

better error messages for bad parser descriptions #7

Open kkoch986 opened 10 years ago

kkoch986 commented 10 years ago

has set a production as

"X":[ "Y" ]

instead of

"X":[ ["Y"] ]

And the error was very unclear:

TypeError: Cannot read property '*e*' of undefined
      at Object.computeFirstSetForGrammar (/home/ken/Documents/projects/js-parse/lib/parser/utils/first_set.js:82:31)
      at CreateLRParser (/home/ken/Documents/projects/js-parse/lib/parser/lr_parser.js:146:42)
      at Object.CreateLRParserWithLexer [as CreateWithLexer] (/home/ken/Documents/projects/js-parse/lib/parser/lr_parser.js:62:15)
      at Context.<anonymous> (/home/ken/Documents/projects/js-parse/examples/php/spec/tokens_spec.js:10:25)
      at callFn (/usr/local/lib/node_modules/mocha/lib/runnable.js:249:21)
      at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:242:7)
      at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:373:10)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:451:12
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:298:14)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:308:7
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:246:23)
      at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:275:5)
      at processImmediate [as _immediateCallback] (timers.js:336:15)