Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Operators for Int64 and Int32
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Adrien <camaradetux@g...>
Subject: Re: [Caml-list] Operators for Int64 and Int32
2008/4/4, Richard Jones <rich@annexia.org>:
> 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