Re: [Flex-help] Only include part of matched string in yytext/token
flex is a tool for generating scanners
Brought to you by:
wlestes
|
From: Will E. <wes...@gm...> - 2012-11-08 19:27:15
|
Sounds like you care a bit more about the grammar and not just the
lexical stream. So, either introduce a parser (using bison, for
example), or do something using start conditions or additional rules to
match only what you want to match.
On Thursday, 8 November 2012, 5:00 pm +0100, Daniel Janzon <dan...@ed...> wrote:
> 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
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_nov
> _______________________________________________
> Flex-help mailing list
> Fle...@li...
> https://lists.sourceforge.net/lists/listinfo/flex-help
--
Will Estes (wl...@us...)
Flex Project Maintainer
http://flex.sourceforge.net/
|