rsmmr / hilti

**NOTE**: This is outdated and no longer maintained. There's a new version at https://github.com/zeek/spicy.
Other
40 stars 22 forks source link

Add more comparision operators for enum labels #10

Open blipp opened 8 years ago

blipp commented 8 years ago

It would be useful to have more possibilities to compare enum labels. Currently, only a test for equality is supported (==). > and < would be useful for some cases, for example the following, where a range of numbers defined in an enum needs to be queried:

type ExampleEnum = enum {
  # ...
  Foo1 = 0xFEFC,
  Foo2 = 0xFEFD,
  Foo3 = 0xFEFE,
  Foo4 = 0xFEFF,
  # ...
};

type ExampleUnit = unit() {
  frame_id: uint16 &convert=ExampleEnum($$);
  ... if (self.frame_id >= ExampleEnum::Foo1 && self.frame_id <= ExampleEnum::Foo2);
}

It would be nice if this would work for not converted integers, as well:

  frame_id: uint16;