3 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
4 * Copyright (c) 2001-2002 by Hiroyuki Yamamoto & The Sylpheed Claws Team.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include "matcher_parser_lex.h"
28 #include "matcher_parser_parse.h"
30 #define MAX_STR_CONST 512
33 static char string_buf[MAX_STR_CONST];
34 static char *string_buf_ptr;
36 static void add_char(char ch)
38 if (string_buf_ptr - string_buf < sizeof(string_buf))
39 *string_buf_ptr++ = ch;
43 /* this function will reinitializes the parser */
45 void matcher_parser_init(void)
51 %option prefix="matcher_parser"
52 %option outfile="lex.yy.c"
61 * a keyword consists of alpha and underscore
62 * characters, possibly preceded by a tilde (~)
68 if (-1 == (id = get_matchparser_tab_id(yytext))) {
74 "\n" return MATCHER_EOL;
75 "&" return MATCHER_AND;
76 "|" return MATCHER_OR;
79 string_buf_ptr = string_buf;
82 /* get out of the state: string ends. */
84 *string_buf_ptr = '\0';
85 if (!g_utf8_validate(string_buf, -1, NULL)) {
86 gchar *tmp = conv_codeset_strdup(string_buf, conv_get_locale_charset_str(), CS_INTERNAL);
88 strcpy(string_buf, tmp);
92 yylval.str = string_buf;
93 return MATCHER_STRING;
96 /* take care of quoted characters */
103 /* for section name in configuration file */
105 yylval.str = yytext + 1;
106 yytext[strlen(yytext) - 1] = '\0';
107 return MATCHER_SECTION;
111 return MATCHER_INTEGER;
114 return MATCHER_RULENAME;
117 return MATCHER_DISABLED;
120 return MATCHER_ENABLED;