Re: C parser yielding syntax tree data structure?

robert.thorpe@antenova.com
21 Apr 2006 23:45:36 -0400

          From comp.compilers

Related articles
C parser yielding syntax tree data structure? andrews@csd.uwo.ca ((Jamie Andrews)) (2006-04-08)
Re: C parser yielding syntax tree data structure? do_not_have@sorry.bitbuck.cmm (Rod Pemberton) (2006-04-09)
Re: C parser yielding syntax tree data structure? tmp123@menta.net (tmp123) (2006-04-09)
Re: C parser yielding syntax tree data structure? muehlenf@sbox.tugraz.at (Arndt Muehlenfeld) (2006-04-12)
Re: C parser yielding syntax tree data structure? idbaxter@semdesigns.com (Ira Baxter) (2006-04-12)
Re: C parser yielding syntax tree data structure? p.black@acm.org (Paul E. Black) (2006-04-14)
Re: C parser yielding syntax tree data structure? scared.of.any@reply.mail (Rod Pemberton) (2006-04-16)
Re: C parser yielding syntax tree data structure? robert.thorpe@antenova.com (2006-04-21)
| List of all articles for this month |
From: robert.thorpe@antenova.com
Newsgroups: comp.software-eng,comp.compilers,comp.lang.c
Date: 21 Apr 2006 23:45:36 -0400
Organization: http://groups.google.com
References: 06-04-044
Keywords: C, parse
Posted-Date: 21 Apr 2006 23:45:36 EDT

  (Jamie Andrews) wrote:
> For a research project, we're looking for a reliable parser for C
> that will take an ANSI C program and yield a tree representation of
> the program (as a Java or C++ object). Of course a grammar e.g. in
> jflex/jbison that will yield the same thing is fine too. We have been
> able to find some grammars and parsers, of unknown reliability, that
> don't yield a syntax tree; we want to avoid starting with a flaky
> parser and/or adding the syntax tree code.
>
> Preferably the tokens in the tree will contain information
> on the line number and character number of the token, but if it
> is sufficiently easy to add that code, then we can do that too.
>
> Thanks for any info you can give.


Linus Torvalds of Linux fame once wrote one of these called "sparse".
See http://freshmeat.net/projects/sparse/


I think the latest version is in
http://www.kernel.org/pub/scm/devel/sparse/ you need to use the "git"
version control system to download it unfortunately.


It doesn't give C++ or Java objects as an output. But, as you'll find
there is not much gained by treating a whole tree as an object, the
important thing is that it has a single root.


I have no idea how good this parser is, you'll have to find that out
for yourself. It's hard to tell how good any C parser is that doesn't
get heavy use, and hard enough to tell if a parser does get heavy use.


Post a followup to this message

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