Skip to content

Parser issue while parsing C code #1113

Answered by louthy
pth14 asked this question in Q&A
Sep 17, 2022 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

The main thing to note is that all parsers have one of four result states:

  • Consumed Success - the parser succeeded
  • Consumed Failure - the parser parsed some tokens, but failed midway through
  • Empty Success - the parser succeeded without parsing anything (this can happen with empty lists, for example)
  • Empty Failure - the parser failed without parsing anything

Imagine this:

var p = either(str("Hello"), str("Hi"));

If you try to use the parser p with the string "Hi" , it won't succeed, even though it's given as a valid option. It's because when trying the first parser str("Hello"), it would get to the 'e' and fail. This is a Consumed Failure. The parsec library won't automatically rewind to…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@pth14
Comment options

@pth14
Comment options

@louthy
Comment options

@pth14
Comment options

@pth14
Comment options

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