Skip to content

Parser signature to accept tokens #621

Answered by zesterer
Flone-dnb asked this question in Q&A
Discussion options

You must be logged in to vote

First, spanned requires an argument

As mentioned in the docs, spanned expects you to pass it an 'end of input' span. This is a span (usually zero-width, although there's no specific need for that to be the case) that sits just beyond the last element of the input. For example, if you're parsing a string, my_str.len()..my_str.len() would do just fine. The reasons for this are an annoying implementation detail, but it basically comes down to the fact that it's possible for an input to produce no tokens but still need to somehow generate a span.

and the parser still has some errors, I've tried fixing some errors

I mentioned that it's a good idea to make your parser generic over the input…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@zesterer
Comment options

Answer selected by Flone-dnb
@Flone-dnb
Comment options

@zesterer
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants