2 * oconfig - src/scanner.l
3 * Copyright (C) 2007 Florian octo Forster <octo at verplant.org>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; only version 2 of the License is applicable.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include "aux_types.h"
27 QUOTED_STRING \"([^\\"]+|\\.)*\"
28 UNQUOTED_STRING [0-9A-Za-z_]+
29 HEX_NUMBER 0[xX][0-9a-fA-F]+
31 DEC_NUMBER [\+\-]?[0-9]+
32 FLOAT_NUMBER [\+\-]?[0-9]*\.[0-9]+([eE][\+\-][0-9]+)?
33 NUMBER ({FLOAT_NUMBER}|{HEX_NUMBER}|{OCT_NUMBER}|{DEC_NUMBER})
34 BOOL_TRUE (true|yes|on)
35 BOOL_FALSE (false|no|off)
37 PORT (6(5(5(3[0-5]|[0-2][0-9])|[0-4][0-9][0-9])|[0-4][0-9][0-9][0-9])|[1-5][0-9][0-9][0-9][0-9]|[1-9][0-9]?[0-9]?[0-9]?)
38 IP_BYTE (2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])
39 IPV4_ADDR {IP_BYTE}\.{IP_BYTE}\.{IP_BYTE}\.{IP_BYTE}(:{PORT})?
43 {COMMENT} {/* ignore */}
47 "<" {return (OPENBRAC);}
48 ">" {return (CLOSEBRAC);}
49 {BOOL_TRUE} {yylval.boolean = 1; return (TRUE);}
50 {BOOL_FALSE} {yylval.boolean = 0; return (FALSE);}
52 {IPV4_ADDR} {yylval.string = yytext; return (UNQUOTED_STRING);}
54 {NUMBER} {yylval.number = strtod (yytext, NULL); return (NUMBER);}
56 {QUOTED_STRING} {yylval.string = yytext; return (QUOTED_STRING);}
57 {UNQUOTED_STRING} {yylval.string = yytext; return (UNQUOTED_STRING);}