• 大小: 104KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-24
  • 语言: C/C++
  • 标签: PL0  VC++  

资源简介

(1)增加了+=,-+,*=,\=,++,--运算符;(2)增加了数组功能;(3)增加了错误提示功能;(4)增加了ELSE,FOR,CASE,REPEAT等语句功能;(5)用VC++设计的可视化操作界面,有打开和保存文件功能,源代码,目标代码,符号表,编译结果一目了然(6)操作简单,方便,里面附有例子代码(7)包含整个PL0的源代码

资源截图

代码片段和文件信息

//A.2     C      版   本

/*编译和运行环境:
*1Visual C++6.0VisualC++.NET and Visual C++.NET 2003
*WinNT Win 200 WinXP and  Win2003
*2 gcc version 3.3.2  20031022(Red Hat Linux 3.3.2-1)
*Redhat Fedora core 1
*Intel 32 platform
*使用方法:
*运行后输入PL/0 源程序文件名
*回答是否输出虚拟机代码
*回答是否输出名字表
*fa.tmp 输出虚拟机代码
*fa1.tmp  输出源文件及其各行对应的首地址
*fa2.tmp  输出结果
*fas.tmp  输出名字表
*/
#include
#include“pl0.h“
#include“string.h“
/*解释执行时使用的栈*/
#define stacksize 500
int main()
{
bool nxtlev[symnum];
printf(“Input pl/0 file ?“);
scanf(“%s“fname);                                     /*输入文件名*/
fin=fopen(fname“r“);
if(fin)
{
printf(“List object code ?(Y/N)“);                /*是否输出虚拟机代码*/
scanf(“%s“fname);
listswitch=(fname[0]==‘y‘||fname[0]==‘Y‘);
printf(“List symbol table ? (Y/N)“);             /*是否输出名字表*/
scanf(“%s“fname);
tableswitch=(fname[0]==‘y‘||fname[0]==‘Y‘);
fa1=fopen(“fa1.tmp““w“);
fprintf(fa1“Iput pl/0 file ?“);
fprintf(fa1“%s\n“ fname);
init();                                          /*初始化*/
err=0;
cc=cx=ll=0;
ifi=elsei=0;
ch=‘ ‘;
if(-1!=getsym())
{
fa=fopen(“fa.tmp““w“);
fas=fopen(“fas.tmp““w“);
addset(nxtlevdeclbegsysstatbegsyssymnum);
nxtlev[period]=true;    
if(-1==block(00nxtlev)) /*调用编译程序*/
{
fclose(fa);
fclose(fa1);
fclose(fas);
fclose(fin);
printf(“\n“);
return 0;
}
fclose(fa);
fclose(fa1);
fclose(fas);
if(sym!=period)
{
error(9);
}
if(err==0)
{
fa2=fopen(“fa2.tmp“ “w“);
interpret();
fclose(fa2);
}
else
{
printf(“Errors in pl/0 program“);
}
}
fclose(fin);
}
else
{
printf(“Can‘t open file! \n“);
}
printf(“\n“);
return 0;
}
/*
*初始化
*/
void init()
{
int i;
for(i=0;i<=255;i++)
{
ssym[i]=nul;
}
ssym[‘(‘]=lparen;
ssym[‘)‘]=rparen;
ssym[‘=‘]=eql;
ssym[‘:‘]=colon;
ssym[‘‘]=comma;
ssym[‘.‘]=period;
ssym[‘;‘]=semicolon;
/*设置保留字名字按照字母顺序便于折半查找*/
strcpy(&(word[0][0])“begin“);
strcpy(&(word[1][0])“call“);
strcpy(&(word[2][0])“case“);
strcpy(&(word[3][0])“const“);
strcpy(&(word[4][0])“do“);
strcpy(&(word[5][0])“downto“);
strcpy(&(word[6][0])“else“);
strcpy(&(word[7][0])“end“);
strcpy(&(word[8][0])“for“);
strcpy(&(word[9][0])“function“);
strcpy(&(word[10][0])“if“);
strcpy(&(word[11][0])“odd“);
strcpy(&(word[12][0])“of“);
strcpy(&(word[13][0])“procedure“);
strcpy(&(word[14][0])“read“);
strcpy(&(word[15][0])“repeat“);
strcpy(&(word[16][0])“return“);
strcpy(&(word[17][0])“step“);
strcpy(&(word[18][0])“then“);
strcpy(&(word[19][0])“to“);
strcpy(&(word[20][0])“until“);
strcpy(&(word[21][0])“var“);
strcpy(&(word[22][0])“while“);
strcpy(&(word[23][0])“write“);
/*设置保留字符号*/
wsym[0]=beginsym;
wsym[1]=callsym;
wsym[2]=casesym;
wsym[3]=constsym;
wsym[4]=dosym;
wsym[5]=downtosym;
wsym[6]=elsesym;
wsym[7]=endsym;
wsym[8]

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      37478  2006-11-10 23:27  PL0\08pl0.cpp

     文件       4261  2006-11-10 22:56  PL0\08pl0.h

     文件        147  2006-12-27 00:18  PL0\fa

     文件        393  2006-12-23 20:45  PL0\fa.tmp

     文件          0  2006-12-27 00:18  PL0\fa1

     文件          0  2006-12-23 20:45  PL0\fa1.tmp

     文件         33  2006-12-27 00:18  PL0\fas

     文件         79  2006-12-23 20:45  PL0\fas.tmp

     文件       1718  2007-08-30 01:04  PL0\PL0.clw

     文件       2021  2006-11-27 13:19  PL0\PL0.cpp

     文件       4172  2006-12-16 13:53  PL0\PL0.dsp

     文件        514  2006-11-27 13:19  PL0\PL0.dsw

     文件       1291  2006-11-27 13:19  PL0\PL0.h

     文件     156672  2007-08-30 01:04  PL0\PL0.ncb

     文件       1560  2007-08-30 01:04  PL0\PL0.plg

     文件          0  2006-12-06 00:38  PL0\Pl0Code.cpp

     文件          0  2006-12-06 00:39  PL0\Pl0Code.h

     文件       3525  2006-11-27 13:19  PL0\ReadMe.txt

     文件        205  2006-11-27 13:19  PL0\StdAfx.cpp

     文件       1054  2006-11-27 13:19  PL0\StdAfx.h

     文件       5751  2007-08-30 01:03  PL0\PL0Dlg.h

     文件      52179  2007-08-30 01:03  PL0\PL0Dlg.cpp

     文件       6651  2007-08-30 01:03  PL0\PL0.rc

     文件       1274  2007-08-30 01:03  PL0\resource.h

     文件      38336  2007-08-30 01:03  PL0\PL0.APS

     文件     102400  2007-08-30 01:04  PL0\PL0.opt

     文件      45056  2007-08-30 01:04  PL0\PL0.exe

     文件        164  2006-12-27 13:32  PL0\测试用例\01.txt

     文件        249  2006-12-15 18:33  PL0\测试用例\02.txt

     文件        207  2006-12-23 20:46  PL0\测试用例\03.txt

............此处省略15个文件信息

评论

共有 条评论