Make the selection parser exception-proof.
The parser now catches and stores any exception that occurs during
parsing, terminates the parser cleanly, and rethrows the exception.
The functions called from the parser are still not exception-safe, and
would require quite some work to make so, because they are code written
originally in C and do a lot of dynamic memory allocation, returning
some of the allocated memory to the caller. But the generated code
should now work with exceptions.
Fixes #880.
Change-Id: I2d534d106a6fe20d949b3f24b0d7f9980c545fcf