fix: bad parsing of comments at end of file closes #551

This commit is contained in:
rvcas
2023-05-30 11:07:39 -04:00
parent c3b8ff0009
commit 26a607eb00
3 changed files with 23 additions and 2 deletions

View File

@@ -148,13 +148,13 @@ pub fn lexer() -> impl Parser<char, Vec<(Token, Span)>, Error = ParseError> {
// NOTE: The first case here work around a bug introduced with chumsky=0.9.0 which
// miscalculate the offset for empty comments.
just("/".repeat(n))
.ignore_then(text::newline().rewind())
.ignore_then(choice((text::newline().rewind(), end())))
.to(token.clone())
.map_with_span(move |token, span: Span| {
(token, Span::new((), span.start + n..span.end))
}),
just("/".repeat(n)).ignore_then(
take_until(text::newline().rewind())
take_until(choice((text::newline().rewind(), end())))
.to(token)
.map_with_span(|token, span| (token, span)),
),