mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-19 01:28:44 +00:00
Filter operations: bitwise AND and OR
This commit is contained in:
parent
cd9550b244
commit
d4bcef0e0b
@ -347,7 +347,7 @@ else: {
|
|||||||
return DDOT;
|
return DDOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
[={}:;,.()+*/%<>~\[\]?!\|-] {
|
[={}:;,.()+*/%<>~\[\]?!\|&-] {
|
||||||
return yytext[0];
|
return yytext[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,7 @@ CF_DECLS
|
|||||||
%nonassoc PREFIX_DUMMY
|
%nonassoc PREFIX_DUMMY
|
||||||
%left AND OR
|
%left AND OR
|
||||||
%nonassoc '=' '<' '>' '~' GEQ LEQ NEQ NMA PO PC
|
%nonassoc '=' '<' '>' '~' GEQ LEQ NEQ NMA PO PC
|
||||||
|
%left '|' '&'
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/' '%'
|
%left '*' '/' '%'
|
||||||
%left '!'
|
%left '!'
|
||||||
|
@ -780,6 +780,8 @@ term:
|
|||||||
| term '-' term { $$ = f_new_inst(FI_SUBTRACT, $1, $3); }
|
| term '-' term { $$ = f_new_inst(FI_SUBTRACT, $1, $3); }
|
||||||
| term '*' term { $$ = f_new_inst(FI_MULTIPLY, $1, $3); }
|
| term '*' term { $$ = f_new_inst(FI_MULTIPLY, $1, $3); }
|
||||||
| term '/' term { $$ = f_new_inst(FI_DIVIDE, $1, $3); }
|
| term '/' term { $$ = f_new_inst(FI_DIVIDE, $1, $3); }
|
||||||
|
| term '&' term { $$ = f_new_inst(FI_BITAND, $1, $3); }
|
||||||
|
| term '|' term { $$ = f_new_inst(FI_BITOR, $1, $3); }
|
||||||
| term AND term { $$ = f_new_inst(FI_AND, $1, $3); }
|
| term AND term { $$ = f_new_inst(FI_AND, $1, $3); }
|
||||||
| term OR term { $$ = f_new_inst(FI_OR, $1, $3); }
|
| term OR term { $$ = f_new_inst(FI_OR, $1, $3); }
|
||||||
| term '=' term { $$ = f_new_inst(FI_EQ, $1, $3); }
|
| term '=' term { $$ = f_new_inst(FI_EQ, $1, $3); }
|
||||||
|
@ -240,6 +240,16 @@
|
|||||||
if (v2.val.i == 0) runtime( "Mother told me not to divide by 0" );
|
if (v2.val.i == 0) runtime( "Mother told me not to divide by 0" );
|
||||||
RESULT(T_INT, i, v1.val.i / v2.val.i);
|
RESULT(T_INT, i, v1.val.i / v2.val.i);
|
||||||
}
|
}
|
||||||
|
INST(FI_BITOR, 2, 1) {
|
||||||
|
ARG(1,T_INT);
|
||||||
|
ARG(2,T_INT);
|
||||||
|
RESULT(T_INT, i, v1.val.i | v2.val.i);
|
||||||
|
}
|
||||||
|
INST(FI_BITAND, 2, 1) {
|
||||||
|
ARG(1,T_INT);
|
||||||
|
ARG(2,T_INT);
|
||||||
|
RESULT(T_INT, i, v1.val.i & v2.val.i);
|
||||||
|
}
|
||||||
INST(FI_AND, 1, 1) {
|
INST(FI_AND, 1, 1) {
|
||||||
ARG(1,T_BOOL);
|
ARG(1,T_BOOL);
|
||||||
ARG_TYPE_STATIC(2,T_BOOL);
|
ARG_TYPE_STATIC(2,T_BOOL);
|
||||||
|
@ -111,6 +111,14 @@ int i;
|
|||||||
bt_assert(!(i = 4));
|
bt_assert(!(i = 4));
|
||||||
bt_assert(1 <= 1);
|
bt_assert(1 <= 1);
|
||||||
bt_assert(!(1234 < 1234));
|
bt_assert(!(1234 < 1234));
|
||||||
|
|
||||||
|
bt_assert(10 - 5 = 5);
|
||||||
|
bt_assert(4294967295 + 1 = 0);
|
||||||
|
bt_assert(6*9=54);
|
||||||
|
bt_assert(984/41 = 24);
|
||||||
|
bt_assert(123/45 = 2);
|
||||||
|
bt_assert(0xfee1a | 0xbeef = 0xffeff);
|
||||||
|
bt_assert(0xfee1a & 0xbeef = 0xae0a);
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_test_suite(t_int, "Testing integers");
|
bt_test_suite(t_int, "Testing integers");
|
||||||
|
Loading…
Reference in New Issue
Block a user