⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 内含源代码和编译实验报告
💻 CPP
字号:
/******************************************************************
** 文件名: main.cpp
******************************************************************/
#include	"globals.h"
#include	"CommandLine.h"
#include	"scan.h"
#include	"prase.h"
#include	"symtab.h"
#include	"analyze.h"
#include	"cgen.h"

/********编译过程中用到的所有简单全局变量。*********/
CGlobals	AllGlobals;

/********用于控制编译器各阶是否输出信息的标志*******/
CFlags		AllFlags;

int main(int argc,char *argv[]){
	try{
		CCompileOption	ComOption;
		CCommandOpt		*pCommLine=new CCommandOpt(argc,argv,ComOption);
		if(!pCommLine) throw bad_alloc();
		delete	pCommLine; 
		pCommLine=NULL;						//命令行处理完毕,即刻释放处理器占用的内存。
		if(ComOption.m_fNoparse){			//只进行扫描。
			CScaner *pScaner=new CScaner;
			if(!pScaner) throw bad_alloc();
			while(pScaner->getToken()!=ENDFILE);	//扫描进行中。
		}
		else if(ComOption.m_fNoanalyze){			//只进行语法分析。
			CPraser *pPraser=new CPraser;
			if(!pPraser) throw bad_alloc();
			delete pPraser;
		}
		else if(ComOption.m_fNocode){				//只进行语义分析。
			Canalyzer *pAnalyzer= new Canalyzer;
			if(!pAnalyzer) throw bad_alloc();
			delete pAnalyzer;
		}
		else{										//生成实际代码。
			Cgenerator *pGenerator= new Cgenerator;
			if(!pGenerator) throw bad_alloc();
			delete pGenerator;
		}
		if(AllGlobals.source) AllGlobals.source.close();
		if(AllGlobals.code)	  AllGlobals.code.close();
		return 0;
	}
	catch (bad_alloc){										//处理堆分配异常。
		cout<<"Can't be allocated in heap, the programme must be terminated."<<endl;
		exit(1);}
	catch (...){
		cout<<"Something error,the program was terminated.";
		exit(1);}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -