




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include #include #include char ch;FILE *fp;char Getchar2()ch=fgetc(fp);if(ch= |ch=10|ch=9)ch=fgetc(fp);return ch;char Getchar()ch=fgetc(fp);return ch;bool IsLetter()/判断ch是否为字母if(ch=a | ch=A)return true;elsereturn false;bool IsDigit()/判断ch是否为数字if(ch=0)return true;else return false;void Concat(char s
2、trToken30)/将ch中的字符加入strToken中int i=0;while(strTokeni!=0)i+;strTokeni=ch;strTokeni+1=0;int Reserve(char str)if(strcmp(str,begin)=0)return 1;else if(strcmp(str,call)=0)return 2;else if(strcmp(str,const)=0)return 3;else if(strcmp(str,do)=0)return 4;else if(strcmp(str,end)=0)return 5;else if(strcmp(str,
3、if)=0)return 6;else if(strcmp(str,odd)=0)return 7;else if(strcmp(str,procedure)=0)return 8;else if(strcmp(str,read)=0)return 9;else if(strcmp(str,program)=0)return 10;else if(strcmp(str,var)=0)return 11;else if(strcmp(str,while)=0)return 12;else if(strcmp(str,write)=0)return 13;else if(strcmp(str,th
4、an)=0)return 14;else return 0;int InsertConst(char str)int i,value=0;for(i=0;stri!=0;i+)value=10*value+stri-0;return value;void main()int code , value;char id30=;char strToken30;if(fp=fopen(1.txt,r)=NULL)printf(文件打开失败!n);exit(0);ch=Getchar2();/读取一个非空字符while(ch!=EOF)strcpy(strToken,id);if(IsLetter()w
5、hile( IsLetter() | IsDigit() )Concat(strToken);ch=Getchar();code=Reserve(strToken);/保留字返回它代码,否则返回0值if(code=0)printf(n,strToken);elseswitch(code)case 1:printf(n);break;case 2:printf(n);break;case 3:printf(n);break;case 4:printf(n);break;case 5:printf(n);break;case 6:printf(n);break;case 7:printf(n);b
6、reak;case 8:printf(n);break;case 9:printf(n);break;case 10:printf(n);break;case 11:printf(n);break;case 12:printf(n);break;case 13:printf(n);break;case 14:printf(n);break;else if(IsDigit()while(IsDigit()Concat(strToken);ch=Getchar();value=InsertConst(strToken);printf(n,value);elseif(ch=*)ch=Getchar(
7、);if(ch=*)printf(n);else printf(n);else if(ch=)printf(-n);/ ch=Getchar();else if(ch=)printf(n);/ =ch=Getchar();elseprintf(n);/ )ch=Getchar();if(ch=)printf(=-n);/=ch=Getchar();elseprintf(-n);/else if(ch=:)ch=Getchar();if(ch=)printf(n);/=ch=Getchar();elseprintf(n);/else if(ch=+)printf(n); else if(ch=)printf(n);else if(ch=-)printf(n);else if(ch=/)printf(n);else if(ch=;)printf(n);else if(ch=,)printf(n);else if(ch=.)printf(n);else if(ch=()printf(n);else if(ch=)prin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 二零二五年度个人之间农业贷款借款合同
- 家长与孩子二零二五年度家务劳动责任履行协议
- 2025年度泳池救生员安全责任及应急响应规范协议
- 2025年度智慧城市建设预付款合作合同
- 二零二五年度酒店管理营业执照及品牌加盟转让合同
- 二零二五年度房屋维修基金顶账返还协议书
- 二零二五年度外墙保温涂料产品环保认证与绿色标识合同
- 二零二五年度女方婚前财产协议婚姻安全与婚姻风险规避合同
- 二零二五年度装配行业产品研发终止合同
- 石家庄市2025年度劳动合同电子化管理规范
- 心理测量学(全套教学课件)
- 高职英语课程说课稿课件
- 大班综合《要是你给老鼠玩手机》课件
- DB37-T 5026-2022《居住建筑节能设计标准》
- DN900钢管dn800E管定向钻穿越京杭大运河施工方案
- 全套IECQ QC080000-2017 有害物质过程管理体系程序文件
- 冀教版三年级数学下册《第二单元第2课时 两位数乘两位数(进位)的乘法》教学课件PPT小学公开课
- 成都市入户申请表
- 主题班会:预防流行性感冒课件
- 对外援助成套项目管理办法(试行)
- 管道吹扫、试压检验批质量验收记录表
评论
0/150
提交评论