From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] How to Create Sensible Debugging Information when Dynamically Typechecking Code Generated with camlp5 Quotations
Date: Wed, 19 Dec 2007 10:50:32 +0100 [thread overview]
Message-ID: <20071219095032.GA4691@yquem.inria.fr> (raw)
In-Reply-To: <86496.88461.qm@web60123.mail.yahoo.com>
Hi,
On Tue, Dec 18, 2007 at 03:05:05PM -0800, echinuz echinuz wrote:
> That seems to have done the trick. Thanks for adding that function.
> The overall solution is a little awkward, so if you take requests,
> it would be nice if this process is streamlined in future versions.
> In other words, it would be nice if there was an easier way to pass
> through location information into the final AST and an easier way to
> throw errors with this information.
Ok, but I don't see, for the moment, what kind of function I can offer.
In the meantime, you can improve your code by building the functions:
let make_expr_loc loc =
let line_nb,bol_pos,bp,ep = get_loc loc in
<:expr<
(Ploc.make $int:line_nb$ $int:bol_pos$ ($int:bp$, $int:ep$),
$str:!Pcaml.input_file$)
>>
;;
let make_patt_loc loc =
let line_nb,bol_pos,bp,ep = get_loc loc in
<:patt<
(Ploc.make $int:line_nb$ $int:bol_pos$ ($int:bp$, $int:ep$),
$str:!Pcaml.input_file$)
>>
;;
and, therefore, your:
| PInt (loc,x)->
let line_nb,bol_pos,bp,ep=get_loc loc in
<:expr< Alg.Int (
(Ploc.make$int:line_nb$ $int:bol_pos$ ($int:bp$,$int:ep$),
$str:!Pcaml.input_file$),
$int:x$) >>
can be written:
| PInt (loc,x)->
<:expr< Alg.Int ($make_expr_loc loc$, $int:x$) >>
For antiquotations, notice that you can use named antiquotations. For
example, adding a case, in your grammar:
| x=ANTIQUOT "int"-> ...
allowing you to use $int:expr$ in your quotations, for an expression
of type int, and you can generate the good code with Alg.Int and a
correctly shifted location (without forgetting the "$int:" before the
expression). You can add a case for floats, and so on.
--
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/
next prev parent reply other threads:[~2007-12-19 9:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 21:22 echinuz echinuz
2007-12-15 15:47 ` [Caml-list] " Nicolas Pouillard
2007-12-15 19:32 ` echinuz echinuz
2007-12-16 16:50 ` Daniel de Rauglaudre
2007-12-17 10:54 ` Nicolas Pouillard
2007-12-17 3:29 ` echinuz echinuz
2007-12-17 5:28 ` Daniel de Rauglaudre
2007-12-17 9:11 ` echinuz echinuz
2007-12-17 12:41 ` Daniel de Rauglaudre
2007-12-18 23:05 ` echinuz echinuz
2007-12-19 9:50 ` Daniel de Rauglaudre [this message]
2007-12-15 16:54 ` Daniel de Rauglaudre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071219095032.GA4691@yquem.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox