能自动把C/C++程序转化为XML的树型结构吗?

来源:百度知道 编辑:UC知道 时间:2024/05/17 04:38:12
能自动把C/C++程序转化为XML的树型结构吗?

如下一个a+b的小程序:
#include<stdio.h>
int a,b;
int main()
{
cin>>a>>b;
cout<<a+b<<endl;
}

我要把上面的程序转化为下面的格式,我寻找的就是要实现这样功能的自动转化工具.....

<headers>
<header>stdio.h</header>
</headers>
<GlobalVariables>
<GlobalVariable kind="int">a</GlobalVariable>
<GlobalVariable kind="int">b</GlobalVariable>
</GlobalVariables>
<functions>
<function name="main" returntype="int" argument=0 body="cin>>a>>b;cout<<a+b<<endl;">
</funtion>
</funtions>
上面的标准是动态输入的,你定义什么样的标准就输出什么样的格式.我要的就是把标准定义在XML的DID中或者XML Schema中.给出用DTD或XML Schema定义的C/C++语法规则就自动输出上面的结果.

很好,可以组合程序

用正则表达式搜索

/ sdgf.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "sdgf.h"

#include <string>
#include <boost/regex.hpp>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
/*
vo