How do I handle multiple line quoted strings in fLex?

Tim Perry <tperry@blinksoft.com>
3 Sep 1997 01:02:52 -0400

          From comp.compilers

Related articles
How do I handle multiple line quoted strings in fLex? tperry@blinksoft.com (Tim Perry) (1997-09-03)
Re: How do I handle multiple line quoted strings in fLex? hbabu@sequent.com (1997-09-07)
Re: How do I handle multiple line quoted strings in fLex? tperry@blinksoft.com (Tim Perry) (1997-09-12)
| List of all articles for this month |

From: Tim Perry <tperry@blinksoft.com>
Newsgroups: comp.compilers
Date: 3 Sep 1997 01:02:52 -0400
Organization: Compilers Central
Keywords: lex, question

I wan't to be able to handle multiple line strings in flex, where I return
one token to bison of that string minus the quotes. I have a pattern such
as this that currently works, with a few snags...


\"[^\"]*\" { yyval.string = strdup(yytext[yyleng]); RETURN STRING }


This doen't get rid of the " nor does it supply a method of counting the
current line numbers since the \n rule that I have will not get executed.


I have thought about makeing a STRING state that when it encounters the
first " I initialize a state that accepts everything besides a \n, I
discard the \n since I don't want them in my string anyway, increase my
linecounter and then strcat the yytext to a temp buffer till I get the
closeing ".


If anyone has a better idea or the one I described above working I would
really appreciate it.


Thanks,


Tim
[I'd do what you suggest, use the STRING state to recognize a line at
a time and buffer up the string myself, since it's unwise to expect
lex to handle enormous single tokens. -John]






--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.