From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 06518BBC1 for ; Sun, 6 Apr 2008 19:34:54 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAPam+EfAXQIn/2dsb2JhbAClDYQU X-IronPort-AV: E=Sophos;i="4.25,612,1199660400"; d="scan'208";a="11136985" Received: from concorde.inria.fr ([192.93.2.39]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Apr 2008 19:34:53 +0200 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m36HYrME005599 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 6 Apr 2008 19:34:53 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApcEAGem+EdIDvydZmdsb2JhbACRVA0EAwUJkxWEFA X-IronPort-AV: E=Sophos;i="4.25,612,1199660400"; d="scan'208";a="9258808" Received: from po-out-1718.google.com ([72.14.252.157]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Apr 2008 19:34:52 +0200 Received: by po-out-1718.google.com with SMTP id y22so1582436pof.2 for ; Sun, 06 Apr 2008 10:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=ORJnuMsPgvQbQy7/HnC6wKj9UuGOhLsjYQMniE80B2I=; b=dUBf+katlPgOmefVbxSwr5oOtSu5ajMHW8rHQGeHx0KBYBRbmdNimmnbBiU9flkV85aMRjAdPzvev16bWfk4HWCZBtCQ1UvtLmheshAoD+oqmVEtnTyspeCS2xcIeK/tcwPoZ6UXG3Lr8Sx3yef05t7Mhbl8RjOH7dZOztu4yuU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=VwDWfT4pv372hwZ4JS6Z6j4e+Z9lUzVlbO3dVhcEWxHVQGJjFVPoWBW7oHyctcNe5/v3lj3QZnJr+XN01DtLjVNcCqwR2zpru9MTVf9hpXPAs+r+C+dQZeJctbCgLPRd3WDh6xdKWXjNG5Qo3hzo1ZtgEwmSwok0ykjR1p6FqLE= Received: by 10.140.191.14 with SMTP id o14mr1188398rvf.78.1207503290435; Sun, 06 Apr 2008 10:34:50 -0700 (PDT) Received: by 10.140.131.10 with HTTP; Sun, 6 Apr 2008 10:34:50 -0700 (PDT) Message-ID: <666572260804061034k3c1f1bc6l6b7ce8f02cfebb15@mail.gmail.com> Date: Sun, 6 Apr 2008 19:34:50 +0200 From: Adrien To: "Richard Jones" Subject: Re: [Caml-list] Operators for Int64 and Int32 Cc: caml-list@inria.fr In-Reply-To: <20080404210725.GA13391@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <906164100804030708p3e2788a0p29b69f4d46600622@mail.gmail.com> <20080404071729.154e130e.mle+ocaml@mega-nerd.com> <20080403221704.GA31402@annexia.org> <20080404124729.460bc323.mle+ocaml@mega-nerd.com> <666572260804041058hdf6e6aclf52cc8a1ee812090@mail.gmail.com> <20080404210725.GA13391@annexia.org> X-Miltered: at concorde with ID 47F909BD.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 0200,:01 translated:01 camlp:01 ocaml:01 wiki:01 hashtbl:01 hashtbl:01 chunks:01 fmt:01 fmt:01 wrote:01 rec:01 parsing:01 parsing:01 assert:01 2008/4/4, Richard Jones : > On Fri, Apr 04, 2008 at 07:58:00PM +0200, Adrien wrote: > > As for my library (I'm sure someone will ask about it), it is > > basically used like Bitmatch. When I saw the Bitmatch release, I > > translated Richard's examples to my library. I took me a few minutes. > > It would benefit from some sugar but I don't know camlp4 (yet). > > > > If you want you can have a look at the examples here : > > http://ocaml.yaxm.org/wiki/doku.php?id=binary_parse#examples > > > I guess the advantage of bitmatch is matching against several cases. > In fact the pa_bitmatch extension generates a really large amount of > code in some cases. The EXT3 case generates this: > > http://www.annexia.org/tmp/ext3.txt > > 1814 lines of code from just 76 lines of source, ouch :-) Well, most > of it is optional debugging statements ... Well the approach is different as I'm not generating code but I'm pretty sure our two libraries are similar in their use. This is an excerpt from the wave parsing example : let rec parsing_list_of_chunk_id hashtbl= match Hashtbl.find hashtbl "next_chunk_id" with |S "fmt "->wav_format_chunk |S "data"->wav_data_chunk |_->assert false and type_of_riff_chunk hashtbl= match Hashtbl.find hashtbl "type" with |S "WAVE"->[input_string 4, "next_chunk_id", Some (parsing_list_of_chunk_id)] |_->raise Unknown_type Wave (1) has many is composed of chunks, among which "fmt " and "data". The first function decides which chunk comes next according to the ID written in the file and the second decides whether the riff file contains a wave part or not (i.e. are we really parsing a wave file) . So it is also possible to match against several cases. (1) : in fact RIFF, the names were chosen when I did not really know what belonged to riff and what belonged to wave And btw, this has been enough to successfully parse tens of wave files over the six past months. Fortunately most wave files are simple. > > I'll probably make some release this week-end if I find enough time (I > > already have to get a new ID card as mine has just been stolen). > > > But our Home Secretary "Wacky" Jacqui Smith assured us that we'll all > be safe with ID cards and all crime will cease!?! Don't forget the security cameras, except when they're pointed in the other direction... --- Adrien Nader