aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ip/snoopy/filter.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/ip/snoopy/filter.y')
-rwxr-xr-xsrc/cmd/ip/snoopy/filter.y33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/cmd/ip/snoopy/filter.y b/src/cmd/ip/snoopy/filter.y
index d34bfc7c..10b6ddef 100755
--- a/src/cmd/ip/snoopy/filter.y
+++ b/src/cmd/ip/snoopy/filter.y
@@ -12,6 +12,7 @@ char *yyend; /* end of buffer to be parsed */
%term LOR
%term LAND
%term WORD
+%term NE
%right '!'
%left '|'
%left '&'
@@ -27,6 +28,14 @@ expr : WORD
{ $$ = $1; }
| WORD '=' WORD
{ $2->l = $1; $2->r = $3; $$ = $2; }
+ | WORD NE WORD
+ { $2->l = newfilter();
+ $2->l->op = '=';
+ $2->l->l = $1;
+ $2->l->r = $3;
+ $2->op = '!';
+ $$ = $2;
+ }
| WORD '(' expr ')'
{ $1->l = $3; free($2); free($4); $$ = $1; }
| '(' expr ')'
@@ -84,17 +93,18 @@ yylex(void)
}
yylp++;
- if(*yylp == c)
- switch(c){
- case '&':
- c = LAND;
- yylp++;
- break;
- case '|':
- c = LOR;
- yylp++;
- break;
- }
+ if(c == '!' && *yylp == '='){
+ c = NE;
+ yylp++;
+ }
+ else if(c == '&' && *yylp == '&'){
+ c = LAND;
+ yylp++;
+ }
+ else if(c == '|' && *yylp == '|'){
+ c = LOR;
+ yylp++;
+ }
yylval->op = c;
return c;
}
@@ -103,5 +113,6 @@ void
yyerror(char *e)
{
USED(e);
+// longjmp(errjmp, 1);
sysfatal("error parsing filter");
}