You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use logos::Logos;use regex::Regex;#[derive(Logos,Clone,Debug,PartialEq)]pubenumLogosToken{#[regex(r"(?m)\(\*([^*]|\*+[^*)])*\*+\)")]Comment,#[error]Error,}fnmain(){let test = "(* hello world *)";let r = Regex::new(r"(?m)\(\*([^*]|\*+[^*)])*\*+\)").unwrap();assert!(r.is_match(test));letmut lexer = LogosToken::lexer(test);assert!(matches!(lexer.next(), Some(LogosToken::Comment)));}
As you can see, the same regex is being used and the same test string but, the first assert passes and the second panics. I'm not sure if I'm missing something or this is a bug
The text was updated successfully, but these errors were encountered:
@jawadcode see this really useful discussion on regexs for comments: #133
Also, I think ?m means multiline mode. If that's the case, one way you could solve this instead is by using separate tokens for (* and )*. Then, use extras to keep track of when a comment begins and ends. Everything in between is part of that comment only if a comment has begun.
Firstly, here is the output of
cargo tree
:And here is code that demonstrates the issue:
As you can see, the same regex is being used and the same test string but, the first assert passes and the second panics. I'm not sure if I'm missing something or this is a bug
The text was updated successfully, but these errors were encountered: