Implements handling for syntax errors and top-level errors.
- Adds test for syntax errors.
- Adds test for top-level errors.