Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Custom lexer in Camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-06-24 (17:03)
From: Yaron Minsky <yminsky@g...>
Subject: Re: [Caml-list] Custom lexer in Camlp4
You might want to take a look at an OSP project that is going on this summer
that is aiming to implement something rather similar to what you describe:


On Tue, Jun 24, 2008 at 11:16 AM, Richard Jones <> wrote:

> On Tue, Jun 24, 2008 at 03:30:23PM +0100, Jeremy Yallop wrote:
> > Ok, I've built a slightly modified clone of PreCast.  What's the best
> > way to persuade Camlp4 to use it?  The original PreCast seems fairly
> > hardwired, e.g. in the Register module.
> If you get an answer to this, please post it.  I would love to be able
> to add new integer literals to the language (0UL and so on).
> On a related note I had a crazy brainwave that we could use camlp4 to
> use 'ordinary' operators in an overloaded context.  Something like:
>  INT64 (2L * n / 3L)
> The INT64(expr) macro would inspect the AST of expr and change + ->
> Int64.add etc.  Of course one can do this using the pa_openin macro
> and a module which overrides (+) etc, but maybe this is better?  I was
> going to try modifying parts of virt-df to use this syntax to see if
> it would be beneficial.
> After writing virt-df which uses mixed int64, int32, int and int63[*]
> types I'm starting to come around to Jon's opinion that some limited
> overloading or type classes or whatever would be worthwhile.
> Rich.
> [*] int63 is my own type: It turns into an efficient int on 64 bit
> platforms, and is emulated on (now rare) 32 bit platforms.  It is
> necessary for virt-df because we want ints which can comfortably hold
> the size (in bytes / sectors / blocks / etc) of a block device.  You
> don't really need a 64 bit int for this, but you do need something
> which is bigger than 32 bits.
> --
> Richard Jones
> Red Hat
> _______________________________________________
> Caml-list mailing list. Subscription management:
> Archives:
> Beginner's list:
> Bug reports: