版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 教育培训中心工作制度
- 数据上传工作制度汇编
- 整形外科医疗工作制度
- 文化市场旅游工作制度
- 文化旅游统计工作制度
- 文稿信息报送工作制度
- 新农合基金科工作制度
- 人美版五年级下学期17.雕塑之美教案
- 新生儿科病房工作制度
- 新疆乡镇护寺工作制度
- 2026云南红河州建水滇南云水环境治理有限公司招聘1人备考题库及一套答案详解
- 站桩培训课件教学
- QC08000培训课件教学课件
- 2024版2026春新人教版数学三年级下册教学课件:数学广角:重叠问题
- 【高一】高中物理公式全集(含图象推导)
- 2026年河南经贸职业学院单招职业适应性测试必刷测试卷含答案
- 2025年高考政治快速记忆顺口溜大全考前必背会
- 销售回款提成合同范本
- 2020-2025年护师类之护士资格证题库练习试卷A卷附答案
- 2025年电力交易员题库及答案
- GB/T 223.11-2025钢铁及合金铬含量的测定滴定法和分光光度法
评论
0/150
提交评论