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

📄 compiler.h

📁 这个也是我们的毕业设计课题
💻 H
字号:
// Compiler.h: interface for the CCompiler class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_COMPILER_H__DF370D1D_413F_4033_AAD4_2AF760AEAA1B__INCLUDED_)
#define AFX_COMPILER_H__DF370D1D_413F_4033_AAD4_2AF760AEAA1B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "DFY\type.h"
#include "fileheader.h"
#include "fstream"
//struct used for holing the flag information 
struct FlagsMap{
	char strFlagName[20];
	UNSHORT uFlagAddr;
	FlagsMap* next;
};
//struct used fot holding the variable information
struct VariableInfo{
	char strVarName[20];
	UNSHORT uVarAddr;
	WORD wValue;
	VariableInfo* next;
};


//class CCompiler
class CCompiler  
{
//data member
//used to hold compile information
private:
	UNSHORT m_uCodeLineNum;
	WORD* m_instructionCode;//used to hold the genersted instructions
	MapFileBody* m_LineToAddr;//used to hold the map information
	BOOL SecondScan(char* asmSourceName,char* DFYexeFile);//generate Destination DFYexe files
	void AddVariable(char* varName,UNSHORT uAddr,WORD wValue);
	void AddFlag(char* flag, UNSHORT uAddr);
	BOOL FindFlag(char* flag, UNSHORT& uAddr);//find flag in the varIntfo
					//list ,return TRUE if Succeed, and the flag addr will
					//fill into the uAddr
	BOOL FindVariable(char * var, UNSHORT& uAddr,WORD& wVar);//the simulator with
					//find flag
	BOOL FirstScan(char* asmSource,char* pdfFile);
	char* _instructions[31];//keep the instruction key words
	char* _registers[5];//keep the register key words
	CString m_strError;//ues to report error
	UINT m_uErrorNum;

	WORD m_wDFYexeFileSize;//the body size of the DFYexe File
	WORD m_wPdfRecordNum;//the body size of the . Pdf File
	FlagsMap * _flagsMap;
	VariableInfo* _varInfo;
public:

	char* GetWordFromLine(int index, char* strSrc);//get a word from
				//strSrc,the position is specified by index,if the word
				//not exist ,return NULL, you must check the return
				//value to avoid use a NULL pointer do any thing
	CCompiler();
	virtual ~CCompiler();
	BOOL Compile(char* asmSourc,char* pdfFile,char* DFYexeFile);
protected:
	UNSHORT m_uDataSegSize;
	UNSHORT m_uCodeSegSize;
	BOOL IsComment(char* str);
	BOOL IsEmpty(char* str);
	BOOL IsRegister(char* str);
	BOOL IsInstruction(char* str);
	BOOL IsNumber(char*);
	BOOL IsLegal(char*);
	void ReportState(CString strError);//report the state to the out put window

};

#endif // !defined(AFX_COMPILER_H__DF370D1D_413F_4033_AAD4_2AF760AEAA1B__INCLUDED_)

⌨️ 快捷键说明

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