inital gtk2 patch
[claws.git] / src / matcher_parser_parse.y
index b0631fd5328e9ae3acdaa2f8243f053289b8ea50..29d70d5fe2bc38c4bed091e35884da18c5be8014 100644 (file)
@@ -1,4 +1,25 @@
+
 %{
+
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (c) 2001-2002 by Hiroyuki Yamamoto & The Sylpheed Claws Team.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
 #include "defs.h"
 
 #include <glib.h>
 static gint error = 0;
 static gint bool_op = 0;
 static gint match_type = 0;
-static gchar * header = NULL;
+static gchar *header = NULL;
 
-static MatcherProp * prop;
+static MatcherProp *prop;
 
-static GSList * matchers_list = NULL;
+static GSList *matchers_list = NULL;
 
-static MatcherList * cond;
+static MatcherList *cond;
 static gint score = 0;
-static FilteringAction * action = NULL;
+static GSList *action_list = NULL;
+static FilteringAction *action = NULL;
 
-static FilteringProp *  filtering;
-static ScoringProp * scoring = NULL;
+static FilteringProp *filtering;
+static ScoringProp *scoring = NULL;
 
-static GSList ** prefs_scoring = NULL;
-static GSList ** prefs_filtering = NULL;
+static GSList **prefs_scoring = NULL;
+static GSList **prefs_filtering = NULL;
 
+#if 0
 static int matcher_parser_dialog = 0;
+#endif
 
+enum {
+        MATCHER_PARSE_NONE,
+        MATCHER_PARSE_NO_EOL,
+        MATCHER_PARSE_CONDITION,
+        MATCHER_PARSE_FILTERING_OR_SCORING,
+};
 
-/* ******************************************************************** */
+static int matcher_parse_op = MATCHER_PARSE_NONE;
 
 
+/* ******************************************************************** */
 
-void matcher_parser_start_parsing(FILE * f)
+void matcher_parser_start_parsing(FILE *f)
 {
        matcher_parserrestart(f);
        matcher_parserparse();
 }
  
-FilteringProp * matcher_parser_get_filtering(gchar * str)
+FilteringProp *matcher_parser_get_filtering(const gchar *str)
 {
-       void * bufstate;
+       void *bufstate;
 
        /* bad coding to enable the sub-grammar matching
           in yacc */
        matcher_parserlineno = 1;
-       matcher_parser_dialog = 1;
+       matcher_parse_op = MATCHER_PARSE_NO_EOL;
        matcher_parserrestart(NULL);
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
         matcher_parser_switch_to_buffer(bufstate);
        if (matcher_parserparse() != 0)
                filtering = NULL;
-       matcher_parser_dialog = 0;
+       matcher_parse_op = MATCHER_PARSE_NONE;
        matcher_parser_delete_buffer(bufstate);
        return filtering;
 }
 
-ScoringProp * matcher_parser_get_scoring(gchar * str)
+ScoringProp *matcher_parser_get_scoring(const gchar *str)
 {
-       void * bufstate;
+       void *bufstate;
 
        /* bad coding to enable the sub-grammar matching
           in yacc */
        matcher_parserlineno = 1;
-       matcher_parser_dialog = 1;
+       matcher_parse_op = MATCHER_PARSE_NO_EOL;
        matcher_parserrestart(NULL);
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
         matcher_parser_switch_to_buffer(bufstate);
        if (matcher_parserparse() != 0)
                scoring = NULL;
-       matcher_parser_dialog = 0;
+       matcher_parse_op = MATCHER_PARSE_NONE;
        matcher_parser_delete_buffer(bufstate);
        return scoring;
 }
 
-static gboolean check_quote_symetry (gchar *str)
+static gboolean check_quote_symetry(gchar *str)
 {
-       gchar *walk;
+       const gchar *walk;
        int ret = 0;
        
        if (str == NULL)
@@ -100,12 +131,12 @@ static gboolean check_quote_symetry (gchar *str)
                                ret ++;
                }
        }
-       return !(ret%2);
+       return !(ret % 2);
 }
 
-MatcherList * matcher_parser_get_cond(gchar * str)
+MatcherList *matcher_parser_get_cond(const gchar *str)
 {
-       void * bufstate;
+       void *bufstate;
 
        if (!check_quote_symetry(str)) {
                cond = NULL;
@@ -115,20 +146,42 @@ MatcherList * matcher_parser_get_cond(gchar * str)
        /* bad coding to enable the sub-grammar matching
           in yacc */
        matcher_parserlineno = 1;
-       matcher_parser_dialog = 1;
+       matcher_parse_op = MATCHER_PARSE_CONDITION;
        matcher_parserrestart(NULL);
         matcher_parser_init();
        bufstate = matcher_parser_scan_string(str);
        matcher_parserparse();
-       matcher_parser_dialog = 0;
+       matcher_parse_op = MATCHER_PARSE_NONE;
        matcher_parser_delete_buffer(bufstate);
        return cond;
 }
 
-MatcherProp * matcher_parser_get_prop(gchar * str)
+GSList *matcher_parser_get_action_list(const gchar *str)
+{
+       void *bufstate;
+
+       if (!check_quote_symetry(str)) {
+               action_list = NULL;
+               return action_list;
+       }
+       
+       /* bad coding to enable the sub-grammar matching
+          in yacc */
+       matcher_parserlineno = 1;
+       matcher_parse_op = MATCHER_PARSE_FILTERING_OR_SCORING;
+       matcher_parserrestart(NULL);
+        matcher_parser_init();
+       bufstate = matcher_parser_scan_string(str);
+       matcher_parserparse();
+       matcher_parse_op = MATCHER_PARSE_NONE;
+       matcher_parser_delete_buffer(bufstate);
+       return action_list;
+}
+
+MatcherProp *matcher_parser_get_prop(const gchar *str)
 {
-       MatcherList * list;
-       MatcherProp * prop;
+       MatcherList *list;
+       MatcherProp *prop;
 
        matcher_parserlineno = 1;
        list = matcher_parser_get_cond(str);
@@ -149,13 +202,12 @@ MatcherProp * matcher_parser_get_prop(gchar * str)
        return prop;
 }
 
-void matcher_parsererror(char * str)
+void matcher_parsererror(char *str)
 {
-       GSList * l;
+       GSList *l;
 
        if (matchers_list) {
-               for(l = matchers_list ; l != NULL ;
-                   l = g_slist_next(l)) {
+               for (l = matchers_list; l != NULL; l = g_slist_next(l)) {
                        matcherprop_free((MatcherProp *)
                                         l->data);
                        l->data = NULL;
@@ -176,7 +228,7 @@ int matcher_parserwrap(void)
 %}
 
 %union {
-       char * str;
+       char *str;
        int value;
 }
 
@@ -195,14 +247,16 @@ int matcher_parserwrap(void)
 %token MATCHER_NOT_MESSAGE  MATCHER_BODY_PART  MATCHER_NOT_BODY_PART
 %token MATCHER_EXECUTE  MATCHER_NOT_EXECUTE  MATCHER_MATCHCASE  MATCHER_MATCH
 %token MATCHER_REGEXPCASE  MATCHER_REGEXP  MATCHER_SCORE  MATCHER_MOVE
-%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK
+%token MATCHER_COPY  MATCHER_DELETE  MATCHER_MARK  MATCHER_UNMARK MATCHER_LOCK MATCHER_UNLOCK
 %token MATCHER_MARK_AS_READ  MATCHER_MARK_AS_UNREAD  MATCHER_FORWARD
 %token MATCHER_FORWARD_AS_ATTACHMENT  MATCHER_EOL  MATCHER_STRING  
 %token MATCHER_OR MATCHER_AND  
-%token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT MATCHER_DELETE_ON_SERVER
+%token MATCHER_COLOR MATCHER_SCORE_EQUAL MATCHER_REDIRECT 
 %token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL
 %token MATCHER_LOCKED MATCHER_NOT_LOCKED
 %token MATCHER_COLORLABEL MATCHER_NOT_COLORLABEL
+%token MATCHER_IGNORE_THREAD MATCHER_NOT_IGNORE_THREAD
+%token MATCHER_CHANGE_SCORE
 
 %start file
 
@@ -214,7 +268,7 @@ int matcher_parserwrap(void)
 
 file:
 {
-       if (!matcher_parser_dialog) {
+       if (matcher_parse_op == MATCHER_PARSE_NONE) {
                prefs_scoring = &global_scoring;
                prefs_filtering = &global_processing;
        }
@@ -229,7 +283,9 @@ file_line_list
 
 file_line:
 section_notification
-| instruction
+| 
+{ action_list = NULL; }
+instruction
 | error MATCHER_EOL
 {
        yyerrok;
@@ -238,63 +294,68 @@ section_notification
 section_notification:
 MATCHER_SECTION MATCHER_EOL
 {
-       gchar * folder = $1;
-       FolderItem * item = NULL;
+       gchar *folder = $1;
+       FolderItem *item = NULL;
 
-       if (!matcher_parser_dialog) {
-               item = folder_find_item_from_identifier(folder);
-               if (item == NULL) {
+       if (matcher_parse_op == MATCHER_PARSE_NONE) {
+               if (!strcmp(folder, "global")) {
                        prefs_scoring = &global_scoring;
                        prefs_filtering = &global_processing;
-               }
-               else {
-                       prefs_scoring = &item->prefs->scoring;
-                       prefs_filtering = &item->prefs->processing;
+               } else {
+                       item = folder_find_item_from_identifier(folder);
+                       if (item != NULL) {
+                               prefs_scoring = &item->prefs->scoring;
+                               prefs_filtering = &item->prefs->processing;
+                       } else {
+                               prefs_scoring = NULL;
+                               prefs_filtering = NULL;
+                       }
                }
        }
 }
 ;
 
 instruction:
-condition end_instr_opt
-| MATCHER_EOL
-;
-
-end_instr_opt:
-filtering_or_scoring end_action
-|
+condition filtering_or_scoring MATCHER_EOL
+| condition filtering_or_scoring
 {
-       if (matcher_parser_dialog)
+       if (matcher_parse_op == MATCHER_PARSE_NO_EOL)
                YYACCEPT;
        else {
                matcher_parsererror("parse error");
                YYERROR;
        }
 }
-;
-
-end_action:
-MATCHER_EOL
-|
+| condition
+{
+       if (matcher_parse_op == MATCHER_PARSE_CONDITION)
+               YYACCEPT;
+       else {
+               matcher_parsererror("parse error");
+               YYERROR;
+       }
+}
+| filtering_action_list
 {
-       if (matcher_parser_dialog)
+       if (matcher_parse_op == MATCHER_PARSE_FILTERING_OR_SCORING)
                YYACCEPT;
        else {
                matcher_parsererror("parse error");
                YYERROR;
        }
 }
+| MATCHER_EOL
 ;
 
 filtering_or_scoring:
-filtering_action
+filtering_action_list
 {
-       filtering = filteringprop_new(cond, action);
+       filtering = filteringprop_new(cond, action_list);
        cond = NULL;
-       action = NULL;
-       if (!matcher_parser_dialog) {
-               * prefs_filtering = g_slist_append(* prefs_filtering,
-                                                  filtering);
+       action_list = NULL;
+       if ((matcher_parse_op == MATCHER_PARSE_NONE) && (prefs_filtering != NULL)) {
+               *prefs_filtering = g_slist_append(*prefs_filtering,
+                                                 filtering);
                filtering = NULL;
        }
 }
@@ -303,13 +364,27 @@ filtering_action
        scoring = scoringprop_new(cond, score);
        cond = NULL;
        score = 0;
-       if (!matcher_parser_dialog) {
-               * prefs_scoring = g_slist_append(* prefs_scoring, scoring);
+       if ((matcher_parse_op == MATCHER_PARSE_NONE)
+            && (prefs_scoring != NULL)) {
+               *prefs_scoring = g_slist_append(*prefs_scoring, scoring);
                scoring = NULL;
        }
 }
 ;
 
+filtering_action_list:
+filtering_action_b filtering_action_list
+| filtering_action_b
+;
+
+filtering_action_b:
+filtering_action
+{
+        action_list = g_slist_append(action_list, action);
+        action = NULL;
+}
+;
+
 match_type:
 MATCHER_MATCHCASE
 {
@@ -488,10 +563,24 @@ MATCHER_ALL
        else if (value > MAX_COLORLABELS) value = MAX_COLORLABELS;
        prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, value);
 }
+| MATCHER_IGNORE_THREAD
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_IGNORE_THREAD;
+       prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
+}
+| MATCHER_NOT_IGNORE_THREAD
+{
+       gint criteria = 0;
+
+       criteria = MATCHCRITERIA_NOT_IGNORE_THREAD;
+       prop = matcherprop_unquote_new(criteria, NULL, 0, NULL, 0);
+}
 | MATCHER_SUBJECT match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_SUBJECT;
        expr = $3;
@@ -500,7 +589,7 @@ MATCHER_ALL
 | MATCHER_NOT_SUBJECT match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_SUBJECT;
        expr = $3;
@@ -509,7 +598,7 @@ MATCHER_ALL
 | MATCHER_FROM match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_FROM;
        expr = $3;
@@ -518,7 +607,7 @@ MATCHER_ALL
 | MATCHER_NOT_FROM match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_FROM;
        expr = $3;
@@ -527,7 +616,7 @@ MATCHER_ALL
 | MATCHER_TO match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_TO;
        expr = $3;
@@ -536,7 +625,7 @@ MATCHER_ALL
 | MATCHER_NOT_TO match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_TO;
        expr = $3;
@@ -545,7 +634,7 @@ MATCHER_ALL
 | MATCHER_CC match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_CC;
        expr = $3;
@@ -554,7 +643,7 @@ MATCHER_ALL
 | MATCHER_NOT_CC match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_CC;
        expr = $3;
@@ -563,7 +652,7 @@ MATCHER_ALL
 | MATCHER_TO_OR_CC match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_TO_OR_CC;
        expr = $3;
@@ -572,7 +661,7 @@ MATCHER_ALL
 | MATCHER_NOT_TO_AND_NOT_CC match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_TO_AND_NOT_CC;
        expr = $3;
@@ -599,7 +688,7 @@ MATCHER_ALL
 | MATCHER_NEWSGROUPS match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NEWSGROUPS;
        expr = $3;
@@ -608,7 +697,7 @@ MATCHER_ALL
 | MATCHER_NOT_NEWSGROUPS match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_NEWSGROUPS;
        expr = $3;
@@ -617,7 +706,7 @@ MATCHER_ALL
 | MATCHER_INREPLYTO match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_INREPLYTO;
        expr = $3;
@@ -626,7 +715,7 @@ MATCHER_ALL
 | MATCHER_NOT_INREPLYTO match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_INREPLYTO;
        expr = $3;
@@ -635,7 +724,7 @@ MATCHER_ALL
 | MATCHER_REFERENCES match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_REFERENCES;
        expr = $3;
@@ -644,7 +733,7 @@ MATCHER_ALL
 | MATCHER_NOT_REFERENCES match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_REFERENCES;
        expr = $3;
@@ -707,7 +796,7 @@ MATCHER_ALL
 } match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_HEADER;
        expr = $2;
@@ -720,7 +809,7 @@ MATCHER_ALL
 } match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_HEADER;
        expr = $2;
@@ -730,7 +819,7 @@ MATCHER_ALL
 | MATCHER_HEADERS_PART match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_HEADERS_PART;
        expr = $3;
@@ -739,7 +828,7 @@ MATCHER_ALL
 | MATCHER_NOT_HEADERS_PART match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_HEADERS_PART;
        expr = $3;
@@ -748,7 +837,7 @@ MATCHER_ALL
 | MATCHER_MESSAGE match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_MESSAGE;
        expr = $3;
@@ -757,7 +846,7 @@ MATCHER_ALL
 | MATCHER_NOT_MESSAGE match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_MESSAGE;
        expr = $3;
@@ -766,7 +855,7 @@ MATCHER_ALL
 | MATCHER_BODY_PART match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_BODY_PART;
        expr = $3;
@@ -775,7 +864,7 @@ MATCHER_ALL
 | MATCHER_NOT_BODY_PART match_type MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_BODY_PART;
        expr = $3;
@@ -784,7 +873,7 @@ MATCHER_ALL
 | MATCHER_EXECUTE MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_EXECUTE;
        expr = $2;
@@ -793,7 +882,7 @@ MATCHER_ALL
 | MATCHER_NOT_EXECUTE MATCHER_STRING
 {
        gint criteria = 0;
-       gchar * expr = NULL;
+       gchar *expr = NULL;
 
        criteria = MATCHCRITERIA_NOT_EXECUTE;
        expr = $2;
@@ -804,7 +893,7 @@ MATCHER_ALL
 filtering_action:
 MATCHER_EXECUTE MATCHER_STRING
 {
-       gchar * cmd = NULL;
+       gchar *cmd = NULL;
        gint action_type = 0;
 
        action_type = MATCHACTION_EXECUTE;
@@ -813,7 +902,7 @@ MATCHER_EXECUTE MATCHER_STRING
 }
 | MATCHER_MOVE MATCHER_STRING
 {
-       gchar * destination = NULL;
+       gchar *destination = NULL;
        gint action_type = 0;
 
        action_type = MATCHACTION_MOVE;
@@ -822,7 +911,7 @@ MATCHER_EXECUTE MATCHER_STRING
 }
 | MATCHER_COPY MATCHER_STRING
 {
-       gchar * destination = NULL;
+       gchar *destination = NULL;
        gint action_type = 0;
 
        action_type = MATCHACTION_COPY;
@@ -850,6 +939,20 @@ MATCHER_EXECUTE MATCHER_STRING
        action_type = MATCHACTION_UNMARK;
        action = filteringaction_new(action_type, 0, NULL, 0);
 }
+| MATCHER_LOCK
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_LOCK;
+       action = filteringaction_new(action_type, 0, NULL, 0);
+}
+| MATCHER_UNLOCK
+{
+       gint action_type = 0;
+
+       action_type = MATCHACTION_UNLOCK;
+       action = filteringaction_new(action_type, 0, NULL, 0);
+}
 | MATCHER_MARK_AS_READ
 {
        gint action_type = 0;
@@ -866,7 +969,7 @@ MATCHER_EXECUTE MATCHER_STRING
 }
 | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING
 {
-       gchar * destination = NULL;
+       gchar *destination = NULL;
        gint action_type = 0;
        gint account_id = 0;
 
@@ -877,7 +980,7 @@ MATCHER_EXECUTE MATCHER_STRING
 }
 | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING
 {
-       gchar * destination = NULL;
+       gchar *destination = NULL;
        gint action_type = 0;
        gint account_id = 0;
 
@@ -888,7 +991,7 @@ MATCHER_EXECUTE MATCHER_STRING
 }
 | MATCHER_REDIRECT MATCHER_INTEGER MATCHER_STRING
 {
-       gchar * destination = NULL;
+       gchar *destination = NULL;
        gint action_type = 0;
        gint account_id = 0;
 
@@ -906,11 +1009,26 @@ MATCHER_EXECUTE MATCHER_STRING
        color = atoi($2);
        action = filteringaction_new(action_type, 0, NULL, color);
 }
-| MATCHER_DELETE_ON_SERVER
+| MATCHER_CHANGE_SCORE MATCHER_STRING
 {
-       gint action_type = 0;
-       action_type = MATCHACTION_DELETE_ON_SERVER;
-       action = filteringaction_new(action_type, 0, NULL, 0);
+       gint action_type = MATCHACTION_CHANGE_SCORE;
+       char *last_tok = NULL;
+       const gchar *first_tok;
+       long int chscore;
+       int change_type; /* -1 == decrement, 0 == assign, 1 == increment */     
+
+#define is_number(x) ( ((x) == '+') || ((x) == '-') || (isdigit((x))) ) 
+       /* find start */
+       for (first_tok = $2; *first_tok && !is_number(*first_tok); first_tok++)
+               ;            
+#undef is_number               
+       
+       chscore = strtol(first_tok, &last_tok, 10);
+       if (last_tok == first_tok || *last_tok == 0) 
+               chscore = 0;
+       change_type = *first_tok == '+' ? 1 : *first_tok == '-' ? -1 : 0;
+       action = filteringaction_new(MATCHACTION_CHANGE_SCORE, change_type,
+                                    NULL, chscore);
 }
 ;