-
Hi, I have a lexer with the following code: pub type Span = SimpleSpan<usize>;
pub type Spanned<T> = (T, Span);
pub fn lexer<'src>() -> impl Parser<
'src, &'src str, Vec<Spanned<Token>>, extra::Err<Rich<'src, char, Span>>
> {
choice((
comment(),
literal(),
keyword(),
operator(),
punctuation(),
))
.map_with(|tok, info| (tok, info.span()))
.padded()
// .recover_with(skip_then_retry_until(any().ignored(), end()))
.repeated()
.collect()
} When I have an empty code file: I suspect this happens because the empty string
Any help is appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I believe this would work fine if you add a |
Beta Was this translation helpful? Give feedback.
I believe this would work fine if you add a
.padded()
after repeated. This should allow whitespace surrounding the item repeated, even if it’s repeated 0 times.