10 void yyerror (char const *);
12 int regex_cmp(char* s, char* r);
25 %token KW_IF KW_ELSE KW_PIPE KW_MAIL KW_COPY
26 %token '(' ')' '{' '}'
28 %left EQ NEQ GE LE '<' '>' RE NRE
42 | boo '\n' { printf("%s\n",$1?"true":"false"); }
43 | error '\n' { yyerrok; }
46 boo: CONST EQ CONST { $$ = ! strcmp($1, $3); }
47 | CONST NEQ CONST { $$ = !! strcmp($1, $3); }
48 | CONST RE CONST { $$ = regex_cmp($1,$3) >= 0 }
49 | CONST NRE CONST { $$ = regex_cmp($1,$3) < 0 }
50 | NUM EQ NUM { $$ = $1 == $3 }
51 | NUM NEQ NUM { $$ = $1 != $3 }
52 | NUM GE NUM { $$ = $1 >= $3 }
53 | NUM LE NUM { $$ = $1 <= $3 }
54 | NUM '>' NUM { $$ = $1 > $3 }
55 | NUM '<' NUM { $$ = $1 < $3 }
56 | boo '|' boo { $$ = $1 || $3 }
57 | boo '&' boo { $$ = $1 && $3 }
58 | boo '^' boo { $$ = ($1 || $3) && !($1 && $3) }
59 | '!' boo { $$ = ! $2 }
66 regex_cmp(char* s, char* r)
71 int ovector[OVECCOUNT];
73 brum = pcre_compile(r,0,&error,&erroroffset,NULL);
77 int res = pcre_exec(brum,NULL,s,strlen(s),0,0,ovector,OVECCOUNT);
85 yyerror (char const *s)
87 fprintf (stderr, "%s\n", s);