X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=blobdiff_plain;f=src%2Fmatcher_parser_parse.y;h=0ba0abfaa8ee2385c84b35481b25492afcd18583;hp=c8c4db58586093843b294ceb24d9d90a9506347a;hb=f7e4774dcdb992ad050571a39700c74fc3bb653e;hpb=11dd56825143bd34e795b51f2818a62e222d6111 diff --git a/src/matcher_parser_parse.y b/src/matcher_parser_parse.y index c8c4db585..0ba0abfaa 100644 --- a/src/matcher_parser_parse.y +++ b/src/matcher_parser_parse.y @@ -1,11 +1,15 @@ %{ +#include "defs.h" + +#include + +#include "intl.h" +#include "utils.h" #include "filtering.h" #include "scoring.h" #include "matcher.h" #include "matcher_parser.h" #include "matcher_parser_lex.h" -#include "intl.h" -#include static gint error = 0; static gint bool_op = 0; @@ -28,14 +32,28 @@ static GSList ** prefs_filtering = NULL; static int matcher_parser_dialog = 0; + +/* ******************************************************************** */ + + + +void matcher_parser_start_parsing(FILE * f) +{ + matcher_parserrestart(f); + matcher_parserparse(); +} + FilteringProp * matcher_parser_get_filtering(gchar * str) { void * bufstate; + /* bad coding to enable the sub-grammar matching + in yacc */ matcher_parserlineno = 1; matcher_parser_dialog = 1; bufstate = matcher_parser_scan_string(str); - matcher_parserparse(); + if (matcher_parserparse() != 0) + filtering = NULL; matcher_parser_dialog = 0; matcher_parser_delete_buffer(bufstate); return filtering; @@ -45,10 +63,13 @@ ScoringProp * matcher_parser_get_scoring(gchar * str) { void * bufstate; + /* bad coding to enable the sub-grammar matching + in yacc */ matcher_parserlineno = 1; matcher_parser_dialog = 1; bufstate = matcher_parser_scan_string(str); - matcher_parserparse(); + if (matcher_parserparse() != 0) + scoring = NULL; matcher_parser_dialog = 0; matcher_parser_delete_buffer(bufstate); return scoring; @@ -58,6 +79,8 @@ MatcherList * matcher_parser_get_cond(gchar * str) { void * bufstate; + /* bad coding to enable the sub-grammar matching + in yacc */ matcher_parserlineno = 1; matcher_parser_dialog = 1; bufstate = matcher_parser_scan_string(str); @@ -87,6 +110,8 @@ MatcherProp * matcher_parser_get_prop(gchar * str) g_slist_free(list->matchers); g_free(list); + + return prop; } void matcher_parsererror(char * str) @@ -137,6 +162,8 @@ int matcher_parserwrap(void) %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_BOUNCE MATCHER_DELETE_ON_SERVER +%token MATCHER_SIZE_GREATER MATCHER_SIZE_SMALLER MATCHER_SIZE_EQUAL %start file @@ -150,7 +177,7 @@ file: { if (!matcher_parser_dialog) { prefs_scoring = &global_scoring; - prefs_filtering = &global_filtering; + prefs_filtering = &global_processing; } } file_line_list; @@ -164,7 +191,10 @@ file_line_list file_line: section_notification | instruction -; +| error MATCHER_EOL +{ + yyerrok; +}; section_notification: MATCHER_SECTION MATCHER_EOL @@ -176,7 +206,7 @@ MATCHER_SECTION MATCHER_EOL item = folder_find_item_from_identifier(folder); if (item == NULL) { prefs_scoring = &global_scoring; - prefs_filtering = &global_scoring; + prefs_filtering = &global_processing; } else { prefs_scoring = &item->prefs->scoring; @@ -192,12 +222,27 @@ condition end_instr_opt ; end_instr_opt: -filtering_or_scoring MATCHER_EOL +filtering_or_scoring end_action | { - if (!matcher_parser_dialog) { - yyerror("parse error"); - return 1; + if (matcher_parser_dialog) + YYACCEPT; + else { + matcher_parsererror("parse error"); + YYERROR; + } +} +; + +end_action: +MATCHER_EOL +| +{ + if (matcher_parser_dialog) + YYACCEPT; + else { + matcher_parsererror("parse error"); + YYERROR; } } ; @@ -548,6 +593,39 @@ MATCHER_ALL value = atoi($2); prop = matcherprop_new(criteria, NULL, 0, NULL, value); } +| MATCHER_SCORE_EQUAL MATCHER_INTEGER +{ + gint criteria = 0; + gint value = 0; + + criteria = MATCHCRITERIA_SCORE_EQUAL; + value = atoi($2); + prop = matcherprop_new(criteria, NULL, 0, NULL, value); +} +| MATCHER_SIZE_GREATER MATCHER_INTEGER +{ + gint criteria = 0; + gint value = 0; + criteria = MATCHCRITERIA_SIZE_GREATER; + value = atoi($2); + prop = matcherprop_new(criteria, NULL, 0, NULL, value); +} +| MATCHER_SIZE_SMALLER MATCHER_INTEGER +{ + gint criteria = 0; + gint value = 0; + criteria = MATCHCRITERIA_SIZE_SMALLER; + value = atoi($2); + prop = matcherprop_new(criteria, NULL, 0, NULL, value); +} +| MATCHER_SIZE_EQUAL MATCHER_INTEGER +{ + gint criteria = 0; + gint value = 0; + criteria = MATCHCRITERIA_SIZE_EQUAL; + value = atoi($2); + prop = matcherprop_new(criteria, NULL, 0, NULL, value); +} | MATCHER_HEADER MATCHER_STRING { header = g_strdup($2); @@ -628,15 +706,6 @@ MATCHER_ALL expr = $3; prop = matcherprop_new(criteria, NULL, match_type, expr, 0); } -| MATCHER_NOT_MESSAGE match_type MATCHER_STRING -{ - gint criteria = 0; - gchar * expr = NULL; - - criteria = MATCHCRITERIA_NOT_MESSAGE; - expr = $3; - prop = matcherprop_new(criteria, NULL, match_type, expr, 0); -} | MATCHER_EXECUTE MATCHER_STRING { gint criteria = 0; @@ -665,7 +734,7 @@ MATCHER_EXECUTE MATCHER_STRING action_type = MATCHACTION_EXECUTE; cmd = $2; - action = filteringaction_new(action_type, 0, cmd); + action = filteringaction_new(action_type, 0, cmd, 0); } | MATCHER_MOVE MATCHER_STRING { @@ -674,7 +743,7 @@ MATCHER_EXECUTE MATCHER_STRING action_type = MATCHACTION_MOVE; destination = $2; - action = filteringaction_new(action_type, 0, destination); + action = filteringaction_new(action_type, 0, destination, 0); } | MATCHER_COPY MATCHER_STRING { @@ -683,42 +752,42 @@ MATCHER_EXECUTE MATCHER_STRING action_type = MATCHACTION_COPY; destination = $2; - action = filteringaction_new(action_type, 0, destination); + action = filteringaction_new(action_type, 0, destination, 0); } | MATCHER_DELETE { gint action_type = 0; action_type = MATCHACTION_DELETE; - action = filteringaction_new(action_type, 0, NULL); + action = filteringaction_new(action_type, 0, NULL, 0); } | MATCHER_MARK { gint action_type = 0; action_type = MATCHACTION_MARK; - action = filteringaction_new(action_type, 0, NULL); + action = filteringaction_new(action_type, 0, NULL, 0); } | MATCHER_UNMARK { gint action_type = 0; action_type = MATCHACTION_UNMARK; - action = filteringaction_new(action_type, 0, NULL); + action = filteringaction_new(action_type, 0, NULL, 0); } | MATCHER_MARK_AS_READ { gint action_type = 0; action_type = MATCHACTION_MARK_AS_READ; - action = filteringaction_new(action_type, 0, NULL); + action = filteringaction_new(action_type, 0, NULL, 0); } | MATCHER_MARK_AS_UNREAD { gint action_type = 0; action_type = MATCHACTION_MARK_AS_UNREAD; - action = filteringaction_new(action_type, 0, NULL); + action = filteringaction_new(action_type, 0, NULL, 0); } | MATCHER_FORWARD MATCHER_INTEGER MATCHER_STRING { @@ -727,9 +796,9 @@ MATCHER_EXECUTE MATCHER_STRING gint account_id = 0; action_type = MATCHACTION_FORWARD; - account_id = $2; + account_id = atoi($2); destination = $3; - action = filteringaction_new(action_type, account_id, destination); + action = filteringaction_new(action_type, account_id, destination, 0); } | MATCHER_FORWARD_AS_ATTACHMENT MATCHER_INTEGER MATCHER_STRING { @@ -738,9 +807,35 @@ MATCHER_EXECUTE MATCHER_STRING gint account_id = 0; action_type = MATCHACTION_FORWARD_AS_ATTACHMENT; - account_id = $2; + account_id = atoi($2); + destination = $3; + action = filteringaction_new(action_type, account_id, destination, 0); +} +| MATCHER_BOUNCE MATCHER_INTEGER MATCHER_STRING +{ + gchar * destination = NULL; + gint action_type = 0; + gint account_id = 0; + + action_type = MATCHACTION_BOUNCE; + account_id = atoi($2); destination = $3; - action = filteringaction_new(action_type, account_id, destination); + action = filteringaction_new(action_type, account_id, destination, 0); +} +| MATCHER_COLOR MATCHER_INTEGER +{ + gint action_type = 0; + gint color = 0; + + action_type = MATCHACTION_COLOR; + color = atoi($2); + action = filteringaction_new(action_type, 0, NULL, color); +} +| MATCHER_DELETE_ON_SERVER +{ + gint action_type = 0; + action_type = MATCHACTION_DELETE_ON_SERVER; + action = filteringaction_new(action_type, 0, NULL, 0); } ;