Browse thread
Custom lexer in Camlp4
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2008-06-24 (15:16) |
From: | Richard Jones <rich@a...> |
Subject: | Re: [Caml-list] Custom lexer in Camlp4 |
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