1 %option nounput never-interactive
5 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
6 * Copyright (c) 2001-2007 by Hiroyuki Yamamoto & The Claws Mail Team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "matcher_parser_lex.h"
31 #include "matcher_parser_parse.h"
34 #define MAX_STR_CONST 8192
36 static char string_buf[MAX_STR_CONST];
37 static char *string_buf_ptr;
39 static void add_char(char ch)
41 if (string_buf_ptr - string_buf < sizeof(string_buf))
42 *string_buf_ptr++ = ch;
46 /* this function will reinitializes the parser */
48 void matcher_parser_init(void)
54 %option prefix="matcher_parser"
55 %option outfile="lex.yy.c"
63 "in" return MATCHER_IN;
66 * a keyword consists of alpha and underscore
67 * characters, possibly preceded by a tilde (~)
73 if (-1 == (id = get_matchparser_tab_id(yytext))) {
79 "\n" return MATCHER_EOL;
80 "&" return MATCHER_AND;
81 "|" return MATCHER_OR;
84 string_buf_ptr = string_buf;
87 /* get out of the state: string ends. */
89 *string_buf_ptr = '\0';
90 if (!g_utf8_validate(string_buf, -1, NULL)) {
91 gchar *tmp = conv_codeset_strdup(string_buf, conv_get_locale_charset_str(), CS_INTERNAL);
93 g_strlcpy(string_buf, tmp, sizeof(string_buf));
97 yylval.str = string_buf;
98 return MATCHER_STRING;
101 /* take care of quoted characters */
108 /* for section name in configuration file */
110 yylval.str = yytext + 1;
111 yytext[strlen(yytext) - 1] = '\0';
112 return MATCHER_SECTION;
116 return MATCHER_INTEGER;
119 return MATCHER_RULENAME;
122 return MATCHER_DISABLED;
125 return MATCHER_ACCOUNT;
128 return MATCHER_ENABLED;