Xref: utzoo comp.unix.questions:28677 comp.unix.programmer:1073 comp.compilers:1711 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!ima!iecc!compilers-sender From: hoffman@nunki.crd.ge.com (William A. Hoffman) Newsgroups: comp.unix.questions,comp.unix.programmer,comp.compilers Subject: Re: Give me your strings. Keywords: C, lex, question Message-ID: <16720@crdgw1.crd.ge.com> Date: 13 Feb 91 18:52:18 GMT References: <1991Feb12.144738.11530@lgc.com> <1991Feb12.201054.129@convex.com> Sender: compilers-sender@iecc.cambridge.ma.us Reply-To: hoffman@nunki.crd.ge.com (William A. Hoffman) Followup-To: comp.unix.questions Organization: Compilers Central Lines: 35 Approved: compilers@iecc.cambridge.ma.us :... 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] -- Send compilers articles to compilers@iecc.cambridge.ma.us or {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.