head 1.26; access; symbols FSL_1_7_0:1.26 CFG_0_9_11:1.26 FSL_1_6_1:1.24 CFG_0_9_10:1.24 FSL_1_6_0:1.24 FSL_1_6b2:1.24 CFG_0_9_9:1.24 FSL_1_6b1:1.24 CFG_0_9_8:1.24 CFG_0_9_7:1.23 CFG_0_9_6:1.23 CFG_0_9_5:1.20 CFG_0_9_4:1.18 FSL_1_5_0:1.17 FSL_1_5a3:1.17 CFG_0_9_3:1.17 FSL_1_5a2:1.17 FSL_1_5a1:1.17 FSL_1_4_0:1.17 FSL_1_4b1:1.17 CFG_0_9_2:1.17 CFG_0_9_1:1.17 FSL_1_4a1:1.16 FSL_1_3_0:1.16 FSL_1_3b1:1.16 FSL_1_2_1:1.16 FSL_1_2_0:1.16 FSL_1_1_0:1.16 FSL_1_1b1:1.16 FSL_1_0_8:1.16 FSL_1_0_7:1.16 FSL_1_0_6:1.12 FSL_1_0_5:1.11 FSL_1_0_4:1.11 FSL_1_0_3:1.11 FSL_1_0_2:1.11 FSL_1_0_1:1.11 FSL_1_0_0:1.11 FSL_0_9_0:1.11 CFG_0_9_0:1.11 FSL_0_1_12:1.11 FSL_0_1_11:1.11 FSL_0_1_10:1.11 FSL_0_1_9:1.11 FSL_0_1_8:1.11 FSL_0_1_7:1.11 FSL_0_1_6:1.11 FSL_0_1_5:1.11 FSL_0_1_1:1.10; locks; strict; comment @ * @; 1.26 date 2006.08.10.19.35.57; author rse; state Exp; branches; next 1.25; commitid Isy241gp4yykKkIr; 1.25 date 2006.08.01.20.13.49; author rse; state Exp; branches; next 1.24; commitid 3vdGctd4mFJffbHr; 1.24 date 2004.12.31.19.16.25; author rse; state Exp; branches; next 1.23; 1.23 date 2004.11.29.07.09.33; author rse; state Exp; branches; next 1.22; 1.22 date 2004.11.28.17.28.27; author rse; state Exp; branches; next 1.21; 1.21 date 2004.11.28.17.23.45; author rse; state Exp; branches; next 1.20; 1.20 date 2004.11.20.12.54.07; author rse; state Exp; branches; next 1.19; 1.19 date 2004.11.20.11.42.21; author rse; state Exp; branches; next 1.18; 1.18 date 2004.07.17.07.37.55; author rse; state Exp; branches; next 1.17; 1.17 date 2003.11.06.15.25.10; author thl; state Exp; branches; next 1.16; 1.16 date 2003.01.06.11.17.43; author rse; state Exp; branches; next 1.15; 1.15 date 2003.01.06.11.08.26; author rse; state Exp; branches; next 1.14; 1.14 date 2002.11.18.09.51.29; author rse; state Exp; branches; next 1.13; 1.13 date 2002.11.10.12.12.23; author rse; state Exp; branches; next 1.12; 1.12 date 2002.11.09.14.34.01; author rse; state Exp; branches; next 1.11; 1.11 date 2002.07.25.07.49.55; author rse; state Exp; branches; next 1.10; 1.10 date 2002.07.17.18.47.09; author rse; state Exp; branches; next 1.9; 1.9 date 2002.07.17.14.48.08; author rse; state Exp; branches; next 1.8; 1.8 date 2002.07.10.12.00.23; author rse; state Exp; branches; next 1.7; 1.7 date 2002.07.08.13.45.13; author rse; state Exp; branches; next 1.6; 1.6 date 2002.07.06.18.44.46; author rse; state Exp; branches; next 1.5; 1.5 date 2002.07.05.20.49.58; author rse; state Exp; branches; next 1.4; 1.4 date 2002.07.05.18.32.37; author rse; state Exp; branches; next 1.3; 1.3 date 2002.07.05.15.11.20; author rse; state Exp; branches; next 1.2; 1.2 date 2002.07.05.14.33.10; author rse; state Exp; branches; next 1.1; 1.1 date 2002.07.03.13.25.34; author rse; state Exp; branches; next ; desc @@ 1.26 log @cleanup source tree for status as of 2006 @ text @%{ /* ** OSSP cfg - Configuration Parsing ** Copyright (c) 2002-2006 Ralf S. Engelschall ** Copyright (c) 2002-2006 The OSSP Project (http://www.ossp.org/) ** ** This file is part of OSSP cfg, a configuration parsing ** library which can be found at http://www.ossp.org/pkg/lib/cfg/. ** ** Permission to use, copy, modify, and distribute this software for ** any purpose with or without fee is hereby granted, provided that ** the above copyright notice and this permission notice appear in all ** copies. ** ** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED ** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF ** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF ** USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** ** cfg_syn_scan.l: regular grammar specification for GNU Flex ** ** ATTENTION: This requires GNU Flex 2.5.10 or newer! */ #include #include #include #include "cfg.h" #include "cfg_global.h" #include "cfg_buf.h" #include "cfg_syn.h" #include "cfg_syn_parse.h" /* how to find our own context */ #define CTX ((cfg_syn_ctx_t *)yyget_extra(yyscanner)) /* provide own input handling */ #undef YY_INPUT #define YY_INPUT(buf,result,max_size) (result = yyinput(CTX, buf, max_size)) static int yyinput(cfg_syn_ctx_t *ctx, char *buf, int max_size); /* location tracking */ #define YY_USER_INIT \ yylloc->first = 0; \ yylloc->last = 0; #define YY_USER_ACTION \ yylloc->first = yylloc->last; \ yylloc->last += yyleng; #define YY_USER_ACTION_ROLLBACK \ yylloc->last = yylloc->first static char closing_brace(char open); static int hex_nibble(const char hex); static int hex_sequence(cfg_syn_ctx_t *ctx, const char *in_ptr, size_t in_len); %} /* scanner options */ %pointer %option stack %option reentrant %option bison-bridge %option bison-locations %option never-interactive %option noyywrap %option nounput %option noyy_top_state %option nounistd /* scanner states */ %x SS_DQ %x SS_SQ %x SS_FQ %x SS_PT %x SS_CO_C /* the delimiting character for flexible quoting has to one a special character c, i.e., one of !"#$%&'()*+,-./:;<=>?@@[\]^_`{|}~ or in C code: isprint(c) && !isspace(c) && !iscntrl(c) && !isalpha(i) && !isdigit(i) */ FQDEL [\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@@\[\\\]\^\_\`\{\|\}\~] FQDELN [^\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@@\[\\\]\^\_\`\{\|\}\~] %% /* local variables */ int nCommentOpen = 0; int nQuoteOpen = 0; char cQuoteOpen = '\0'; char cQuoteClose = '\0'; /* whitespaces */ [ \t\n]+ { /* no-op */ } /* C-style block comment */ "/*" { nCommentOpen = 1; BEGIN(SS_CO_C); } "/*" { nCommentOpen++; } "*/" { nCommentOpen--; if (nCommentOpen == 0) BEGIN(INITIAL); } (.|\n) { /* no-op */ } <> { cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated C-style block comment"); yyterminate(); } /* C++-style EOL comment */ "//"[^\n]* { /* no-op */ } /* Shell-style EOL comment */ "#"[^\n]* { /* no-op */ } /* double-quoted word ("...") */ \" { cfg_buf_resize(CTX->buf, 0); BEGIN(SS_DQ); } \" { cfg_buf_content(CTX->buf, &yylval->cpString, NULL, NULL); BEGIN(INITIAL); return T_STRING; } \\\n[ \t]* { /* no-op */ } \\[0-7]{1,3} { unsigned int result; (void)sscanf(yytext+1, "%o", &result); if (result > 0xff) { cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "escape sequence out of bound"); yyterminate(); } cfg_buf_append(CTX->buf, NULL, 0, (char)result); } \\x\{[0-9a-fA-F]+\} { if (!hex_sequence(CTX, yytext+3, yyleng-3-1)) yyterminate(); } \\x[0-9a-fA-F]{2} { if (!hex_sequence(CTX, yytext+2, 2)) yyterminate(); } \\n { cfg_buf_append(CTX->buf, NULL, 0, '\n'); } \\r { cfg_buf_append(CTX->buf, NULL, 0, '\r'); } \\t { cfg_buf_append(CTX->buf, NULL, 0, '\t'); } \\b { cfg_buf_append(CTX->buf, NULL, 0, '\b'); } \\f { cfg_buf_append(CTX->buf, NULL, 0, '\f'); } \\a { cfg_buf_append(CTX->buf, NULL, 0, '\007'); } \\e { cfg_buf_append(CTX->buf, NULL, 0, '\033'); } \\(.|\n) { cfg_buf_append(CTX->buf, NULL, 0, yytext[1]); } [^\\\"]+ { cfg_buf_append(CTX->buf, yytext, yyleng, 0); } (.|\n) { cfg_buf_append(CTX->buf, NULL, 0, yytext[0]); } <> { cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated double-quoted string"); yyterminate(); } /* single-quoted word ('...') */ \' { cfg_buf_resize(CTX->buf, 0); BEGIN(SS_SQ); } \' { cfg_buf_content(CTX->buf, &yylval->cpString, NULL, NULL); BEGIN(INITIAL); return T_STRING; } \\\n[ \t]* { /* no-op */ } \\[\\\'] { cfg_buf_append(CTX->buf, NULL, 0, yytext[1]); } \\[^\\\'] { cfg_buf_append(CTX->buf, yytext, yyleng, 0); } [^\\\']+ { cfg_buf_append(CTX->buf, yytext, yyleng, 0); } (.|\n) { cfg_buf_append(CTX->buf, NULL, 0, yytext[0]); } <> { cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated single-quoted string"); yyterminate(); } /* flexible-quoted word (q(.)[^\1]\1) */ "q"{FQDEL} { cfg_buf_resize(CTX->buf, 0); nQuoteOpen = 1; cQuoteOpen = yytext[1]; cQuoteClose = closing_brace(yytext[1]); BEGIN(SS_FQ); } \\{FQDEL} { if (yytext[1] == cQuoteOpen || yytext[1] == cQuoteClose) cfg_buf_append(CTX->buf, NULL, 0, yytext[1]); else cfg_buf_append(CTX->buf, yytext, yyleng, 0); } \\\n[ \t]* { /* no-op */ } {FQDELN} { cfg_buf_append(CTX->buf, yytext, yyleng, 0); } (.|\n) { if (yytext[0] == cQuoteOpen || yytext[0] == cQuoteClose) { if (cQuoteOpen != cQuoteClose) nQuoteOpen += (yytext[0] == cQuoteOpen ? 1 : -1); else nQuoteOpen = ((nQuoteOpen + 1) % 2); } if (yytext[0] == cQuoteClose && nQuoteOpen == 0) { cfg_buf_content(CTX->buf, &yylval->cpString, NULL, NULL); BEGIN(INITIAL); return T_STRING; } else cfg_buf_append(CTX->buf, NULL, 0, yytext[0]); } <> { cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "unterminated flexible-quoted string"); yyterminate(); } /* special tokens */ ";" { return T_SEP; } "{" { return T_OPEN; } "}" { return T_CLOSE; } /* plain text word */ \\\n[ \t]* { /* no-op */ } (.|\n) { cfg_buf_resize(CTX->buf, 0); cfg_buf_append(CTX->buf, NULL, 0, yytext[0]); BEGIN(SS_PT); } \\\n[ \t]* { /* no-op */ } [^ \t\n;{}\\"']+ { cfg_buf_append(CTX->buf, yytext, yyleng, 0); } (.|\n) { cfg_buf_content(CTX->buf, &yylval->cpString, NULL, NULL); yyless(0); BEGIN(INITIAL); return T_STRING; } <> { cfg_buf_content(CTX->buf, &yylval->cpString, NULL, NULL); BEGIN(INITIAL); return T_STRING; } <> { /* end of scanning */ yyterminate(); } %% /* external scanner state transitions */ void cfg_syn_scan_push(cfg_syn_ctx_t *ctx, const char *state); void cfg_syn_scan_push(cfg_syn_ctx_t *ctx, const char *state) { if (strcmp(state, "SS_SQ") == 0) yy_push_state(SS_SQ, ctx->yyscan); } void cfg_syn_scan_pop(cfg_syn_ctx_t *ctx); void cfg_syn_scan_pop(cfg_syn_ctx_t *ctx) { yy_pop_state(ctx->yyscan); } /* buffer-based input routine */ static int yyinput(cfg_syn_ctx_t *ctx, char *buf, int max_size) { int n; n = (ctx->inputbuf + ctx->inputlen - ctx->inputptr); if (n > max_size) n = max_size; if (n <= 0) return YY_NULL; memcpy(buf, ctx->inputptr, n); ctx->inputptr += n; return n; } /* closing brace */ static char closing_brace(char open) { static struct { char open; char close; } openclose[] = { { '(', ')' }, { '{', '}' }, { '{', ']' }, { '<', '>' }, }; int i; for (i = 0; i < sizeof(openclose)/sizeof(openclose[0]); i++) { if (openclose[i].open == open) return (char)openclose[i].close; } return open; } /* convert a hex digit into a nibble */ static int hex_nibble(const char hex) { unsigned char nibble; if (hex >= '0' && hex <= '9') nibble = (unsigned char)(hex - '0'); else if (hex >= 'a' && hex <= 'f') nibble = (unsigned char)(hex - 'a' + 10); else if (hex >= 'A' && hex <= 'F') nibble = (unsigned char)(hex - 'A' + 10); else nibble = -1; return nibble; } /* convert a hex digit sequence into an octet stream */ static int hex_sequence(cfg_syn_ctx_t *ctx, const char *in_ptr, size_t in_len) { int i; int c; if (in_len % 2 != 0) { c = hex_nibble(in_ptr[0]); cfg_buf_append(ctx->buf, NULL, 0, (char)c); in_ptr++; in_len--; } for (i = 0; in_len > 0; i++) { c = ((hex_nibble(in_ptr[0]) << 4) | (hex_nibble(in_ptr[1]))); cfg_buf_append(ctx->buf, NULL, 0, (char)c); in_ptr += 2; in_len -= 2; } return 1; } @ 1.25 log @Replace "return 0" with the official "yyterminate()" in cfg_syn_scan.l and fix quotation parsing by replacing two "yytext[1]" with the intended "yytext[0]". @ text @d4 2 a5 3 ** Copyright (c) 2002-2005 Ralf S. Engelschall ** Copyright (c) 2002-2005 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2002-2005 Cable & Wireless (http://www.cw.com/) @ 1.24 log @Adjust copyright messages for new year 2005. @ text @d124 1 a124 1 return 0; d155 1 a155 1 return 0; d161 1 a161 1 return 0; d165 1 a165 1 return 0; d181 1 a181 1 cfg_buf_append(CTX->buf, NULL, 0, yytext[1]); d185 1 a185 1 return 0; d211 1 a211 1 cfg_buf_append(CTX->buf, NULL, 0, yytext[1]); d215 1 a215 1 return 0; d255 1 a255 1 return 0; @ 1.23 log @Fix optional DMalloc build support. @ text @d4 3 a6 3 ** Copyright (c) 2002-2004 Ralf S. Engelschall ** Copyright (c) 2002-2004 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2002-2004 Cable & Wireless (http://www.cw.com/) @ 1.22 log @improve performance by using yyleng instead of calculating the string length on-the-fly @ text @d78 1 @ 1.21 log @Replace fixed-size token buffer in scanner by a dynamic buffer (cfg_buf_t). This eliminates the old 1024 size limit on tokens and makes the scanner more robust. @ text @d177 1 a177 1 cfg_buf_append(CTX->buf, yytext, 0, 0); d204 1 a204 1 cfg_buf_append(CTX->buf, yytext, 2, 0); d207 1 a207 1 cfg_buf_append(CTX->buf, yytext, 0, 0); d229 1 a229 1 cfg_buf_append(CTX->buf, yytext, 2, 0); d235 1 a235 1 cfg_buf_append(CTX->buf, yytext, 0, 0); d275 1 a275 1 cfg_buf_append(CTX->buf, yytext, 0, 0); @ 1.20 log @- Fixed cfg_test program by correctly passing the used number of bytes in the buffer instead of the size of the buffer. - Accept zero-length strings for parsing. - Correctly handle end-of-file during plain text token scanning. @ text @d40 1 d64 1 a64 1 static int hex_sequence(char *out_ptr, size_t out_len, const char *in_ptr, size_t in_len); a94 2 char caStr[1024]; char *cpStr = NULL; d138 1 a138 1 cpStr = caStr; d142 1 a142 2 *cpStr = '\0'; yylval->cpString = strdup(caStr); d156 1 a156 1 *cpStr++ = result; d159 2 a160 1 cpStr += hex_sequence(cpStr, sizeof(caStr)-(cpStr-caStr), yytext+3, yyleng-3-1); d163 2 a164 1 cpStr += hex_sequence(cpStr, sizeof(caStr)-(cpStr-caStr), yytext+2, 2); d166 7 a172 7 \\n { *cpStr++ = '\n'; } \\r { *cpStr++ = '\r'; } \\t { *cpStr++ = '\t'; } \\b { *cpStr++ = '\b'; } \\f { *cpStr++ = '\f'; } \\a { *cpStr++ = '\007'; } \\e { *cpStr++ = '\033'; } d174 1 a174 1 *cpStr++ = yytext[1]; d177 1 a177 3 char *cp = yytext; while (*cp != '\0') *cpStr++ = *cp++; d180 1 a180 1 *cpStr++ = yytext[1]; d189 1 a189 1 cpStr = caStr; d193 1 a193 2 *cpStr = '\0'; yylval->cpString = strdup(caStr); d201 1 a201 1 *cpStr++ = yytext[1]; d204 1 a204 2 *cpStr++ = yytext[0]; *cpStr++ = yytext[1]; d207 1 a207 3 char *cp = yytext; while (*cp != '\0') *cpStr++ = *cp++; d210 1 a210 1 *cpStr++ = yytext[1]; d219 1 a219 1 cpStr = caStr; d226 4 a229 7 if (yytext[1] == cQuoteOpen || yytext[1] == cQuoteClose) { *cpStr++ = yytext[1]; } else { *cpStr++ = yytext[0]; *cpStr++ = yytext[1]; } d235 1 a235 3 char *cp = yytext; while (*cp != '\0') *cpStr++ = *cp++; d245 1 a245 2 *cpStr = '\0'; yylval->cpString = strdup(caStr); d250 1 a250 1 *cpStr++ = yytext[0]; d267 2 a268 2 cpStr = caStr; *cpStr++ = yytext[0]; d275 1 a275 3 char *cp = yytext; while (*cp != '\0') *cpStr++ = *cp++; d278 1 a278 2 *cpStr = '\0'; yylval->cpString = strdup(caStr); d284 1 a284 2 *cpStr = '\0'; yylval->cpString = strdup(caStr); d362 1 a362 1 static int hex_sequence(char *out_ptr, size_t out_len, const char *in_ptr, size_t in_len) d365 1 a365 1 size_t out_max; a366 1 out_max = out_len; d368 2 a369 2 *out_ptr++ = hex_nibble(in_ptr[0]); out_len--; d373 3 a375 3 for (i = 0; in_len > 0 && out_len > 0; i++) { *out_ptr++ = ((hex_nibble(in_ptr[0]) << 4) | (hex_nibble(in_ptr[1]))); out_len--; d379 1 a379 1 return (out_max - out_len); @ 1.19 log @Do not let Flex generate the unused yyunput() and yy_top_state() functions in order to shut up compilation warnings. @ text @d59 1 a59 1 yylloc->last = yylloc->first d64 1 d298 11 @ 1.18 log @Adjust copyright messages for new year 2004. @ text @a46 1 #define YY_NO_UNPUT 1 d74 2 @ 1.17 log @Add and document bison-locations to conditionally include new M4 yylloc macro into analyzer skeleton code. Keep now redundant bison-bridge option around (this doesn't hurt), just incase the new conditional reentrant yylloc reverts. @ text @d4 3 a6 3 ** Copyright (c) 2002-2003 Ralf S. Engelschall ** Copyright (c) 2002-2003 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2002-2003 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.16 log @update copyright messages for new year @ text @d72 1 @ 1.15 log @upgrade to the latest Flex & Bison combo @ text @d4 3 a6 3 ** Copyright (c) 1999-2002 Ralf S. Engelschall ** Copyright (c) 1999-2002 The OSSP Project (http://www.ossp.org/) ** Copyright (c) 2001-2002 Cable & Wireless Deutschland (http://www.cw.com/de/) @ 1.14 log @add Dmalloc support @ text @d31 1 a31 1 ** ATTENTION: This requires GNU Flex 2.5.6 or newer! @ 1.13 log @remove trailing whitespaces @ text @d39 1 @ 1.12 log @ok, with the latest and greatest plus a little tweaking it works again @ text @d82 1 a82 1 special character c, i.e., one of !"#$%&'()*+,-./:;<=>?@@[\]^_`{|}~ or d357 1 a357 1 else @ 1.11 log @upgrade to flex-beta 2.5.10 (incompatible changes, so require it) @ text @d69 2 a70 1 %option reentrant-bison @ 1.10 log @use definitions to remove redundancy @ text @d43 1 a43 1 #define CTX ((cfg_syn_ctx_t *)yyget_extra(yy_globals)) @ 1.9 log @allow C-style block comments to nest @ text @d80 6 d218 2 a219 6 /* flexible-quoted word (q(.)[^\1]\1) the delimiting character has to one a special character c, i.e., one of !"#$%&'()*+,-./:;<=>?@@[\]^_`{|}~ or in C code: isprint(c) && !isspace(c) && !iscntrl(c) && !isalpha(i) && !isdigit(i) */ "q"[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@@\[\\\]\^\_\`\{\|\}\~] { d226 1 a226 1 \\[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@@\[\\\]\^\_\`\{\|\}\~] { d238 1 a238 1 [^\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\=\>\?\@@\[\\\]\^\_\`\{\|\}\~] { @ 1.8 log @Mega-change: full API overhauling. @ text @d85 1 d97 1 d100 3 d104 3 a106 1 BEGIN(INITIAL); @ 1.7 log @add more error checking @ text @d85 3 a87 3 int nQuoteOpen; char cQuoteOpen; char cQuoteClose; @ 1.6 log @Make sure 'a\b\\\'c' is parsed as "a\\b\\'c" and not "ab\\'c", i.e. follow the rules of the Perl '...' quoting and process only \\ and \' and keep all other escape sequences as is. @ text @d104 4 d166 4 d200 4 d249 4 @ 1.5 log @More scanner enhancement for supporting Perl-style \x{HHHHHH} sequences and for better escaping in export output. @ text @d177 5 a181 1 \\(.|\n) { @ 1.4 log @Add line-continuation support and make export output correctly quote the tokens. @ text @d62 2 d126 3 d138 3 d142 1 a142 10 unsigned int result; (void)sscanf(yytext+1, "%x", &result); if (result > 0xff) { cfg_syn_error(CTX, CFG_ERR_SYN, yylloc, "escape sequence out of bound"); return 0; } *cpStr++ = result; } \\\n[ \t]* { /* no-op */ d149 2 d314 38 @ 1.3 log @fix q(..) construct for q|..| situation, i.e., open and close chars the same @ text @d142 3 d173 3 d209 3 d240 3 d248 4 a251 1 [^ \t\n;{}"']+ { @ 1.2 log @Add support for Perl-like q(.)[^\1]\1 style quotations which allow one to place arbitrary stuff into a single syntax token. This is especially useful if you think about complex OSSP l2 or OSSP pcbe expressions which else had to be escaped into double- or single-quoted strings in order to be placed into a OSSP cfg syntax. @ text @d209 6 a214 4 if (yytext[0] == cQuoteOpen) nQuoteOpen++; else if (yytext[0] == cQuoteClose) nQuoteOpen--; d221 1 a221 1 else { a222 1 } a289 1 { '`', '\'' }, @ 1.1 log @Add this first cut for the forthcoming OSSP cfg library to CVS. This is work in progress and still not ready for use anywhere. @ text @d60 2 d74 2 d83 3 d182 40 a221 4 /* plain text word */ [^ \t\n;{}"']+ { yylval->cpString = strdup(yytext); return T_STRING; d225 2 a226 2 ";" { return T_SEP; } "{" { return T_OPEN; } d229 17 a245 3 /* anything else is returned as is... */ .|\n { return yytext[0]; d276 22 @