1%{ 2/* 3 * Copyright (c) 2003 4 * Bill Paul <wpaul@windriver.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Bill Paul. 17 * 4. Neither the name of the author nor the names of any co-contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h>
| 1%{ 2/* 3 * Copyright (c) 2003 4 * Bill Paul <wpaul@windriver.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Bill Paul. 17 * 4. Neither the name of the author nor the names of any co-contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h>
|
62%% 63 64[ \t]+ ; 65\n { lineno++; return EOL; } 66\r ; 67;.*$ ; 68\/\/.*$ ; 69= { return EQUALS; } 70, { return COMMA; } 71\"(\\\"|[^"]|\"\")*\" { 72 int len = strlen(yytext) - 2; 73 int blen = len + 1; 74 char *walker; 75 int i; 76 update_lineno(yytext); 77 yylval.str = (char *)malloc(blen); 78 if (yylval.str == NULL) 79 goto out; 80 walker = yylval.str; 81 for (i = 1; i <= len; i++) { 82 if (yytext[i] == '\"') { 83 switch (yytext[i + 1]) { 84 case '\"': 85 i++; 86 break; 87 default: 88 break; 89 } 90 } 91 if (yytext[i] == '\\') { 92 switch (yytext[i + 1]) { 93 case '\n': 94 i += 2; 95 while(isspace(yytext[i])) 96 i++; 97 break; 98 case '\"': 99 i++; 100 break; 101 case '(': 102 i++; 103 break; 104 default: 105 break; 106 } 107 } 108 *walker++ = yytext[i]; 109 } 110 *walker++ = '\0'; 111 out:; 112 return STRING; 113 } 114\[[a-zA-Z0-9%&\{\}\-\.\/_\\\*\ ]+\] { 115 int len = strlen(yytext); 116 yytext[len-1] = '\0'; 117 yylval.str = strdup(yytext+1); 118 return SECTION; 119 } 120[a-zA-Z0-9%&\{\}\-\.\/_\\\*]+ { 121 yylval.str = strdup(yytext); 122 return WORD; 123 } 124%% 125 126void 127yyerror(const char *s) 128{ 129 errx(1, "line %d: %s%s %s.", lineno, yytext, yytext?":":"", s); 130}
| 63%% 64 65[ \t]+ ; 66\n { lineno++; return EOL; } 67\r ; 68;.*$ ; 69\/\/.*$ ; 70= { return EQUALS; } 71, { return COMMA; } 72\"(\\\"|[^"]|\"\")*\" { 73 int len = strlen(yytext) - 2; 74 int blen = len + 1; 75 char *walker; 76 int i; 77 update_lineno(yytext); 78 yylval.str = (char *)malloc(blen); 79 if (yylval.str == NULL) 80 goto out; 81 walker = yylval.str; 82 for (i = 1; i <= len; i++) { 83 if (yytext[i] == '\"') { 84 switch (yytext[i + 1]) { 85 case '\"': 86 i++; 87 break; 88 default: 89 break; 90 } 91 } 92 if (yytext[i] == '\\') { 93 switch (yytext[i + 1]) { 94 case '\n': 95 i += 2; 96 while(isspace(yytext[i])) 97 i++; 98 break; 99 case '\"': 100 i++; 101 break; 102 case '(': 103 i++; 104 break; 105 default: 106 break; 107 } 108 } 109 *walker++ = yytext[i]; 110 } 111 *walker++ = '\0'; 112 out:; 113 return STRING; 114 } 115\[[a-zA-Z0-9%&\{\}\-\.\/_\\\*\ ]+\] { 116 int len = strlen(yytext); 117 yytext[len-1] = '\0'; 118 yylval.str = strdup(yytext+1); 119 return SECTION; 120 } 121[a-zA-Z0-9%&\{\}\-\.\/_\\\*]+ { 122 yylval.str = strdup(yytext); 123 return WORD; 124 } 125%% 126 127void 128yyerror(const char *s) 129{ 130 errx(1, "line %d: %s%s %s.", lineno, yytext, yytext?":":"", s); 131}
|