Re: GCC as front end for C++ browser?

sanjay@clef.lcs.mit.edu (Sanjay Ghemawat)
Sun, 16 Jul 1995 21:27:31 GMT

          From comp.compilers

Related articles
GCC as front end for C++ browser? mikey@mcs.com (1995-07-11)
Re: GCC as front end for C++ browser? mnp@compass-da.com (Mitchell N. Perilstein) (1995-07-16)
Re: GCC as front end for C++ browser? sanjay@clef.lcs.mit.edu (1995-07-16)
Re: GCC as front end for C++ browser? jan@janhh.shnet.org (1995-07-17)
Re: GCC as front end for C++ browser? sc@iaxp01.inf.uni-jena.de (Sebastian Schmidt) (1995-07-18)
ANNOUNCE: C++ browser hack (was GCC as front end...) sanjay@clef.lcs.mit.edu (1995-07-19)
Re: GCC as front end for C++ browser? vmulyk@bnr.ca (victor (v.) mulyk) (1995-07-21)
Re: GCC as front end for C++ browser? vmulyk@bnr.ca (victor (v.) mulyk) (1995-07-21)
Re: GCC as front end for C++ browser? rcd@dooley.cs.brown.edu (1995-07-23)
[3 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: sanjay@clef.lcs.mit.edu (Sanjay Ghemawat)
Keywords: C++, tools
Organization: MIT Lab for Computer Science
References: 95-07-076
Date: Sun, 16 Jul 1995 21:27:31 GMT

mikey@mcs.com (Mike Young) writes:


> I'm considering writing a browser for C++/C code using GCC's front end as
> the "parser." Having used MSVC for a short time, I've become quite
> attached to the code browser built into its work environment. Now that I'm
> safely back home in UNIX, I do sorely miss being able to hot-key to
> definitions/references for arbitrary symbols. Tags in emacs and vi fall
> far, far short of this capability.
> ...
> Does this sound viable as a quick, evenings-only project? Are there other
> tools that already do a good job of this? Is gcc's front end a suitable
> starting point? How hard is it to learn and use? Where do I find more
> information about gcc internals? Are there better, simpler ways to
> accomplish this same end?


One thing you might want to ask yourself is whether or not you want
to parse C++ completely, or just enough to identify various things
like class declarations etc. C++ is quite a complicated language to
parse, and you will have to spend a lot of time getting a parser
integrated in whatever you write. If you go that route, you might
want to take a look at a C++ parser project I think people at Brown
are working on. If I remember correctly, the ftp location is
wilma.cs.brown.edu:/pub/cppp.tar.Z


If you don't need to parse C++ completely, things become much simpler.
I did something like this two or three years ago using flex and yacc.
The combined scanner and parser size (with calls to a program database
kept on the the side) was less than 500 lines of code:


              lines words chars file


              245 674 4390 parser.y
              208 499 4103 lexer.l
              453 1173 8493 total


The resulting parser identifies the definitions of classes, structs,
methods, functions, and preprocessor macros. It also identifies any
hierarchical relationships between classes and records the uses of
all symbols. I shudder to think of what would be necessary if I had
decided to write a parser for all of C++.


If people are interested in taking a copy of my sources and promise
not to bother me too much (I have to finish writing my thesis on a
completely unrelated topic), I could probably tar up my sources
and put them on an ftp site.


-Sanjay Ghemawat
--
==========================================================================
<A HREF="http://www.pmg.lcs.mit.edu/~sanjay/">Sanjay Ghemawat</A>
sanjay@lcs.mit.edu
--


Post a followup to this message

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