[antlr-interest] [antlr-dev] BitSets

Luke A. Guest laguest at archangeli.co.uk
Wed Jun 6 14:04:31 PDT 2007


On Wed, 2007-06-06 at 20:25 +0100, Stuart Dootson wrote:
> Luke - I've had a reasonable amount of Ada experience (real-time,

Good to know there's somebody else here that uses (or has used) Ada ;D

> safety critical embedded systems) - I would have thought the idiomatic
> way to do a bitset in Ada would be a packed (using pragma pack) array
> of Booleans? If you declare this to be constant, with an initialiser,

Yeah, I did mention this on the dev ml.

> then GNAT (the only Ada compiler I've had recent experience of) should
> code that up without any elaboration code - in an embedded system, it
> would be ROM-able.
> 
> Something like:
> 
> type Bits132Type is array(Integer range 1..132) of Boolean;
> pragma Pack(Bits132Type);
> for Bits132Type'Size use 132;
> Bit_Set : constant Bits132Type := Bits132Type'(1 => True, 2 => False,
> 3 => True, 4 => True, others => False);
> 
> 
> I don't think you'd need dynamically resizable arrays for Antlr
> bitsets - I think their size is fixed @ code-generation time? If
> that's the case, then you can just fix the array size at compile time.

For both the dynamic and static cases, I think it would be possible to
implement using the same type and some representation clauses (maybe).

Lemme think about it some more and I'll post back.

Thanks,
Luke.




More information about the antlr-interest mailing list