Re: C parser (Michael Tiomkin)
5 Aug 2004 14:12:12 -0400

          From comp.compilers

Related articles
C parser (Siddharth Choudhuri) (2004-07-28)
Re: C parser (Rajaram) (2004-08-04)
Re: C parser (jacob navia) (2004-08-04)
Re: C parser (Daniel C. Wang) (2004-08-04)
Re: C parser (2004-08-05)
C parser (=?gb2312?q?sky=20yan?=) (2004-08-05)
Re: C parser (2004-08-10)
Re: C parser (Siddharth Choudhuri) (2004-08-11)
C parser (DAVID) (1997-07-16)
Re: C parser (Dave Hanson) (1997-07-18)
Re: C parser (1997-07-22)
| List of all articles for this month |

From: (Michael Tiomkin)
Newsgroups: comp.compilers
Date: 5 Aug 2004 14:12:12 -0400
References: 04-07-079
Keywords: parse, C
Posted-Date: 05 Aug 2004 14:12:12 EDT

Siddharth Choudhuri <> wrote in message news:04-07-079...
> I am looking for a C parser that can generate a list of all variable
> names, their type (int, char...) and scope (auto, static, ...) by reading
> a C source file.

    You'd like to run this parser with the same -D definitions as your
original compiler. I would prefer to use the same compiler with the
same options because some of these options can introduce additional
#define's and change your source.
    Instead of reading the source file you can read the object file (.o
or .obj) after compilation. For example, 'nm file.o' will give you
some info about external variables, but not about the automatic vars.
    For better info you'd like to compile your source with symbol table
and/or debug info, and read this info from the object file. Notice
that some of the variables would have a complex type, e.g. structures,
unions and functions. You would have to find a way to deal with
definitions of these complex types together with definitions of the

Post a followup to this message

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