[antlr-interest] [antlr-dev] BitSets

Stuart Dootson stuart.dootson at gmail.com
Wed Jun 6 12:25:44 PDT 2007


Luke - I've had a reasonable amount of Ada experience (real-time,
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,
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.

HTH.

Stuart Dootson


More information about the antlr-interest mailing list