[Bro-Dev] set and vector operators

Vern Paxson vern at icir.org
Wed Apr 25 22:19:36 PDT 2018


Hmmm thinking about it, we can get away with '&' with minimal keyword
conflict because there's such an easy (and natural-to-presume) fix -
namely, rather than "x&attrkeyword" you use "x & attrkeyword".  Now
there's no problem, since the lexer only recognizes "&attrkeyword"
as a unit, with no whitespace allowed.

Given that, here's my updated proposal, with 'c' standing for values of
type count:

	s1 + s2		Set union
	s1 - s2		Set difference
	s1 | s2		Set union
	s1 & s2		Set intersection
	s1 ^ s2		Set symmetric difference

	s + e		The set resulting from adding the element 'e' to
				the set 's'
	s - e		The set resulting from removing the element 'e' from
				the set 's', if present

	s1 {+=, -=, |=, &=, ^=} s2
			Perform the corresponding set operation between
				s1 and s2 and put the result in s1.
	s {+=, -=} e
			Add or remove the element e from the set s

	c1 | c2
	c1 & c2		Bitwise or/and/xor of two count values
	c1 ^ c2	

	c1 {|=, &=, ^=} c2
			Perform the corresponding bitwise operation between
				c1 and c2 and put the result in c1.

	v += e		Append the element 'e' to the vector 'v'

	s += v		Add the elements of 'v' to 's'
	s -= v		Remove the elements of 'v' from 's', if present

How does that sound?

		Vern


More information about the bro-dev mailing list