caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlyacc and error recovery
@ 1997-02-20 19:11 David Monniaux
  1997-02-24 10:50 ` Xavier Leroy
  0 siblings, 1 reply; 2+ messages in thread
From: David Monniaux @ 1997-02-20 19:11 UTC (permalink / raw)
  To: Caml-list

[ ENGLISH AT BOTTOM OF MESSAGE ]

J'ai un petit probleme avec ocamlyacc lorsque je veux pouvoir gerer les
erreurs. Je n'arrive pas a utiliser le pseudo-token "error". La
documentation de caml est tres breve a ce sujet et renvoie aux documents
sur yacc... qui traitent de yacc pour le langage C et ne disent evidemment
pas comment rattraper les erreurs sous ocamlyacc!

J'ai toujours une exception Parse_error qui n'est jamais rattrapee.
Quelqu'un sait-il comment utiliser le token "error"?

[=== ENGLISH ===]

I have a small problem with ocamlyacc when I want to handle errors. I
can't get the "error" token to work. The caml documentation is very terse
on the subject and points to standard texts about yacc... which deal with
C-language yacc, not the particular points of ocamlyacc.

I always have an uncaught Parser_error exception. Does anyone know how to
handle the "error" token?

Si l'informatique marchait, cela se saurait."
http://www.ens-lyon.fr/~dmonniau






^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ocamlyacc and error recovery
  1997-02-20 19:11 ocamlyacc and error recovery David Monniaux
@ 1997-02-24 10:50 ` Xavier Leroy
  0 siblings, 0 replies; 2+ messages in thread
From: Xavier Leroy @ 1997-02-24 10:50 UTC (permalink / raw)
  To: David Monniaux; +Cc: caml-list

> I have a small problem with ocamlyacc when I want to handle errors.
> I always have an uncaught Parser_error exception. Does anyone know how to
> handle the "error" token?

The first thing to do is to define a function called "parse_error" in
the header section of the grammar:

%{
let parse_error msg =
  print_string msg
%}

That will allow error recovery to be initiated. (According to the
documentation, defining this function is optional; there is a bug in
the current implementation that makes it necessary.)

Once this is done, "error" rules should work as described in the Yacc
books.

- Xavier Leroy





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-02-24 18:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-20 19:11 ocamlyacc and error recovery David Monniaux
1997-02-24 10:50 ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).