3 ms·
I thought most of these errors could be handled with the error construct in Bison? I suppose most errors tend to get written as "Unexpected TOKEN, expected OTH
by Periodic 17y ago
I thought most of these errors could be handled with the error construct in Bison? I suppose most errors tend to get written as "Unexpected TOKEN, expected OTHER_TOKEN."
If you're willing to complicate your grammar a bit you can add productions for a lot of the erroneous situations which could arrise with nice error messages, such as:
for_init := ...
| var error { error("var not allowed in for initializer."); }
My syntax is a bit off, but can't all syntax errors be expressed with the CFG and be given errors as semantic actions?