C/C++ front-end extension a la SWIG?
Daniel Berlin
dan@cgsoftware.com
Thu Jun 29 15:09:00 GMT 2000
>
> 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
>
More information about the Gcc
mailing list