From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 46BB07FADB for ; Thu, 6 Nov 2014 18:21:58 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of rlepigre@gmail.com) identity=pra; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rlepigre@gmail.com"; x-sender="rlepigre@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of rlepigre@gmail.com designates 209.85.212.173 as permitted sender) identity=mailfrom; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rlepigre@gmail.com"; x-sender="rlepigre@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f173.google.com) identity=helo; client-ip=209.85.212.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="rlepigre@gmail.com"; x-sender="postmaster@mail-wi0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugEANCtW1TRVdStm2dsb2JhbABbFoNMWYMGyBuBYYcTFgEBAQEBEQEBAQEBBgsLCRQuhAMBAQMBEhEPAQ0BOAEDAQsBBQUaAgUMFQICDwUgAQUBIjWICgMJCQQBCK0tPTGLM4FugxeJXicNhjEmAQUOgR+PdYJtNoEeBZMwg0WHHoFwkm5BgXaDPmuCSwEBAQ X-IPAS-Result: AugEANCtW1TRVdStm2dsb2JhbABbFoNMWYMGyBuBYYcTFgEBAQEBEQEBAQEBBgsLCRQuhAMBAQMBEhEPAQ0BOAEDAQsBBQUaAgUMFQICDwUgAQUBIjWICgMJCQQBCK0tPTGLM4FugxeJXicNhjEmAQUOgR+PdYJtNoEeBZMwg0WHHoFwkm5BgXaDPmuCSwEBAQ X-IronPort-AV: E=Sophos;i="5.07,327,1413237600"; d="scan'208";a="105296454" Received: from mail-wi0-f173.google.com ([209.85.212.173]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 06 Nov 2014 18:21:32 +0100 Received: by mail-wi0-f173.google.com with SMTP id n3so2197212wiv.0 for ; Thu, 06 Nov 2014 09:21:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=/OL3zUNOIRNfN7/HNJtlMN7OUaWsUQevugGdXThOhKA=; b=O/u+rUBJtKGF4fv8cEf9ZnpmaT4It/KuhZ6cqomGZmMQ0k+gzjUkHS3/YW5Oe/XF0W uAEavugBgn+FogABsAqrUCJyDwM2NdKH0q2m+lZDsQjHHl4YQurfJX6v2PQL9zX6QgYx /1zw7Kyn3eegBt0+2xHI/GIw01FNecBeK2gM2ASjQ4st5TxBz2TWXILuPh6IC2nGzPNP GdZaM5Ma5c5nb9Eg4QDXHKVliJd49G6Wh31nU6xAeCciO1KYPuQ5ZR+QIk9v5bW/A2J+ Y5fpKisIyOz/IdSHPAj/EaG1v69BnS+khm0l/fdLh/0ib/M25aR+gEhGKsSM+FqdjXZM bM3A== X-Received: by 10.194.19.4 with SMTP id a4mr7606401wje.3.1415294491978; Thu, 06 Nov 2014 09:21:31 -0800 (PST) Received: from localhost (nat-maths.univ-savoie.fr. [193.48.123.14]) by mx.google.com with ESMTPSA id ud9sm8584588wjc.20.2014.11.06.09.21.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Nov 2014 09:21:31 -0800 (PST) Sender: Rodolphe Lepigre Date: Thu, 6 Nov 2014 18:21:30 +0100 From: Rodolphe Lepigre To: Christoph =?utf-8?B?SMO2Z2Vy?= Cc: caml users Message-ID: <20141106172130.GA32182@HPArchRod> References: <545BAA3D.5070606@tu-berlin.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <545BAA3D.5070606@tu-berlin.de> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [Caml-list] Parsetree comparison Hi, > is there a way to compare two abstract syntax trees for equality > without taking into account locations? Or rather a way to stratify the > location information inside a parsetree? I want to unit-test a parser > that invokes the OCaml parser itself. One quick, dirty and hackish way to do that is to use the -dparsetree option to print the parse tree, use sed to remove position indication and the compare files with diff... I used that trick to compare the ast generated by an OCaml parser generated using DeCaP (http://lama.univ-savoie.fr/decap/), and the ast generated by other OCaml parsers. Here is the script we used: ########## #!/bin/bash ocamlc -dparsetree $1 2> /tmp/$1.ocaml ocamlc -dparsetree -pp ../pa_ocaml $1 2> /tmp/$1.pa_ocaml cat /tmp/$1.ocaml | sed -e 's/(.*\.ml\[.*\]\.\.\[.*\])\( ghost\)\?//' > /tmp/$1.ocaml.out cat /tmp/$1.pa_ocaml | sed -e 's/(.*\.ml\[.*\]\.\.\[.*\])\( ghost\)\?//' > /tmp/$1.pa_ocaml.out # diff -y /tmp/$1.ocaml.out /tmp/$1.pa_ocaml.out | less diff $2 /tmp/$1.ocaml.out /tmp/$1.pa_ocaml.out ########## Regards, Rodolphe -- Rodolphe Lepigre LAMA, Université de Savoie, FRANCE http://lama.univ-savoie.fr/~lepigre/