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

📄 pl0compiler.cpp

📁 pl0文法编译器
💻 CPP
字号:
#include "PL0Compiler.h"
#include "LexAnalyze.h"
#include "Errors.h"
#include "GramAnalyze.h"
#include "SymbolTable.h"
#include "CCode.h"
#include <iostream>
using namespace std;

PL0Compiler::PL0Compiler(const string &infileName, const string &outfileName):infileStream(infileName.c_str())
{	
	if(!infileStream)
	{
		cout<<"文件无法打开,请确认文件名或路径正确。"<<endl;
		lexAnalyze = 0;
		errors = 0;
		exit(1);
	}
	else
	{
		lexAnalyze = new LexAnalyze(this);
		errors = new Errors(this);
		gramAnalyze = new GramAnalyze(this);
		symbolTable = new SymbolTable(this);
		ccode = new CCode(this);
		outFileName = outfileName;
	}
}

PL0Compiler::~PL0Compiler()
{
	if(lexAnalyze) delete lexAnalyze;
	if(errors) delete errors;
	if(gramAnalyze) delete gramAnalyze;
	if(symbolTable) delete symbolTable;
	if(ccode) delete ccode;
	infileStream.close();
	//outfilestream.close();
}

void PL0Compiler::displayScript(){lexAnalyze->showScript();}
void PL0Compiler::compile(){gramAnalyze->startCompile();}
void PL0Compiler::listCode(){ccode->list();}
bool PL0Compiler::listError(){return errors->display();}
void PL0Compiler::wrtToFile(){ccode->writeToFile(outFileName);}

⌨️ 快捷键说明

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