资源简介
PL0C.rar

代码片段和文件信息
/*
*制作者:LCcai
*使用方法:
*运行后输入PL/0 源程序文件名
*回答是否输出虚拟机代码
*回答是否输出名字表
*fa.tmp 输出虚拟机代码
*fa1.tmp 输出源文件及其各行对应的首地址
*fa2.tmp 输出结果
*fas.tmp 输出名字表
*/
#include
#include“pl0c.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;
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[‘‘]=comma;
ssym[‘.‘]=period;
ssym[‘#‘]=neq;
ssym[‘;‘]=semicolon;
/*设置保留字名字按照字母顺序便于折半查找*/
strcpy(&(word[0][0])“begin“);
strcpy(&(word[1][0])“call“);
strcpy(&(word[2][0])“const“);
strcpy(&(word[3][0])“do“);
strcpy(&(word[4][0])“else“);
strcpy(&(word[5][0])“end“);
strcpy(&(word[6][0])“for“);
strcpy(&(word[7][0])“if“);
strcpy(&(word[8][0])“odd“);
strcpy(&(word[9][0])“procedure“);
strcpy(&(word[10][0])“read“);
strcpy(&(word[11][0])“repeat“);
strcpy(&(word[12][0])“then“);
strcpy(&(word[13][0])“until“);
strcpy(&(word[14][0])“var“);
strcpy(&(word[15][0])“while“);
strcpy(&(word[16][0])“write“);
/*设置保留字符号*/
wsym[0]=beginsym;
wsym[1]=callsym;
wsym[2]=constsym;
wsym[3]=dosym;
wsym[4]=elsesym;
wsym[5]=endsym;
wsym[6]=forsym;
wsym[7]=ifsym;
wsym[8]=oddsym;
wsym[9]=procsym;
wsym[10]=readsym;
wsym[11]=repeatsym;
wsym[12]=thensym;
wsym[13]=untilsym;
wsym[14]=varsym;
wsym[15]=whilesym;
wsym[16]=writesym;
/*设置指令名称*/
strcpy(&(mnemonic[lit][0])“lit“);
strcpy(&(mnemonic[opr][0])“opr“);
strcpy(&(mnemonic[lod][0])“lod“);
strcpy(&(mnemonic[sto][0])“sto“);
strcpy(&(mnemonic[cal][0])“cal“);
s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 235 2008-04-24 09:59 PL0C\Debug\fa.tmp
文件 152 2008-04-24 09:59 PL0C\Debug\fa1.tmp
文件 14 2008-04-24 09:59 PL0C\Debug\fa2.tmp
文件 73 2008-04-24 09:59 PL0C\Debug\fas.tmp
文件 74752 2008-04-24 23:57 PL0C\Debug\PL0C.bsc
文件 213038 2008-04-24 23:57 PL0C\Debug\PL0C.exe
文件 219104 2008-04-24 23:57 PL0C\Debug\PL0C.ilk
文件 68651 2008-04-24 23:57 PL0C\Debug\pl0c.obj
文件 223860 2008-04-24 23:55 PL0C\Debug\PL0C.pch
文件 533504 2008-04-24 23:57 PL0C\Debug\PL0C.pdb
文件 0 2008-04-24 23:57 PL0C\Debug\pl0c.sbr
文件 33792 2008-04-24 23:57 PL0C\Debug\vc60.idb
文件 53248 2008-04-24 23:57 PL0C\Debug\vc60.pdb
文件 271 2008-04-24 23:57 PL0C\fa.tmp
文件 173 2008-04-24 23:57 PL0C\fa1.tmp
文件 19 2008-04-24 23:58 PL0C\fa2.tmp
文件 135 2008-04-24 23:57 PL0C\fas.tmp
文件 38711 2008-04-27 19:59 PL0C\pl0c.cpp
文件 4323 2008-03-03 21:42 PL0C\PL0C.dsp
文件 514 2008-03-03 21:42 PL0C\PL0C.dsw
文件 5984 2008-04-16 15:35 PL0C\pl0c.h
文件 50176 2008-04-24 23:58 PL0C\PL0C.ncb
文件 53760 2008-04-24 23:58 PL0C\PL0C.opt
文件 1387 2008-04-24 23:57 PL0C\PL0C.plg
文件 80 2008-04-24 11:32 PL0C\Test\add-minus.txt
文件 115 2008-04-24 23:57 PL0C\Test\array-complex.txt
文件 98 2008-04-16 15:36 PL0C\Test\array-error.txt
文件 67 2008-04-24 10:59 PL0C\Test\array.txt
文件 124 2008-03-20 09:09 PL0C\Test\becomes.txt
文件 212 2008-03-17 12:50 PL0C\Test\call.txt
............此处省略13个文件信息
相关资源
- 开源1A锂电池充电板TP4056原理图+PCB
- m1卡 ic卡可选择扇区初始化加密软件
- TSCC.exe
- FTP课程设计(服务端+客户端)
- 计算机图形学 边填充算法实现代码
- 电力系统潮流计算程序集合
- oracle数据迁移项目实施方案
- Web Api 通过文件流 文件到本地
- Visio图标-最新最全的网络通信图标库
- Spire API文档
- OpenGL参考手册
- Python中Numpy库最新教程
- SPD博士V5.3.exe
- 直流无刷电机方波驱动 stm32 例程代码
- layui后台管理模板
- 仿知乎界面小程序源代码
- 云平台-阿里云详细介绍
- photoshop经典1000例
- scratch垃圾分类源码(最终版本).sb
- IAR ARM 7.8破解
- TI CCS V5.4 安装步骤及破解文件
- 松下plc FP-XH的驱动
- 局域网硬件信息收集工具
- 加快Windows XP操作系统开机速度
- 联想启天M4350 BIOS升级文件
- 操作系统教程课后答案华中科技大学
- 用友ERP考试系统练习题库及答案
- 北京邮电大学数据结构历年考研真题
- 真正!!!概率论与数理统计浙江大
- TMS320VC5509A_开发板使用手册
评论
共有 条评论