Skip to content

Parser combinaison #27

Closed Answered by stephencelis
mackoj asked this question in Q&A
Feb 22, 2021 · 2 comments · 3 replies
Discussion options

You must be logged in to vote

@mackoj You're close! I think the problem is that your input has multiple new lines before the comments and your separator is Newline(), which will only attempt to parse a single one. Changing the separator to Many(Newline()) might fix things, or even just Whitespace().

One other suggestion would be to avoid PrefixThrough and PrefixUpTo when using skip with parsers, since in this case it may have made things more difficult to debug. Instead you could be very explicit in what you want to match. This is just a sketch so not sure if it's exactly what you want, but something like this:

let comment = StartsWith("/*".utf8).take(PrefixUpTo("*/".utf8)).skip(StartsWith("*/".utf8))
let literal = St…

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
@mackoj
Comment options

@mackoj
Comment options

@stephencelis
Comment options

Answer selected by mackoj
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