kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
805 stars 95 forks source link

Fetching position inside of the transformer #188

Closed khash closed 6 years ago

khash commented 6 years ago

Apologies for asking a question here, but it seems the http://dir.gmane.org mailing list is not working anymore (links to archive don't work) and I can't find any place to ask questions about Transformers, hence this Issue in the repository.

I would like to be able to show the line number / position of an error that's happening inside of a transformer. For example, the type of an argument passed into the transformer might be wrong (string as opposed to an integer). While the transformer can raise an exception, it can be very helpful to include the position in the exception as well.

Is there a way to achieve this?

kschiess commented 6 years ago

https://kschiess.github.io/parslet/tricks.html

...a really discourteous place to ask for help.

khash commented 6 years ago

Thank you for taking the time to comment @kschiess Would you mind pointing me to where you have mentioned a place to ask for help courteously please, for anyone else having a question? I tried the mailing list and it went into a blackhole, tried searching the mailing list archives to see if anyone has asked for this or not. I also read the link you sent me and while it talks about positions in parsers it doesn't talk about it in transformers. The only way I could think of was to create a dummy error handler to capture the positions so they can be retrieved if needed by a transformer.