You should be using `parser.error` here instead of the `raise` statement.