Added users for symconst.
[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
25
26 #include <stdio.h>
27
28 #include "lc_parser_t.h"
29 #include "lc_config_parser.h"
30
31 static int _lc_opt_wrap(void)
32 {
33         return 1;
34 }
35
36 %}
37
38 num             [0-9]+
39 hexnum          0x[0-9a-fA-F]+
40 idcharsbegin    [a-zA-Z$_]
41 idchars         ({idcharsbegin}|[0-9])
42 ident           {idcharsbegin}{idchars}*
43 ws              [\t ]*
44 nl              \n
45
46 %x LINE_COMMENT
47 %x BIG_COMMENT
48 %x DAT
49 %x DAT_CONT
50 %x STR
51
52
53 %%
54
55 "/*"                { BEGIN(BIG_COMMENT); }
56 <BIG_COMMENT>"*/"   { BEGIN(INITIAL); }
57 <BIG_COMMENT>\n     PMANGLE(linenr)++;
58 <BIG_COMMENT>.      ;
59
60 ("#"|"//")          { BEGIN(LINE_COMMENT); }
61 <LINE_COMMENT>\n    { BEGIN(INITIAL); PMANGLE(linenr)++; }
62 <LINE_COMMENT>.     ;
63
64
65 <INITIAL>[=:]{ws}   { BEGIN(DAT); }
66 <DAT>\"             { BEGIN(STR); }
67 <DAT>\\             { BEGIN(DAT_CONT); }
68 <DAT>.              { _lc_opt_add_to_data_char(PMANGLE(text)[0]); }
69 <DAT>\n             {
70                                                 BEGIN(INITIAL);
71                                                 PMANGLE(linenr)++;
72                                                 _lc_opt_add_to_data_char('\0');
73                                                 return DATA;
74                                         }
75 <DAT_CONT>\n        { BEGIN(DAT); PMANGLE(linenr)++; }
76 <DAT_CONT>.         ;
77
78
79 <STR>\"             {
80                                                 BEGIN(INITIAL);
81                                                 _lc_opt_add_to_data_char('\0');
82                                                 return DATA;
83                                         }
84
85 <STR>\\n            _lc_opt_add_to_data_char('\n');
86 <STR>\\r            _lc_opt_add_to_data_char('\r');
87 <STR>\\t            _lc_opt_add_to_data_char('\t');
88 <STR>\\b            _lc_opt_add_to_data_char('\b');
89 <STR>\\f            _lc_opt_add_to_data_char('\f');
90 <STR>\\.            _lc_opt_add_to_data_char(yytext[1]);
91 <STR>[^\"]          _lc_opt_add_to_data_char(yytext[0]);
92
93 {ident}                         {
94                                                 PMANGLE(lval).text.str = PMANGLE(text);
95                                                 PMANGLE(lval).text.len = PMANGLE(leng);
96                                                 return IDENT;
97                                         }
98 [/.]                { return SEP; }
99
100 {ws}                ;
101 {nl}                PMANGLE(linenr)++;
102
103 .                   return yytext[0];
104
105 %%