probably the best C++ parser...
Alexander Neundorf
neundorf at kde.org
Fri Jul 1 17:18:04 UTC 2005
On Friday 01 July 2005 17:01, Alexander Neundorf wrote:
> ...you can find is gcc, but did you know gccxml
> (http://www.gccxml.org/HTML/Index.html) ? It's basically the real gcc, but
> it doesn't produce machine instructions, but an xml file describing the
> source file.
> So you get
> -all functions
> -all variables
> -all parameters for functions
> -the locations where the functions are declared (file and line number)
> etc. in a machine-readable format.
Here's a very simple example:
----------8<-----------8<--------------8<-----------
struct EmptyClass {};
int a_function(float f, EmptyClass e)
{
}
int main(void)
{
return 0;
}
----------8<-----------8<--------------8<-----------
and the resulting xml:
<?xml version="1.0"?>
<GCC_XML>
<Namespace id="_1" name="::" members="_2 _3 _4 "/>
<Function id="_2" name="main" returns="_5" context="_1" location="f0:8"/>
<Function id="_3" name="a_function" returns="_5" context="_1"
location="f0:4">
<Argument name="f" type="_6"/>
<Argument name="e" type="_4"/>
</Function>
<Struct id="_4" name="EmptyClass" context="_1" location="f0:1" members="_7
_8 " bases=""/>
<FundamentalType id="_5" name="int"/>
<FundamentalType id="_6" name="float"/>
<Constructor id="_7" name="EmptyClass" context="_4" location="f0:1">
<Argument name="_ctor_arg" type="_9"/>
</Constructor>
<Constructor id="_8" name="EmptyClass" context="_4" location="f0:1"/>
<ReferenceType id="_9" type="_4c"/>
<File id="f0" name="example1.cxx"/>
</GCC_XML>
Alex
--
Work: alexander.neundorf at jenoptik.com - http://www.jenoptik-los.de
Home: neundorf at kde.org - http://www.kde.org
alex at neundorf.net - http://www.neundorf.net
More information about the KDevelop-devel
mailing list