lark-parser / Lark.js

Live port of Lark's standalone parser to Javascript
MIT License
71 stars 12 forks source link

Get into infinite loop if keeping parsing when encountered errors #22

Closed jillyj closed 2 years ago

jillyj commented 2 years ago

Grammar file: https://github.com/opencybersecurityalliance/kestrel-lang/blob/develop/src/kestrel/syntax/kestrel.lark Generated parser: kestrelParser.js.zip

Code

function handle_errors(e) { return true; }

  try {
    treeData = parser.parse("proc2 =", null, handle_errors).children[0];
  } catch (e) {
    console.debug("uncaught error:", e)
  }

Expected: can stop parsing and get error info.

jillyj commented 2 years ago

@erezsh could you please take a look at this issue?

erezsh commented 2 years ago

Fixed in PR https://github.com/lark-parser/Lark.js/pull/26

Can you test that it works as expected?

erezsh commented 2 years ago

(now also merged to master)

jillyj commented 2 years ago

@erezsh how do I test with the master? I usually generated the parser by the larkJS package.

jillyj commented 2 years ago

I got it worked by pip install -e. :) The fix works! Thanks.

erezsh commented 2 years ago

Great! It will get into the next release.