Quite right. But antlr is better for query parsing. They also have error listeners so error handling can be added.