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

📄 compiler.cpp

📁 PL0的编译系统,使用MFC编写界面,采用浮动窗口来仿VC的环境
💻 CPP
字号:
// Compiler.cpp : implementation file
//

#include "stdafx.h"
#include "My1.h"
#include "Compiler.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCompiler
#include "WordAnalysis.h"
#include "PhraseAnalysis.h"
#include "Error.h"
#include "Table.h"
#include "Code.h"
CCompiler::CCompiler()
{
	mFile=NULL;
}

CCompiler::CCompiler(char * filename,CMainFrame *f)
{
	mFrame =f;
	if(mFile=fopen(filename,"r"))
		{		
		mWordAnalysis	=new CWordAnalysis(this);
		mPhraseAnalysis	=new CPhraseAnalysis(this);
		mError		=new CError(this);
		mTable		=new CTable(this);
		mCode		=new CCode(this);
		}
	else{
		mWordAnalysis	=0;
		mPhraseAnalysis =0;
		mError		=0;
		mTable		=0;
		mCode		=0;
		}
}
void CCompiler::Interpret()
{
	if (mCode) mCode->Interpret();
}
int CCompiler::ErrorNumber()
{
	if (!mError) return 0;
	return mError->Number();
}
CCompiler::~CCompiler()
{
	if (mWordAnalysis) delete mWordAnalysis;
	if (mError) delete mError;
	if (mCode) delete mCode;
	if (mTable) delete mTable;
	if (mPhraseAnalysis) delete mPhraseAnalysis;
	if (mFile) fclose(mFile);
}
int CCompiler::Compile()
{
	if(!(mFile && mWordAnalysis && mPhraseAnalysis && mError && mTable && mCode))
		return 0;	
	mPhraseAnalysis->Analysis();
	return 1;
}

BEGIN_MESSAGE_MAP(CCompiler, CWnd)
	//{{AFX_MSG_MAP(CCompiler)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CCompiler message handlers

⌨️ 快捷键说明

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