[MLton] confusing error message from MLton
Mon, 21 Jun 2004 12:18:44 -0700
> But, I don't know why the grammer isn't parsing the code with = as an
> infix. It seems like the following would be a valid parse:
> That is, parse the equals as infix, applied to fiba applied to 4 arguments
> and to the case expression.
Yes, your example is valid. It fails without the parens because case
expressions need to be parenthesized in an infix expression. Have a
look at the grammar on page 63 of the Definition.
> Presumably, the attempt to insert a VAL arises from the use of =.
Yeah, if you replace the "=" by "foo", then the parser quite
reasonably inserts a left paren just before the case expression. I
don't understand why "=" is treated differently, since it is a valid
longid in an infix expression. I don't have a good understanding of
how the error correction works in ML-Yacc works though.
Henry, if you want to take a closer look, in the ML-Yacc User's
Manual, section 1.3 talks about error recovery, and there is also a
reference to a TOPLAS paper on error recovery at the end of the
manual. In ml.grm, the error recovery is specified by the %change
directive, which says:
%change -> VAL | -> THEN | -> ELSE | -> LPAREN | -> SEMICOLON |
DARROW -> EQUALOP | EQUALOP -> DARROW | AND -> ANDALSO | COLON -> OF |
SEMICOLON -> COMMA | COMMA -> SEMICOLON |
-> IN LONGID END | -> ELSE LONGID
I guess that the first entry, "-> VAL" is responsible for the message.
I suspect that this entire directive is copied unchanged from SML/NJ's
parser. I've never had enough trouble fixing parse errors to make it
worth investigating further.