mrkkrp / parser-combinators

Lightweight package providing commonly useful parser combinators
Other
52 stars 15 forks source link

Expr unable to explicitly backtrack #28

Closed faucct closed 4 years ago

faucct commented 4 years ago

Hello. I am trying to describe a parser which would be able to return 1 in this case, so I could run it on remaining string, getting a sequence of tokens: 1 and +.

faucct commented 4 years ago

Okay, I guess I was not understanding the try semantics: try parser1 *> try parser2 /= try (parser1 *> parser2).

mrkkrp commented 4 years ago

You might want to take time to go through the tutorial: https://markkarpov.com/tutorial/megaparsec.html. It explains everything you need to know, including backtracking.