Debian Codegraph @

src/tools/dlgedit/loadcfg.l

raw
1 %{
2 /*
3 Copyright (C) 2002 Kai Sterker <[email protected]>
4 Part of the Adonthell Project <http://adonthell.nongnu.org>
5
6 Dlgedit 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.
10
11 Dlgedit 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.
15
16 You should have received a copy of the GNU General Public License
17 along with Dlgedit. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <math.h>
21 #include <string>
22 #include "dlg_types.h"
23
24 #define YY_DECL int parse_cfgfile (std::string &mytext, int &mynum)
25 %}
26
27 digit [0-9]
28 num -?{digit}+
29
30 %x text
31 %option noyywrap nounput never-interactive prefix="loadcfg"
32
33 %%
34
35 "#".*[\n]? ; /* Eat up comments */
36
37 File return LOAD_FILE;
38 Project return LOAD_PROJECT;
39 BaseDir return LOAD_BASE_DIR;
40 End return LOAD_END;
41
42 \[ mytext = ""; BEGIN(text);
43 <text>\] BEGIN(INITIAL); return LOAD_STR;
44 <text>[^\]]+ mytext += yytext;
45
46 {num} mynum = atoi (yytext); return LOAD_NUM;
47
48 [ \t\n]+ ; /* Eat whitespace */
49 . return LOAD_UNKNOWN;