caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Dan Bensen <danbensen@att.net>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] analyzing Camlp4 nodes
Date: Fri, 13 Jul 2012 12:12:20 +0200	[thread overview]
Message-ID: <CAPFanBHvuh7e72TqUyVBYteZJ_66m_AxtE-cgHS+M+7hDJyBFw@mail.gmail.com> (raw)
In-Reply-To: <1342169284.53181.YahooMailRC@web180016.mail.gq1.yahoo.com>

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.

  reply	other threads:[~2012-07-13 10:13 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 [this message]
2012-07-13 10:24   ` Wojciech Meyer
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=CAPFanBHvuh7e72TqUyVBYteZJ_66m_AxtE-cgHS+M+7hDJyBFw@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=danbensen@att.net \
    /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).