Merge remote-tracking branch 'origin/topic/johanna/bit-1619'

BIT-1619 #merged

* origin/topic/johanna/bit-1619:
  Fix precedence of hook
This commit is contained in:
Robin Sommer 2016-06-14 16:11:07 -07:00
commit a4db7f1359
5 changed files with 39 additions and 2 deletions

View file

@ -1,4 +1,12 @@
2.4-606 | 2016-06-14 16:11:07 -0700
* Fix parsing precedence of "hook" expression. Addresses BIT-1619
(Johanna Amann)
* Update the "configure" usage message for --with-caf (Daniel
Thayer)
2.4-602 | 2016-06-13 08:16:34 -0700
* Fixing Covertity warning (CID 1356391). (Robin Sommer)

View file

@ -1 +1 @@
2.4-602
2.4-606

View file

@ -31,12 +31,12 @@
%token TOK_NO_TEST
%nonassoc TOK_HOOK
%left ',' '|'
%right '=' TOK_ADD_TO TOK_REMOVE_FROM
%right '?' ':'
%left TOK_OR
%left TOK_AND
%nonassoc TOK_HOOK
%nonassoc '<' '>' TOK_LE TOK_GE TOK_EQ TOK_NE
%left TOK_IN TOK_NOT_IN
%left '+' '-'

View file

@ -17,3 +17,7 @@ myhook return F
myhook return T
myhook, &priority=5, [a=37, b=goobye world]
F
myhook5, test
second part ran
myhook5 ran
myhook6, test

View file

@ -10,6 +10,8 @@ global myhook: hook(r: rec);
global myhook2: hook(s: string);
# a hook doesn't have to take any arguments
global myhook4: hook();
global myhook5: hook(s: string);
global myhook6: hook(s: string);
hook myhook(r: rec) &priority=5
{
@ -72,6 +74,23 @@ hook myhook4() &priority=2
print "myhook4", 2;
}
hook myhook5(s: string)
{
print "myhook5", s;
}
hook myhook6(s: string)
{
print "myhook6", s;
break;
}
function printMe(s: string): bool
{
print s;
return T;
}
event bro_init()
{
print hook myhook([$a=1156, $b="hello world"]);
@ -90,4 +109,10 @@ event bro_init()
# invoked directly by name.
local h = myhook;
print hook h([$a=2, $b="it works"]);
if ( hook myhook5("test") && printMe("second part ran") )
print "myhook5 ran";
if ( ( hook myhook6("test") ) && printMe("second part ran") )
print "myhook6 ran";
}