help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

escpape characters


From: Bernd Prager
Subject: escpape characters
Date: Tue, 26 Nov 2002 22:15:31 -0500

Hi,

I'm trying to parse a string where special characters
are used as delimiters but they can also appear 
within the single items when an escape sequence
is used. So ':' is a delimiter, '\:' is not.
I tried to describe that in flex but failed ;-/
Can anybody give me a hand here?
That's what I tried:

--------- snip ---------------
WS      [ \t]+                  // white space
DEL     [:,\.]                   // delimiter
ESCD     \\{DEL}{1}           // escaped delimiter
CHAR    [[:alnum:]{ESCD}]    // valid character

%%

{WS}        /* skip white spaces */
{CHAR}+     printf("valid string: %s\n", yytext);
.                printf("something else: %s\n", yytext);

%%

main()
{
   yylex();
}
--------- snip ---------------

Thanks.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]