1 /* 2 * COPYRIGHT (c) International Business Machines Corp. 2013-2017 3 * 4 * This program is provided under the terms of the Common Public License, 5 * version 1.0 (CPL-1.0). Any use, reproduction or distribution for this 6 * software constitutes recipient's acceptance of CPL-1.0 terms which can be 7 * found in the file LICENSE file or at 8 * https://opensource.org/licenses/cpl1.0.php 9 */ 10 11 %{ 12 #include <string.h> 13 #include "icsf_config_parse.h" 14 15 /* Ignore -Wsign-compare for autogenerated code. */ 16 #pragma GCC diagnostic ignored "-Wsign-compare" 17 18 extern void yyerror(const char *s); 19 20 %} 21 22 %option noyywrap 23 %option nounput 24 %option noinput 25 26 %% 27 28 [\t\n ]+ { 29 /* Ignore spaces */ 30 } 31 32 #.*\n { 33 /* Comment */ 34 } 35 36 slot { 37 /* Identify a definition */ 38 return SLOT; 39 } 40 41 [0-9]+ { 42 /* Number */ 43 yylval.num = strtoul(yytext, NULL, 10); 44 return INTEGER; 45 } 46 47 \{ { 48 /* Open definition */ 49 return BEGIN_DEF; 50 } 51 52 \} { 53 /* Close definition */ 54 return END_DEF; 55 } 56 57 = { 58 /* Assignment */ 59 return EQUAL; 60 } 61 62 [^\"= \t\n]+ { 63 /* String */ 64 yylval.str = strdup(yytext); 65 return STRING; 66 } 67 68 \"[^\"\n]*\" { 69 /* Quoted string */ 70 yylval.str = strdup(yytext + 1); 71 if (yylval.str && yylval.str[0]) 72 yylval.str[strlen(yylval.str) - 1] = '\0'; 73 return STRING; 74 } 75 76 . { 77 /* Default */ 78 yyerror(yytext); 79 } 80 81 %% 82