caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Adrien <camaradetux@gmail.com>
To: "Richard Jones" <rich@annexia.org>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Operators for Int64 and Int32
Date: Sun, 6 Apr 2008 19:34:50 +0200	[thread overview]
Message-ID: <666572260804061034k3c1f1bc6l6b7ce8f02cfebb15@mail.gmail.com> (raw)
In-Reply-To: <20080404210725.GA13391@annexia.org>

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


      reply	other threads:[~2008-04-06 17:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-03 14:08 Michał Maciejewski
2008-04-03 15:24 ` David Allsopp
2008-04-03 15:44   ` Bünzli Daniel
2008-04-03 19:00   ` David Thomas
2008-04-03 19:50   ` Michał Maciejewski
2008-04-03 22:22     ` Jon Harrop
2008-04-03 17:15 ` Richard Jones
2008-04-03 20:17 ` Erik de Castro Lopo
2008-04-03 20:39   ` Michał Maciejewski
2008-04-03 22:02     ` Erik de Castro Lopo
2008-04-03 22:17   ` Richard Jones
2008-04-04  1:47     ` Erik de Castro Lopo
2008-04-04 17:58       ` Adrien
2008-04-04 21:07         ` Richard Jones
2008-04-06 17:34           ` Adrien [this message]

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=666572260804061034k3c1f1bc6l6b7ce8f02cfebb15@mail.gmail.com \
    --to=camaradetux@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=rich@annexia.org \
    /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).