-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Error: Indexing into an empty node #132
Comments
#[derive(logos::Logos)]
pub enum Token2 {
#[regex(r#"[!#$%&*+-./<=>?@\\^|~:]+"#)]
Operator,
#[error]
#[regex(r"/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*])*\*/", logos::skip)]
Error,
} Gives |
Your regex is very strange. (?x:
# (1) This entire block…
( [^\*]*
\*+
[^\*/]
)*
# (1) … is almost the exact same as this block. And both are optional.
( [^\*]*
\*+ # (2) Why `+ |` when you can do `*`?
| [^\*]
)*
) I think what you wanted was this? And in your So the »bug« for You can solve this in two ways, an elegant and a hack-y way:
|
I should have figured out this is going to be a problem. There was an issue before when the first thing inside a grouped repeat was a maybe: |
I think I may have modified the regex from this answer https://stackoverflow.com/a/36328890/2489366 so that it didn't need non-greedy matching since that caused ambiguities with LALRPOP. Then I just copied that into logos when adding comments. There may very well be a better way to write it in logos. The error is still poor, as noted so I didn't actually know what I were supposed to do to fix it :) |
Any panic in |
Famous last words. So I fixed the issue I thought this was relatively quickly, but the example you gave me will require a bit more digging. The operator and comment regexes overlap, and they are both looping. I've handled this case elsewhere quite gracefully, but Logos really doesn't like this example. That it panics is bad enough, but it panics after a long time, which means there is some crazy looping going on when merging the regexes. I'll make a release with the fix I have and #131, and get back to tracking this. Edit: shortly = almost two days ;P |
Released a fix in 0.11.3 ( |
Attempt to skip over
/* */
comments but I am getting an error which seems to be a bug. Similar to #97 I think as I were getting that error before reducing it.The text was updated successfully, but these errors were encountered: