[antlr-interest] Parsing C++header files

David Wigg wiggjd at lsbu.ac.uk
Wed Mar 17 05:24:32 PST 2004


I normally parse C++ programs from the pre-processed, *.i files 
in order to pick up types properly. However, it is quite easy to 
parse *.h and *.cpp files although it may mean putting in some 
temporary dummy typedefs.

When I process *.i files I use the /P (MSVC parameter) to 
generate #line directives which are in turn used to control the 
use of our own application code at the correct time.

I'm sorry to hear you weren't able to compile and link a usable 
version. If you would like to try again please let me know. I'm 
using MSVC 6.0 .

I would have thought it easier to use an existing parser, even 
if it does more than you want, than write a new, albeit simpler one.

For your information I am still working on providing a cleaned 
up version of the parser, and I have also been able to find out 
how to separate our application code from the parser code by 
sub-classing it so our application code is now kept in separate 
*.hpp and *.cpp files.

In this way the application code and the parser code can be 
maintained independently and I will be able to provide updated 
versions of the parser code without having to take all our 
application code out each time.

In addition it might even make it possible for us to "attach" 
our application code to other antlr parsers of similar languages 
later on.

David

Message: 11
    Date: Tue, 16 Mar 2004 13:20:49 -0000
    From: "salee2945" <salee2945 at yahoo.ca>
Subject: New to Antlr: need guideline for parsing C++ header file.

Hello, Antlr users:

I need to write a program that parses C++ header files to generate
some C++ source code for my current C++ RMI project. I am new to
Antlr or any other parser/lexer stuff.

I downloaded C++ grammar by David Wigg from the share list at Antlr
web site and managed to generate CPPParser and CPPlexer files, but
failed to compile them, using binaries comiled with MSVC 7.0 by 
Arnar
Birgisson (which i also downloaded from the share list).

Now I am thinking if generating general C++ parser is an 
overkill to
parse only header files for things like: class names, base class
names, virtual methord names, and their parameters.

Could anyone tell me if I am in the right track? If not, any
suggestion?

Thanks in advance,

SL



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list