-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add possibility for pegtl::control to not throw exception on global error #40
Comments
Thanks for the feedback! Regarding your issue, are you sure that the try-catch is a performance problem? With most modern compilers a try-catch has zero (!) performance cost as long as no exception is thrown. |
Also, if you don't use any of the |
afaik, try/catch costs some even if no exception is thrown, but you are right that the cost is near zero. Still the problem is that pegtl is used in inner loop of message processing deep inside chained FSMs since the decoding is lazy for performance reasons. Thus I just can't have one outer try/catch block (wish it would be an opposite case as I like exceptions for exceptional cases). Yet again, it's questionable whether malformed text is an exceptional case or not. |
It really is zero cost, for example look at page 40 of this technical report which says that "All associated run-time costs occur only when an exception is thrown." Windows 64bit, and GCC and Clang, should all do this. |
I'm not sure you understood Colin's second comment completely: If you do not use Is this sufficient in your case or are you bound to some given grammar that is using the above rules? |
Hi! I did understand the must usage and thanks a lot for pointing this out. |
Great, so I'll close this issue for now, but feel free to contact us again here if there is anything that needs clarifying or that doesn't work... |
Thanks a lot guys! Lightning fast support and valuable/true help! |
Many, many thanks to your brilliant code!
Just discovered it and it seems to be a killer solution for my task.
However I need to parse messages and can't afford to wrap decoding in try/catch blocks since it's costly. Rather would be enough to get true/false from parse. Perhaps I couldn't find it in docs but trying to provide custom control doesn't help since the PEGTL code will call std::abort if no exception thrown.
Could you please consider some control policy to inhibit exceptions?
The text was updated successfully, but these errors were encountered: