[Flex-help] Only include part of matched string in yytext/token
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Daniel J. <dan...@ed...> - 2012-11-08 16:20:20
|
Hi, Suppose I have a rule \"[a-zA-Z0-9 ]*\" { yylval.s = strdup(yytext); return QUOTEDSTRING; } But I don't want yylval.s to include the actual quote characters. Is there a way to tell flex not to include them in the token? They should still be consumed. Otherwise I have to do \"[a-zA-Z0-9\._\/ ]*\" { yytext[strlen(yytext)-1]='\0'; yylval.s = strdup(yytext+1); return QUOTEDSTRING; } I don't have a problem with that; I'm just curious whether it is possible or not. Regards, Daniel |