fix trailing whitespaces and tabulators in the middle of a line
[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 #define YY_NO_UNISTD_H
34
35 static int _lc_opt_wrap(void);
36
37 %}
38
39 num             [0-9]+
40 hexnum          0x[0-9a-fA-F]+
41 idcharsbegin    [a-zA-Z$_]
42 idchars         ({idcharsbegin}|[0-9])
43 ident           {idcharsbegin}{idchars}*
44 ws              [\t ]*
45 nl              \n
46
47 %x LINE_COMMENT
48 %x BIG_COMMENT
49 %x DAT
50 %x DAT_CONT
51 %x STR
52
53
54 %%
55
56 "/*"                { BEGIN(BIG_COMMENT); }
57 <BIG_COMMENT>"*/"   { BEGIN(INITIAL); }
58 <BIG_COMMENT>\n     PMANGLE(linenr)++;
59 <BIG_COMMENT>.      ;
60
61 ("#"|"//")          { BEGIN(LINE_COMMENT); }
62 <LINE_COMMENT>\n    { BEGIN(INITIAL); PMANGLE(linenr)++; }
63 <LINE_COMMENT>.     ;
64
65
66 <INITIAL>[=:]{ws}   { BEGIN(DAT); }
67 <DAT>\"             { BEGIN(STR); }
68 <DAT>\\             { BEGIN(DAT_CONT); }
69 <DAT>.              { _lc_opt_add_to_data_char(PMANGLE(text)[0]); }
70 <DAT>\n             {
71                                                 BEGIN(INITIAL);
72                                                 PMANGLE(linenr)++;
73                                                 _lc_opt_add_to_data_char('\0');
74                                                 return DATA;
75                                         }
76 <DAT_CONT>\n        { BEGIN(DAT); PMANGLE(linenr)++; }
77 <DAT_CONT>.         ;
78
79
80 <STR>\"             {
81                                                 BEGIN(INITIAL);
82                                                 _lc_opt_add_to_data_char('\0');
83                                                 return DATA;
84                                         }
85
86 <STR>\\n            _lc_opt_add_to_data_char('\n');
87 <STR>\\r            _lc_opt_add_to_data_char('\r');
88 <STR>\\t            _lc_opt_add_to_data_char('\t');
89 <STR>\\b            _lc_opt_add_to_data_char('\b');
90 <STR>\\f            _lc_opt_add_to_data_char('\f');
91 <STR>\\.            _lc_opt_add_to_data_char(yytext[1]);
92 <STR>[^\"]          _lc_opt_add_to_data_char(yytext[0]);
93
94 {ident}                         {
95                                                 PMANGLE(lval).text.str = PMANGLE(text);
96                                                 PMANGLE(lval).text.len = PMANGLE(leng);
97                                                 return IDENT;
98                                         }
99 [/.]                { return SEP; }
100
101 {ws}                ;
102 {nl}                PMANGLE(linenr)++;
103
104 .                   return yytext[0];
105
106 %%
107
108 static int _lc_opt_wrap(void)
109 {
110         /* avoid warning */
111         (void) yyunput;
112         (void) input;
113         return 1;
114 }