This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: C/C++ front-end extension a la SWIG?
- To: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Subject: Re: C/C++ front-end extension a la SWIG?
- From: Daniel Berlin <dan at cgsoftware dot com>
- Date: Thu, 29 Jun 2000 15:08:52 -0700 (PDT)
- cc: ttn at gnu dot org, gcc at gcc dot gnu dot org
>
> Rethinking it, a parser only (i.e. a syntax analyser) for C++ cannot
> work at all. You always need semantical analysis to find out what the
> type names are, or you couldn't tell apart cases like
>
> a*b;
> c<d,e>f;
>
> Readers familiar with C++ but not too familiar with C++ parsing are
> encouraged to find two completions of this program, so that each line
> means something completely different in each program :-)
>
> That, in turn, means that you need a significant part of the g++ front
> end - in fact, there isn't much you could leave out.
Right, in the case of G++, you'd be better off doing a "syntax only" pass,
and walking the tree.
It also depends on how much analysis you need to do.
If you are trying to make a SWIG like generator, you don't need to
actaully parse/analyze the function bodies, only the definitions.
In the case of C++ source to soure translators, which is what he's
talking about, he'd be better off working within the framework of
OpenC++, which was built for this sort of thing, and does handle all the
proper analysis.
It specifically lets you do the kind of walking/transforming he's kinda
looking to do.
> > Regards,
> Martin
>