The MySQL parser is built with bison/flex.
When an error occurs, the application layer (MySQL in that case) has very inaccurate information about why the parsing failed and it is difficult to give better reporting to the user than is currently does.
Considers a simple calculator and a parenthesis error like:
( ... (.....)
Where the second parenthesis is missing? You need a human brain to answer that question since localizing the error means being able not only to understand the syntax but also the content being processed. A parser will just see that at the end of the statement to process, the count of parenthesis is wrong and report the error. It can't do better, even if the statement is very large, that's why when coding in C (or other languages), if you made some error about parenthesis or braces, the compiler may give totally wrong information.
Consider this:
select from mytable where s=''and r=''';
Where is the mistake? Did I incorrectly used ' instead of " for the whole where clause because I wanted to have:
select from mytable where s="'and r=''";
Maybe I wanted this:
select from mytable where s=''and r='';
The later seems possible to a humain brain, because a human brain knows that chances are low that the content of an attribute looks like part of a SQL statement. But for a parser, this would mean reparsing the content of what was not understood, which is quite paradoxical. And the human brain could be wrong, maybe my application was processing data entered by someone that entered weird strings in a web form.
So maybe the MySQL parser can be improved but I don't think that the result obtained will be worth the effort.