Re: Give me your strings.

hoffman@nunki.crd.ge.com (William A. Hoffman)
13 Feb 91 18:52:18 GMT

          From comp.compilers

Related articles
Give me your strings. cl@lgc.com (1991-02-12)
Re: Give me your strings. tchrist@convex.COM (Tom Christiansen) (1991-02-12)
Re: Give me your strings. hoffman@nunki.crd.ge.com (1991-02-13)
| List of all articles for this month |
Newsgroups: comp.unix.questions,comp.unix.programmer,comp.compilers
From: hoffman@nunki.crd.ge.com (William A. Hoffman)
Followup-To: comp.unix.questions
Keywords: C, lex, question
Organization: Compilers Central
References: <1991Feb12.144738.11530@lgc.com> <1991Feb12.201054.129@convex.com>
Date: 13 Feb 91 18:52:18 GMT

:... I'm looking for an executable that knows enough C
:(or Pascal, ...) syntax to isolate string constants, and echo them out
:to a file (possibly stdout).




What about a simple lex program: string.lex


--------------------------------------------------------
string \"([^"\n]|\\["\n])*\"
%%
{string} printf("%s\n", yytext); return(1);
\n ;
. ;
%%
main()
{
int i;


while(i= yylex())
;
}


yywrap()
{
}
------------------------------------------------------------
to run just:
lex string.lex
cc lex.yy.c -o string
string < *.c
[I'd make it a little bit smarter to handle character constants and
comments, but in general that's the right idea. -John]
--


Post a followup to this message

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