> In general, you are right; the problem is that I do not have access
> to the location in the source code where the exception happened. I'm
> interested in the line number and the file name of the statement
> that originally caused the exception. Example:
It should be easy to do with camlp4, since locations in sources are
bound in the right hand sides of grammar rules. Thus, you just have to
overwrite the syntax of raise so that it actually raises the exception
together with its location, in an exception looking like
exception LocatedException of exn * (int * int);;
Then, when you want to debug your program, you compile it with camlp4
and that little extension, instead of ocamlc.
I'm not expert enough in the use of camlp4 to give the code for this
extension (by the way, there is no quotation for raising exception, as
far as I looked in the manual) but I'm sure that's no more than two or
three lines of code. And I don't know if the current file name being
parsed can be accessed. Surely Daniel will be of some help here if you
ask him.
--
Jean-Christophe Filliatre
Computer Science Laboratory Phone (650) 859-5173
SRI International FAX (650) 859-2844
333 Ravenswood Ave. email filliatr@csl.sri.com
Menlo Park, CA 94025, USA web http://www.csl.sri.com/~filliatr