[MLton-user] How ml-yacc works with the "error" token.

Rodrigo Saad digaots at gmail.com
Mon Jan 15 02:14:47 PST 2007

Thankyou Matthew for the answer.
About the lookahead parameter, I had already tried to set the
parameter to zero but i was not  able to recover the parser after an
error point. The parser had deleted all the tokens that came after the
error point and for this reason i am trying to use the "error" token,
like others Yacc's implementation, to suggest where an error is
expected to happen.
Usually the error token is provided by yacc to allow the user some
control over the parser process.
I don't know any other way to recover the parser but i am open for any
kind of idea.
Rodrigo Saad

On 1/15/07, Matthew Fluet <fluet at tti-c.org> wrote:
>  > I am developing a compiler with ml-yacc and i would like to know how
>  > the report errors works.
> The error recovery mechanism in ml-yacc is derived from:
>          'A Practical Method for LR and LL Syntactic Error Diagnosis and
>           Recovery', by M. Burke and G. Fisher, ACM Transactions on
>           Programming Langauges and Systems, Vol. 9, No. 2, April 1987,
>           pp. 164-197.
>  > I don't wanna permit any kind of correction (deletion, insertion, ...)
>  > by the compiler, the only thing i want is that every time the compiler
>  > detects an error, it reports the "statement" where that error occurred
>  > and then it continues parsing as if the discarded token was really a
>  > valid "statement".
> A careful reading of the ml-yacc manual reveals some suggestions:
> "The algorithm uses a parse check to evaluate corrections. A parse check
> is a check of how far a correction allows a parser to parse without
> encountering a syntax error. You pass an upper bound on how many tokens
> beyond the error point a parser may read while doing a parse check as an
> argument to the parser. This allows you to control the amount of
> lookahead that a parser reads for different kinds of systems. For an
> interactive system, you should set the lookahead to zero. Otherwise, a
> parser may hang waiting for input in the case of a syntax error. If the
> lookahead is zero, no syntax errors will be corrected."
>  > I searched over the web and i didn't find anything about the use of
>  > the "error" token by the ml-yacc.
> I don't believe that the error token is a distinguished token; rather in
> a given attempted parse, the token at which a parse error is discovered
> is an "error token".

More information about the MLton-user mailing list