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

Consider generating a warning (with an option to suppress) for rules that accept empty string #65

Open
osa1 opened this issue Sep 13, 2023 · 0 comments

Comments

@osa1
Copy link
Owner

osa1 commented Sep 13, 2023

Recently I debugged a lexer with this rule:

("0b" | "0o" | "0x")? ($digit | '_')* $id? = ...,

This regex accepts empty string, so the lexgen state never failed and instead looped when it's supposed to fail.

Now, I've never needed this in a lexer, but this kind of rule can be used to switch to another state on failure, so I guess it's not completely useless. However I suspect for the majority of the use cases it actually means a bug in the lexer, so perhaps it makes sense to generate a warning for rules that accept empty strings, with a pragma to explicitly suppress the warning.

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

1 participant