lark-parser / Lark.js

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

wrong parameter passing in Lark.parse_interactive #12

Open supergem3000 opened 2 years ago

supergem3000 commented 2 years ago

lark.js line 3472

return this.parser.parse_interactive({
    unknown_param_0: text,
    start: start,
});

ParsingFrontend.parse_interactive receives two params: text and start, but it gives an object with unknown_param_0. So the lexer cannot read the correct text.

When I write the code like this:

const parser = get_parser();
let p = parser.parser_interactive(text);
p.exhaust_lexer();

it cannot run correctly. But there is no error in python version of lark if i write the similar code.

Maybe its a programming language translation error. I found three unknown_param_0 in lark.js source code. Hope you can fix it. I'm trying to use lark to finish my course project. Thank you.

ParsingFrontend.parse_interactive接受两个参数: textstart,但是却传给了一个包含unknown_param_0字段的对象。因此lexer无法读取到正确的文本。

上方的代码不能正确运行。但是在Python版本的lark中没有问题。

可能是一个计算机语言翻译出现的问题。我在lark.js的源代码中发现了三处unknown_param_0。希望你们可以修复它。我正在试着用lark完成我的课程项目。谢谢。

erezsh commented 2 years ago

Yes, you're right that it's a translation error.

It should look like this:

  parse_interactive(text = null, start = null) {
    return this.parser.parse_interactive(text, start);
  }