summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-07-26 11:22:17 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-07-26 11:22:17 +0000
commit659d10e3b4efed955dce25c58a7e9d204789b146 (patch)
tree408c46b97318bf789b9bdc9bfd16afc643b089be
parentcc8b0d810b932659b1accb31b28d22ba2d7d6c63 (diff)
downloadmailutils-659d10e3b4efed955dce25c58a7e9d204789b146.tar.gz
mailutils-659d10e3b4efed955dce25c58a7e9d204789b146.tar.bz2
Implemented boolean shortcuts for ALLOF and ANYOF
-rw-r--r--libsieve/sieve.y26
1 files changed, 15 insertions, 11 deletions
diff --git a/libsieve/sieve.y b/libsieve/sieve.y
index 2a0989f7d..7bb2abb07 100644
--- a/libsieve/sieve.y
+++ b/libsieve/sieve.y
@@ -39,6 +39,10 @@ static void branch_fixup __P((size_t start, size_t end));
list_t list;
size_t pc;
struct {
+ size_t start;
+ size_t end;
+ } pclist;
+ struct {
char *ident;
list_t args;
} command;
@@ -57,7 +61,7 @@ static void branch_fixup __P((size_t start, size_t end));
%type <value> arg
%type <list> slist stringlist stringorlist arglist maybe_arglist
%type <command> command
-%type <number> testlist
+%type <pclist> testlist
%type <pc> action test statement list elsif else cond begin if block
%type <branch> elsif_branch maybe_elsif else_part
@@ -171,15 +175,19 @@ block : '{' list '}'
testlist : cond_expr
{
- if (sieve_code_instr (instr_push))
+ $$.start = $$.end = sieve_machine->pc;
+ if (sieve_code_instr (instr_brz)
+ || sieve_code_number (0))
YYERROR;
- $$ = 1;
}
| testlist ',' cond_expr
{
- if (sieve_code_instr (instr_push))
+ sieve_machine->prog[$1.end+1].pc = sieve_machine->pc;
+ $1.end = sieve_machine->pc;
+ if (sieve_code_instr (instr_brz)
+ || sieve_code_number (0))
YYERROR;
- $$ = $1 + 1;
+ $$ = $1;
}
;
@@ -195,15 +203,11 @@ cond_expr : test
{ /* to placate bison */ }
| ANYOF '(' testlist ')'
{
- if (sieve_code_instr (instr_anyof)
- || sieve_code_number ($3))
- YYERROR;
+ sieve_code_anyof ($3.start);
}
| ALLOF '(' testlist ')'
{
- if (sieve_code_instr (instr_allof)
- || sieve_code_number ($3))
- YYERROR;
+ sieve_code_allof ($3.start);
}
| NOT cond_expr
{

Return to:

Send suggestions and report system problems to the System administrator.