caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: Gabriel Scherer <gabriel.scherer@gmail.com>
Cc: Dan Bensen <danbensen@att.net>, caml-list@inria.fr
Subject: Re: [Caml-list] analyzing Camlp4 nodes
Date: Fri, 13 Jul 2012 11:24:03 +0100	[thread overview]
Message-ID: <CAOg1smAXQWxBOa8SJO54zGrmaMQ9q7E0GNr03KJjy7LFMxD1-A@mail.gmail.com> (raw)
In-Reply-To: <CAPFanBHvuh7e72TqUyVBYteZJ_66m_AxtE-cgHS+M+7hDJyBFw@mail.gmail.com>

There is Camlp4LocationStripper.ml filter in Camlp4/Filters.

On Fri, Jul 13, 2012 at 11:12 AM, Gabriel Scherer
<gabriel.scherer@gmail.com> wrote:
> I'm sorry but I don't understand your question.
> What do you mean by "comparing" ast nodes? Is it an equality/ordering
> test between the node as OCaml values?
> I don't understand what you mean by the idea of "a quotation and
> another quotation" having "the same location".
> Maybe a concrete example would be clearer.
>
> If your question is: how do I text that two pieces of ASTs are equal
> *modulo* the location (the term structure is the same but the
> locations are allowed to be different), then you can do that by
> erasing the locations. Untested code:
>
>   let strip_locations = Ast.map_loc (fun _ -> Loc.ghost)
>   let equal_modulo_loc a b = (strip_locations a) = (strip_locations b)
>
> On Fri, Jul 13, 2012 at 10:48 AM, Dan Bensen <danbensen@att.net> wrote:
>>
>> Is there a way to compare a Camlp4 ast node to a quotation
>> that ignores the locations?
>> Camlp4 seems to rely on quotations as much as possible,
>> but it seems like you have to either compare a quotation
>> with another quotation, so they have the same location,
>> or write out the ast code explicitly.
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>

  reply	other threads:[~2012-07-13 10:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13  8:48 Dan Bensen
2012-07-13 10:12 ` Gabriel Scherer
2012-07-13 10:24   ` Wojciech Meyer [this message]
2012-07-13 11:10   ` Dan Bensen

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=CAOg1smAXQWxBOa8SJO54zGrmaMQ9q7E0GNr03KJjy7LFMxD1-A@mail.gmail.com \
    --to=wojciech.meyer@googlemail.com \
    --cc=caml-list@inria.fr \
    --cc=danbensen@att.net \
    --cc=gabriel.scherer@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).