Give me your strings.
Cameron Laird
cl at lgc.com
Wed Feb 13 01:47:38 AEST 1991
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
cl at lgc.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]
--
Send compilers articles to compilers at iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
More information about the Comp.unix.programmer
mailing list