Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug with parse_interactive and unknown_param_0? #42

Closed
thekevinscott opened this issue Feb 20, 2024 · 4 comments · Fixed by #44
Closed

Possible bug with parse_interactive and unknown_param_0? #42

thekevinscott opened this issue Feb 20, 2024 · 4 comments · Fixed by #44

Comments

@thekevinscott
Copy link
Contributor

When calling .exhaust_lexer() I'm seeing differing behavior between Python and Javascript.

I think I've narrowed it down to this bit of code:

https://github.com/lark-parser/Lark.js/blob/master/larkjs/lark.js#L3761

Which sets LexerThread.state to:

{
unknown_param_0: text,
      start: start,
}

Later on, next_token is called here, which calls this:

while (line_ctr.char_pos < lex_state.text.length) {

Which seems to imply that it expects text to be a string, but in fact text is { unknown_param_0: text, start: start, }.

@thekevinscott
Copy link
Contributor Author

@thekevinscott
Copy link
Contributor Author

I tried modifying the relevant Javascript bit to be:

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

And it appears to work now. But I'm not familiar enough with the code to know whether doing so introduces other bugs.

@erezsh
Copy link
Member

erezsh commented Feb 20, 2024

It's just a bug in the automatic conversion. I think this fix should be okay, though I'll have to check to make sure.

You're welcome to open a PR for it.

@thekevinscott
Copy link
Contributor Author

PR opened here: #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants