make firm (mostly) -Wmissing-prototypes clean
[libfirm] / ir / libcore / lc_config_lexer.l
1
2 %option prefix="_lc_opt_"
3
4 %{
5
6 /*
7   libcore: library for basic data structures and algorithms.
8   Copyright (C) 2005  IPD Goos, Universit"at Karlsruhe, Germany
9
10   This library is free software; you can redistribute it and/or
11   modify it under the terms of the GNU Lesser General Public
12   License as published by the Free Software Foundation; either
13   version 2.1 of the License, or (at your option) any later version.
14
15   This library is distributed in the hope that it will be useful,
16   but WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public
21   License along with this library; if not, write to the Free Software
22   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 */
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <stdio.h>
29
30 #include "lc_parser_t.h"
31 #include "lc_config_parser.h"
32
33 static int _lc_opt_wrap(void);
34
35 %}
36
37 num             [0-9]+
38 hexnum          0x[0-9a-fA-F]+
39 idcharsbegin    [a-zA-Z$_]
40 idchars         ({idcharsbegin}|[0-9])
41 ident           {idcharsbegin}{idchars}*
42 ws              [\t ]*
43 nl              \n
44
45 %x LINE_COMMENT
46 %x BIG_COMMENT
47 %x DAT
48 %x DAT_CONT
49 %x STR
50
51
52 %%
53
54 "/*"                { BEGIN(BIG_COMMENT); }
55 <BIG_COMMENT>"*/"   { BEGIN(INITIAL); }
56 <BIG_COMMENT>\n     PMANGLE(linenr)++;
57 <BIG_COMMENT>.      ;
58
59 ("#"|"//")          { BEGIN(LINE_COMMENT); }
60 <LINE_COMMENT>\n    { BEGIN(INITIAL); PMANGLE(linenr)++; }
61 <LINE_COMMENT>.     ;
62
63
64 <INITIAL>[=:]{ws}   { BEGIN(DAT); }
65 <DAT>\"             { BEGIN(STR); }
66 <DAT>\\             { BEGIN(DAT_CONT); }
67 <DAT>.              { _lc_opt_add_to_data_char(PMANGLE(text)[0]); }
68 <DAT>\n             {
69                                                 BEGIN(INITIAL);
70                                                 PMANGLE(linenr)++;
71                                                 _lc_opt_add_to_data_char('\0');
72                                                 return DATA;
73                                         }
74 <DAT_CONT>\n        { BEGIN(DAT); PMANGLE(linenr)++; }
75 <DAT_CONT>.         ;
76
77
78 <STR>\"             {
79                                                 BEGIN(INITIAL);
80                                                 _lc_opt_add_to_data_char('\0');
81                                                 return DATA;
82                                         }
83
84 <STR>\\n            _lc_opt_add_to_data_char('\n');
85 <STR>\\r            _lc_opt_add_to_data_char('\r');
86 <STR>\\t            _lc_opt_add_to_data_char('\t');
87 <STR>\\b            _lc_opt_add_to_data_char('\b');
88 <STR>\\f            _lc_opt_add_to_data_char('\f');
89 <STR>\\.            _lc_opt_add_to_data_char(yytext[1]);
90 <STR>[^\"]          _lc_opt_add_to_data_char(yytext[0]);
91
92 {ident}                         {
93                                                 PMANGLE(lval).text.str = PMANGLE(text);
94                                                 PMANGLE(lval).text.len = PMANGLE(leng);
95                                                 return IDENT;
96                                         }
97 [/.]                { return SEP; }
98
99 {ws}                ;
100 {nl}                PMANGLE(linenr)++;
101
102 .                   return yytext[0];
103
104 %%
105
106 static int _lc_opt_wrap(void)
107 {
108         /* avoid warning */
109         (void) yyunput;
110         (void) input;
111         return 1;
112 }