1 %{ 2 /** 3 * This file is part of the Detox package. 4 * 5 * Copyright (c) Doug Harple <detox.dharple@gmail.com> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11 #include "config.h" 12 13 #include <string.h> 14 #include <stdlib.h> 15 16 #include "config_file_yacc.h" 17 18 int config_file_lineno = 1; 19 20 %} 21 22 %option noyywrap 23 24 %% 25 26 [\t ]+ { /* ignore whitespace */ } 27 28 #.* { /* ignore comments */ } 29 30 \n { config_file_lineno++; } 31 32 [Ss][Ee][Qq][Uu][Ee][Nn][Cc][Ee] { return SEQUENCE; } 33 34 [Ii][Gg][Nn][Oo][Rr][Ee] { return IGNORE; } 35 36 [Uu][Nn][Cc][Gg][Ii] { return UNCGI; } 37 38 [Ii][Ss][Oo]8859_1 { return ISO8859_1; } 39 40 [Uu][Tt][Ff]_8 { return UTF_8; } 41 42 [Ss][Aa][Ff][Ee] { return SAFE; } 43 44 [Ww][Ii][Pp][Ee][Uu][Pp] { return WIPEUP; } 45 46 [Mm][Aa][Xx]_[Ll][Ee][Nn][Gg][Tt][Hh] { return MAX_LENGTH; } 47 48 [Ll][Oo][Ww][Ee][Rr] { return LOWER; } 49 50 [Ll][Ee][Nn][Gg][Tt][Hh] { return LENGTH; } 51 52 [Ff][Ii][Ll][Ee][Nn][Aa][Mm][Ee] { return FILENAME; } 53 54 [Rr][Ee][Mm][Oo][Vv][Ee]_[Tt][Rr][Aa][Ii][Ll][Ii][Nn][Gg] { return REMOVE_TRAILING; } 55 56 [{] { return OPEN; } 57 [}] { return CLOSE; } 58 59 \"[^\"\n]*[\"\n] { 60 yylval.string = strdup(yytext+1); 61 if (yylval.string[yyleng-2] != '"') { 62 printf("Unterminated character string\n"); 63 } 64 else { 65 yylval.string[yyleng-2] = '\0'; 66 } 67 return QSTRING; 68 } 69 70 [a-zA-Z][a-zA-Z0-9_]* { 71 yylval.string = strdup(yytext); 72 return ID; 73 } 74 75 [0-9]+ { 76 yylval.nvalue = atoi(yytext); 77 return NVALUE; 78 } 79 80 81 82 [;] { return EOL; } 83 84 %% 85 86