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

Tokenizer regression in 0.4.0 #28

Closed
CommanderTvis opened this issue Jul 27, 2020 · 1 comment
Closed

Tokenizer regression in 0.4.0 #28

CommanderTvis opened this issue Jul 27, 2020 · 1 comment

Comments

@CommanderTvis
Copy link
Contributor

CommanderTvis commented Jul 27, 2020

I'm trying to upgrade better-parse in https://github.com/mipt-npm/kmath/tree/extended-grammar from 0.4.0-alpha-3 to 0.4.0.

The tokens are
image

Before the update the string "2+2*(2+2)" was lexed like:

[num for "2" at 0 (1:1), plus for "+" at 1 (1:2), num for "2" at 2 (1:3), mul for "*" at 3 (1:4), lpar for "(" at 4 (1:5), num for "2" at 5 (1:6), plus for "+" at 6 (1:7), num for "2" at 7 (1:8), rpar for ")" at 8 (1:9)]

After the update the same string is lexed like:

[num@1 for "2" at 0 (1:1), num@2 for "+2" at 1 (1:2), num@3 for "*(2" at 3 (1:4), num@4 for "+2" at 6 (1:7), rpar@5 for ")" at 8 (1:9)]

+ in num token with regex "[\\d.]+(?:[eE]-?\\d+)?".toRegex() makes no sense, so there is regression.

By the way, replacing token function with regexToken produces same wrong behavior.

@h0tk3y h0tk3y closed this as completed in 68b42ad Jul 27, 2020
h0tk3y added a commit that referenced this issue Jul 27, 2020
The constructor stored the Regex instance passed to
it and did not prepend the input start marker. This
led to false matches found with some characters
skipped at the current position.

Fix #28
@h0tk3y
Copy link
Owner

h0tk3y commented Jul 27, 2020

Thanks @CommanderTvis for the report, I'll include the fix into the 0.4.1 update. As a workaround, you can use the regexToken(...) overload that accepts a String pattern, not Regex, as that overload was not affected.

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

No branches or pull requests

2 participants