help-flex
[Top][All Lists]
Advanced

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

Suppress copying characters to yytext?


From: Dave Dutcher
Subject: Suppress copying characters to yytext?
Date: Thu, 26 Apr 2001 10:50:20 -0500

Hi,

First off I was wondering if there is an official web site for Flex?

Second, I would like to be able to have Flex use certain characters in a
regular expression to match the expression but suppress copying the
characters to yytext.  A simple example would be if I was trying to match
text surrounded by quotes, but I don't want to use the quotes. i.e.

\"[^\n]\"               { yylval = strdup(yytext); //This gives me the text and 
quotes. }

or

\"[^\n]\"               { yylval = strdup(yytext+1); yylval[strlen(yylval)-1] = 
'\0';
//Now I've removed the quotes. }

But since I'm lazy ;)  I would like to be able to tell Flex not to copy the
quotes.  What I would like is an operator that would tell flex to match an
expression but to not copy it to yytext.  Off the top of my head maybe the #
symbol could work for such an operator, so I could then do:

\"#[^\n]\"#     { yylval = strdup(yytext); //This would give me the text without
the quotes. }

Does anyone know if such a feature or something similar exists?  If this
doesn't exists would it be practical?

Thanks,

Dave Dutcher
Software Engineer
Symbology, Inc.
Minneapolis, MN




reply via email to

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