[Flex-help] Matching quoted strings
flex is a tool for generating scanners
Brought to you by:
wlestes
From: AlannY <m...@al...> - 2009-10-24 13:17:29
|
Hi there. I have another issue with my regexp, so, please, if you can, help me. At the manual at the section "Start Conditions" there are nice manual of how to solve double quoted string (at the end, if you don't remember). So, I've just adapted that's regular expressions to single quotes: And so, my code: === code ' { BEGIN (SQUOTE); } <SQUOTE>{ ' { yylval.str = out; return STRING: } \\ { *out++ = '\\'; } \\' { *out++ = '\''; } [^\\']+ { tmp = yytext; while (*tmp) *out++ = *tmp++; } } === code Everything seems ok, but at the running time, there are redundant \ at the stdout. And this is broken for string '\\\\' How to solve it? |