[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Xavier Leroy <Xavier.Leroy@i...> |
| Subject: | Re: ocamlyacc and error recovery |
> 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