inhabitedtype/angstrom

Extracting source locations

nholland94 opened this issue · 1 comments

Hello. I am interested in being able to extract locations from the combinators in this library. It seems like there isn't a way to really do this as of now (if I understand correctly). However, it seems like it would be possible to create a new operator that works like >>| but also passes in the position before and after the parser on the left hand side was run (in the current source code for >>|, pos and pos' in succ'). Would this be something this library would be interested in including? And, if so, what should the operator be? Maybe something like >>||?

I can PR this change if it acceptable.

Thanks for opening the issue. I believe what you're looking for is the pos. This will return the current position, in bytes. This is not part of the public API because I want to discourage its use. However, I don't think it will go away any time soon, if ever.