Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to Create Sensible Debugging Information when Dynamically Typechecking Code Generated with camlp5 Quotations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] How to Create Sensible Debugging Information when Dynamically Typechecking Code Generated with camlp5 Quotations
Hi,

On Mon, Dec 17, 2007 at 01:11:09AM -0800, echinuz echinuz wrote:

> This contains no location information since Plot.Exc is not caught
> and handled in the same manner as it is during preprocessing.  I
> would like an error similar to the first case, when there were no
> quotations, to be shown in the second case, when there are
> quotations.

Ok, I understand your problem. It is indeed something missing in Camlp5.
I just added what is necessary and made a release. Download the latest
version (5.05) of Camlp5 at:
   http://pauillac.inria.fr/~ddr/camlp5/

I added a function "Pcaml.quotation_location" which returns the location
of the quotation text, relative to the source file, and usable in quotations
expanders.

Your code:

  let get_loc l=
    string_of_int (Ploc.line_nb l),
    string_of_int (Ploc.bol_pos l),
    string_of_int (Ploc.first_pos l),
    string_of_int (Ploc.last_pos l)

could be changed into:

  let get_loc l=
    let l =
      let qloc = Pcaml.quotation_location () in
      Ploc.shift (Ploc.first_pos qloc) l
    in
    string_of_int (Ploc.line_nb l),
    string_of_int (Ploc.bol_pos l),
    string_of_int (Ploc.first_pos l),
    string_of_int (Ploc.last_pos l)

Hope this helps.

-- 
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/