📄 pl0.cpp
字号:
#include <stdio.h>
#include "pl0.h"
#include "cifa.h"
#include "errors.h"
#include "biaoge.h"
#include "daima.h"
#include "yufa.h"
CPlCompiler::CPlCompiler(char *filename)
{
if (fp=fopen(filename,"r"))
{
errors=new CErrors(this);
biaoge=new CBiaoge(this);
daima=new CDaima;
cifa=new CCifa(this);
yufa=new CYufa(this);
}
else
{
cifa=0;
errors=0;
daima=0;
biaoge=0;
yufa=0;
}
}
CPlCompiler::~CPlCompiler()
{
if (cifa) delete cifa;
if (errors) delete errors;
if (daima) delete daima;
if (biaoge) delete biaoge;
if (yufa) delete yufa;
if (fp) fclose(fp);
}
int CPlCompiler::Compile()
{
if (!(cifa && yufa && daima && errors && biaoge && fp))
return 0;
yufa->Analysis();
return 1;
}
void CPlCompiler::DisplaySrcfile()
{
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 CPlCompiler::ErrorNumber()
{
if (!errors) return 0;
return errors->Number();
}
void CPlCompiler::DisplayErrors()
{
if (errors) errors->Display();
}
void CPlCompiler::ListCode()
{
if (daima) daima->ListCode();
}
void CPlCompiler::Interpret()
{
if (daima) daima->Interpret();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -