#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <string>
using namespace std;
const int LINE=99999;
const int BUF_SIZE=1000;
int totalline=0; //总行数
int useful[LINE]= {0};
//简单类型
const int STYPES_SIZE=3;
string simpleTypes[STYPES_SIZE]= {"integer_type","real_type","void_type"};
const int NODE_NUM=999;
int count=0; //结点数组的结点个数
typedef struct eNode
{
string enode_name;
int enode_value;
eNode *next;
} eNode;
typedef struct vNode
{
string vnode_name;
int vnode_type;
eNode *head;
} vNode;
vNode vnodelist[NODE_NUM];
int allude[NODE_NUM]; //编号映射数组
void toSameLine(const char* filename,const char* destname)
{
ifstream fin(filename);
ofstream fout(destname);
if(!fout)
{
cout<<"create error";
return;
}
if(!fin)
{
cout<<"open error";
return;
}
char buf[BUF_SIZE];
char tmp[BUF_SIZE];
fin.getline(buf,1000);
while(!fin.eof())
{
fin.getline(tmp,1000);
if(tmp[0]=='@')
{
fout<<buf<<endl;
totalline++;
strcpy(buf,tmp);
}
else
{
strcat(buf,tmp);
}
}
cout<<"写到一行完成!一共有"<<totalline<<"行"<<endl;
fin.close();
fout.close();
}
void pointToLine(ifstream &fp,int line) //将文件指针指向指定行
{
fp.seekg(0L,ios::beg);
char buf[BUF_SIZE];
int i=0;
for(; i<line; i++)
{
fp.getline(buf,BUF_SIZE);
}
}
void regulateTree(const char* filename,const char* destname)
{
ifstream fin(filename);
if(!fin)
{
cout<<"open error"<<endl;
return;
}
ofstream fout(destname);
if(!fout)
{
cout<<"create error"<<endl;
return ;
}
int i=0;
char buf[BUF_SIZE];
string str;
while(!fin.eof())
{
fin.getline(buf,BUF_SI
GCC抽象语法树
最新推荐文章于 2024-05-13 09:44:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)