pl0.cpp

来自「PL/0编译器」· C++ 代码 · 共 73 行

CPP
73
字号
#include "StdAfx.h"
#include ".\pl0.h"
#include "Wording.h"
#include "Errors.h"
#include "Form.h"
#include "Code.h"
#include "Symtax.h"

CPl0::CPl0(char *filename)
{
	if (fp=fopen(filename,"r"))
	{
		errors=new CErrors(this);
		form=new CForm(this);
		code=new CCode(this);
		wording=new CWording(this);
		symtax=new CSymtax(this);
		flnm = filename;
	}
}

CPl0::~CPl0(void)
{
	if (fp) 
		fclose(fp);
}

int CPl0::Compile()
{
	if (!fp)
		return 0;

	symtax->Analysis();

	return 1;
}

void CPl0::ShowSrcfile()
{
	if (!fp) 
		return;
	long pos=ftell(fp);
	fseek(fp,0,SEEK_SET);
	char ch;
	while((ch=getc(fp))!=EOF) 
		putchar(ch);
	putchar('\n');

	fseek(fp,pos,SEEK_SET);
}

int CPl0::ErrorNumber()
{
	if (!errors) 
		return 0;
	return errors->Number();
}

void CPl0::ShowErrors()
{
	if (errors) 
		errors->Show();
}

void CPl0::ListCode()
{
	code->ListCode();
}

void CPl0::Interpret()
{
	code->Interpret();
}

⌨️ 快捷键说明

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