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

Maybe a bug #277

Open
lylythechosenone opened this issue Jan 16, 2023 · 0 comments
Open

Maybe a bug #277

lylythechosenone opened this issue Jan 16, 2023 · 0 comments

Comments

@lylythechosenone
Copy link

I have a doc comment token, that uses the following regexes:

  • ///[^\n]*
  • /\*\*([^\*]|\*[^\*/]|\*\*[^/])*\*?\*/

As well as a regular comment token, that skips the following regexes:

  • //[^\n]*
  • /\*([^\*]|\*[^/])*\*/

And for some reason, these tests pass:

// first test
let input = "// hello world
/* hello world */
/// hello world doc
/** hello world doc **/";
let mut lexer = Token::lexer(input);
assert_eq!(lexer.next(), Some(Token::Doc("hello world doc")));
assert_eq!(lexer.next(), Some(Token::Doc("hello world doc")));

// second test
let input = "// hello world
/* hello world */
/// hello world doc
/** hello world doc */
";
let mut lexer = Token::lexer(input);
assert_eq!(lexer.next(), Some(Token::Doc("hello world doc")));
assert_eq!(lexer.next(), Some(Token::Doc("hello world doc")));

While this one doesn't:

let input = "// hello world
/* hello world */
/// hello world doc
/** hello world doc **/
";
let mut lexer = Token::lexer(input);
assert_eq!(lexer.next(), Some(Token::Doc("hello world doc")));
assert_eq!(lexer.next(), Some(Token::Doc("hello world doc")));

In this last one, the multiline comment is turned into an Error.

My lexer

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