Improve input parsing to be more robust
Add badly formatted grammar to test robustness