|Give me your strings. firstname.lastname@example.org (1991-02-12)|
|Re: Give me your strings. tchrist@convex.COM (Tom Christiansen) (1991-02-12)|
|Re: Give me your strings. email@example.com (1991-02-13)|
|From:||firstname.lastname@example.org (Cameron Laird)|
|Keywords:||C, lex, question|
|Organization:||Landmark Graphics Corp., Houston, Tx|
|Date:||Tue, 12 Feb 91 14:47:38 GMT|
I want to be able to type
show_me_source_strings source1.c source2.c
and receive something like
source1.c: "This is a string in the C-source source1.c"
source1.c: "I'm a string too, passed to the function %s.\n""
source1.c: "I initialize a char *.";
source2.c: "Me too; I'm in the string-space of this program."
source2.c: "There's another string in this file, but it's in comments."
Is the point clear? 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).
It's easy enough to write a grep or sed or grep script that finds all
lines with a couple of "-s in them, but I'm curious whether there is a
Better (more accurate, powerful, ...) Way. Is there a standard, modern,
low-cost fashion for getting at the syntactic elements of C source? If
I became adept at YACC, could I code this up in two minutes? Is there a
public-domain C parser that everyone uses to construct filters such as I
have in mind? Has Harry Spencer written an awk program that does this,
or will emacs give it to me if I type CTL-\-ESC-ALT-&-F7-...?
Cameron Laird USA 713-579-4613
email@example.com USA 713-996-8546
[What you want to do is lexical analysis, and that's what lex and flex do.
Many C lexers are floating around the net; see the comp.compilers monthly
posting for some suggestions. By the way, his name is Henry. -John]
Return to the
Search the comp.compilers archives again.