Improvements to the parser to (more) graciously handle errors.

This was supposed to be 2 commits, but got merged due to wrong patch manipulations.

1) Update the parser code to graciously return on error.
Having the program crash when the parser fails to parse the regular
expression is not acceptable for the user.

2)Move the parsing stage earlier to allow regexp validataion and error checking.
The parsing is done when the Regej is created, allowing the user to check if
the regular expression was correct.