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

Consider adding ambiguity check for regexes #16

Open
matklad opened this Issue Nov 22, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@matklad

matklad commented Nov 22, 2018

Hi! LALRPOP’s lexer has a very cool feature: if two tokens have regexes with non-empty intersection language, then an error is reported, unless there’s an explicit precedence annotation as well. This helps a lot with producing correct lexers: after implementing a TOML lexer with LALRPOP, I’ve found an ambiguity in the lexer I’ve implemented for IntelliJ Rust:
https://github.com/intellij-rust/intellij-rust/pull/2426/files

It would be cool if logos had this feature as well!

@matklad

This comment has been minimized.

matklad commented Nov 22, 2018

For the reference, here’s the relevant bit from LALRPOP:

https://github.com/lalrpop/lalrpop/blob/28533afc7fe0ba653d015ba587e0cda52b0840c8/lalrpop/src/lexer/dfa/mod.rs#L39

The precedence thing is what determines if ambiguity is an errror or not.

@maciejhirsz

This comment has been minimized.

Owner

maciejhirsz commented Nov 22, 2018

Logos currently errors if two patterns can resolve to the same token. Adding precedence markers to make it resolve those situations should be possible, will need to think about how to reflect it on the API surface without adding too much bloat to the attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment