版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 除尘工安全规程竞赛考核试卷含答案
- 煮糖助晶工岗前理论水平考核试卷含答案
- 汽油煤油柴油加氢装置操作工岗前生产安全水平考核试卷含答案
- 供应链管理师复试竞赛考核试卷含答案
- 酸性水汽提装置操作工安全检查能力考核试卷含答案
- 煤制油生产工诚信道德考核试卷含答案
- 矿石处理工操作能力测试考核试卷含答案
- 链板冲压工安全技能测试考核试卷含答案
- 精细木工岗中安全风险考核试卷含答案
- 趸船水手岗前安全管理考核试卷含答案
- 口腔护士种植课件
- KNX智能家居系统培训资料
- 手术室物品管理与消毒灭菌
- 2025-2026学年广东省深圳实验学校初中部八年级(上)期中英语试卷
- 出生医学证明警示教育培训
- 困困困不醒大王原创课件
- (已压缩)(11)义务教育物理课程标准日常修订版(2022年版2025年修订)
- 2025年上海交通大学招聘真题(行政管理岗)
- Q-SY 13034-2024 物料主数据数字化描述规范
- 2025年法考主观题真题答案及解析
- 淝水之战课件
评论
0/150
提交评论