Merge branch 'topic/vern/bit-ops' of https://github.com/bro/bro

* 'topic/vern/bit-ops' of https://github.com/bro/bro:
  documentation clarification for "p1 | p2"
  documentation for bitwise operators
  document the '|' operator for patterns
  test suite for bitwise operators brief NEWS blurb allow for "counter" operands (does anyone still use these?) for one (but not both) of the bitwise operands
  bitwise operations for "count" types implemented
  Starting branch for supporting bit operations on count's.
This commit is contained in:
Jon Siwek 2018-06-21 16:00:48 -05:00
commit e5275b0c92
12 changed files with 215 additions and 26 deletions

View file

@ -34,18 +34,21 @@
%token TOK_NO_TEST
%left ',' '|'
%left ','
%right '=' TOK_ADD_TO TOK_REMOVE_FROM
%right '?' ':'
%left TOK_OR
%left TOK_AND
%left TOK_OR_OR
%left TOK_AND_AND
%nonassoc TOK_HOOK
%nonassoc '<' '>' TOK_LE TOK_GE TOK_EQ TOK_NE
%left TOK_IN TOK_NOT_IN
%left '|'
%left '^'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%left TOK_INCR TOK_DECR
%right '!'
%right '!' '~'
%left '$' '[' ']' '(' ')' TOK_HAS_FIELD TOK_HAS_ATTR
%nonassoc TOK_AS TOK_IS
@ -338,6 +341,12 @@ expr:
$$ = new NotExpr($2);
}
| '~' expr
{
set_location(@1, @2);
$$ = new ComplementExpr($2);
}
| '-' expr %prec '!'
{
set_location(@1, @2);
@ -392,16 +401,34 @@ expr:
$$ = new ModExpr($1, $3);
}
| expr TOK_AND expr
| expr '&' expr
{
set_location(@1, @3);
$$ = new BoolExpr(EXPR_AND, $1, $3);
$$ = new BitExpr(EXPR_AND, $1, $3);
}
| expr TOK_OR expr
| expr '|' expr
{
set_location(@1, @3);
$$ = new BoolExpr(EXPR_OR, $1, $3);
$$ = new BitExpr(EXPR_OR, $1, $3);
}
| expr '^' expr
{
set_location(@1, @3);
$$ = new BitExpr(EXPR_XOR, $1, $3);
}
| expr TOK_AND_AND expr
{
set_location(@1, @3);
$$ = new BoolExpr(EXPR_AND_AND, $1, $3);
}
| expr TOK_OR_OR expr
{
set_location(@1, @3);
$$ = new BoolExpr(EXPR_OR_OR, $1, $3);
}
| expr TOK_EQ expr
@ -704,7 +731,7 @@ expr:
$$ = new ConstExpr(new PatternVal($1));
}
| '|' expr '|'
| '|' expr '|' %prec '('
{
set_location(@1, @3);
$$ = new SizeExpr($2);