lark-parser / Lark.js

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

Fix UnexpectedInput.get_context() errors #36

Closed jpcano closed 1 year ago

jpcano commented 1 year ago

I tried to call get_context() like this:

try {
  const result = parser.parse(equation);
  console.log(result.pretty());
} catch (e) {
  console.log("There was an error in the following line");
  console.log(e.get_context(equation));
}

But I got several errors indicating that some symbols are not defined (I execute Lark.js through node v16.18.1)

Correct me if I am wrong but I suspect that this code is autogenerated from Python where those symbols are defined. I rewrote it so it can be executed in my environment. I took the following decisions:

erezsh commented 1 year ago

Correct me if I am wrong but I suspect that this code is autogenerated from Python

Yes, that's true. And some functions fell through the cracks.

lgtm, thanks!