X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fscanner.l;h=aa111a2933b7fef756ec40dd96707e9d62d7471c;hb=d7ead7bd0d32daa0b8ca55213b18ba7e327648f0;hp=12055087d6ae5404572ce2e54066aae4b8c2cec2;hpb=5c7aa9c49ae9928ea26c4baa50d92bbbd16d5b64;p=liboconfig.git diff --git a/src/scanner.l b/src/scanner.l index 1205508..aa111a2 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -1,3 +1,21 @@ +/** + * oconfig - src/scanner.l + * Copyright (C) 2007 Florian octo Forster + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; only version 2 of the License is applicable. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + %{ #include #include "oconfig.h" @@ -5,9 +23,8 @@ #include "parser.h" %} WHITE_SPACE [\ \t\b] -ALNUM [A-Za-z0-9_] -QUOTED_STRING \"([^\"]+|\\.)*\" -UNQUOTED_STRING {ALNUM}+ +QUOTED_STRING \"([^\\"]+|\\.)*\" +UNQUOTED_STRING [0-9A-Za-z_]+ HEX_NUMBER 0[xX][0-9a-fA-F]+ OCT_NUMBER 0[0-7]+ DEC_NUMBER [\+\-]?[0-9]+ @@ -16,20 +33,25 @@ NUMBER ({FLOAT_NUMBER}|{HEX_NUMBER}|{OCT_NUMBER}|{DEC_NUMBER}) BOOL_TRUE (true|yes|on) BOOL_FALSE (false|no|off) COMMENT #.* +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]?) +IP_BYTE (2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]) +IPV4_ADDR {IP_BYTE}\.{IP_BYTE}\.{IP_BYTE}\.{IP_BYTE}(:{PORT})? %% -{WHITE_SPACE} | -{COMMENT} {/* nothing */} +{WHITE_SPACE} | +{COMMENT} {/* ignore */} \n {return (EOL);} "/" {return (SLASH);} "<" {return (OPENBRAC);} ">" {return (CLOSEBRAC);} -{NUMBER} {yylval.number = strtod (yytext, NULL); return (NUMBER);} {BOOL_TRUE} {yylval.boolean = 1; return (TRUE);} {BOOL_FALSE} {yylval.boolean = 0; return (FALSE);} +{IPV4_ADDR} {yylval.string = yytext; return (UNQUOTED_STRING);} + +{NUMBER} {yylval.number = strtod (yytext, NULL); return (NUMBER);} + {QUOTED_STRING} {yylval.string = yytext; return (QUOTED_STRING);} {UNQUOTED_STRING} {yylval.string = yytext; return (UNQUOTED_STRING);} - %%