欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

    C语言词法分析器源代码风君版.docx

    • 资源ID:5395631       资源大小:19.41KB        全文页数:37页
    • 资源格式: DOCX        下载积分:3金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要3金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    C语言词法分析器源代码风君版.docx

    1、C语言词法分析器源代码风君版C语言词法分析器_源代码_风君版.txt小时候觉得父亲不简单,后来觉得自己不简单,再后来觉得自己孩子不简单。越是想知道自己是不是忘记的时候,反而记得越清楚。#include #include #include char *key0= ,auto,break,case,char,const,continue,default,do,double,else,enum,extern,float,for,goto,if,int,long,register,return,short,signed,sizeof,static,struct,switch,typedef,_Comp

    2、lex,_Imaginary,union,unsigned,void,volatile,while;/*保留字表*/char *key1= ,(,),;,;/*分隔符表*/char *key2= ,+,-,*,/,%,=,=,=,!=,!,&,|,|,&,=,?:,-,+,-,.,+=,-=,*=,/=;/*运算符表*/int xx035,xx110,xx231;int temp_key3=0,temp_c40=0,temp_c41=0,temp_c42=0,temp_c43=0;/* 初始化函数 */void load() int mm; for (mm=0;mm=34;mm+) xx0mm

    3、=0; for (mm=0;mm=9;mm+) xx1mm=0; for (mm=0;mm=30;mm+) xx2mm=0; FILE *floading; if (floading=fopen(key0.txt,w)=NULL) printf(Error! Cant create file : key0.txt); return; fclose (floading); /*建立保留字表文件:key0.txt*/ if (floading=fopen(key1.txt,w)=NULL) printf(Error! Cant create file : key1.txt); return; /*

    4、建立分隔符表文件:key1.txt*/ if (floading=fopen(key2.txt,w)=NULL) printf(Error! Cant create file : key2.txt); return; fclose(floading); /*建立运算符表文件:key2.txt*/ if (floading=fopen(key3.txt,w)=NULL) printf(Error! Cant create file : key3.txt); return; fclose (floading); /*建立标识符表文件:key3.txt*/ if (floading=fopen(c4

    5、0.txt,w)=NULL) printf(Error! Cant create file : c40.txt); return; fclose (floading); /*建立整数类型常量表文件:c40.txt*/ if (floading=fopen(c41.txt,w)=NULL) printf(Error! Cant create file : c41.txt); return; fclose (floading); /*建立浮点类型常量表文件:c41.txt*/ if (floading=fopen(c42.txt,w)=NULL) printf(Error! Cant create

    6、 file : c42.txt); return; fclose (floading); /*建立字符类型常量表文件:c42.txt*/ if (floading=fopen(c43.txt,w)=NULL) printf(Error! Cant create file : c43.txt); return; fclose (floading); /*建立字符串类型常量表文件:c43.txt*/ if (floading=fopen(defination.txt,w)=NULL) printf(Error! Cant create file : defination.txt); return;

    7、 fclose (floading); /*建立注释文件:defination.txt*/ if (floading=fopen(output.txt,w)=NULL) printf(Error! Cant create file : output.txt); return; fclose (floading); /*建立内部码文件:output.txt*/ if (floading=fopen(temp_key1,w)=NULL) printf(Error! Cant create file : temp_key1); return; fclose (floading); /*建立保留字临时

    8、表文件:temp_key1*/ if (floading=fopen(temp_key3,w)=NULL) printf(Error! Cant create file : temp_key3); return; fclose (floading); /*建立标识符临时文件:temp_key3*/ if (floading=fopen(temp_c40,w)=NULL) printf(Error! Cant create file : temp_c40); return; fclose (floading); /*建立整数类型常量临时文件:temp_c40*/ if (floading=fop

    9、en(temp_c41,w)=NULL) printf(Error! Cant create file : temp_c41); return; fclose (floading); /*建立浮点类型常量临时文件:temp_c41*/ if (floading=fopen(temp_c42,w)=NULL) printf(Error! Cant create file : temp_c42); return; fclose (floading); /*建立字符类型常量临时文件:temp_c42*/ if (floading=fopen(temp_c43,w)=NULL) printf(Erro

    10、r! Cant create file : temp_c43); return; fclose (floading); /*建立字符串类型常量临时文件:temp_c43*/* 保留字及标识符判断函数 */void char_search(char *word) int m,line=0,csi=0; int value=0; int value2=0; char c,cs100; FILE *foutput,*finput; for (m=1;m=34;m+) if (strcmp(word,key0m)=0) value=1; break; if (value=1) if (xx0m=0)

    11、foutput=fopen(key0.txt,a); fprintf(foutput,0t%dtt%sn,m,word); fclose(foutput); xx0m=1; foutput=fopen(output.txt,a); fprintf(foutput,0t%dtt%sn,m,word); fclose(foutput); else if (temp_key3=0) foutput=fopen(temp_key3,a); fprintf(foutput,%sn,word); fclose(foutput); temp_key3+; foutput=fopen(key3.txt,a);

    12、 fprintf(foutput,3t1tt%sn,word); fclose(foutput); finput=fopen(temp_key3,r); c=fgetc(finput); while (c!=EOF) while (c!=n) cscsi+=c; c=fgetc(finput); cscsi=0; csi=0; line+; if (strcmp(cs,word)=0) value2=1; break; else value2=0; c=fgetc(finput); fclose(finput); if (value2=1) foutput=fopen(output.txt,a

    13、); fprintf(foutput,3t%dtt%sn,line,word); fclose(foutput); else foutput=fopen(temp_key3,a); fprintf(foutput,%sn,word); fclose(foutput); temp_key3+; foutput=fopen(output.txt,a); fprintf(foutput,3t%dtt%sn,temp_key3,word); fclose(foutput); foutput=fopen(key3.txt,a); fprintf(foutput,3t%dtt%sn,temp_key3,w

    14、ord); fclose(foutput); /* 整数类型判断函数 */void inta_search(char *word) FILE *foutput,*finput; char c; char cs100; int csi=0; int line=0; int value2=0; if (temp_c40=0) foutput=fopen(temp_c40,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c40+; foutput=fopen(c40.txt,a); fprintf(foutput,4t0t1t%sn,word

    15、); fclose(foutput); finput=fopen(temp_c40,r); c=fgetc(finput); while (c!=EOF) while (c!=n) cscsi+=c; c=fgetc(finput); cscsi=0; csi=0; line+; if (strcmp(cs,word)=0) value2=1; break; c=fgetc(finput); fclose(finput); if (value2=1) foutput=fopen(output.txt,a); fprintf(foutput,4t0t%dt%sn,line,word); fclo

    16、se(foutput); else foutput=fopen(temp_c40,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c40+; foutput=fopen(output.txt,a); fprintf(foutput,4t0t%dt%sn,temp_c40,word); fclose(foutput); foutput=fopen(c40.txt,a); fprintf(foutput,4t0t%dt%sn,temp_c40,word); fclose(foutput); /* 浮点类型判断函数 */void intb_s

    17、earch(char *word) FILE *foutput,*finput; char c; char cs100; int csi=0; int line=0; int value2=0; if (temp_c41=0) foutput=fopen(temp_c41,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c41+; foutput=fopen(c41.txt,a); fprintf(foutput,4t1t1t%sn,word); fclose(foutput); finput=fopen(temp_c41,r); c=

    18、fgetc(finput); while (c!=EOF) while (c!=n) cscsi+=c; c=fgetc(finput); cscsi=0; csi=0; line+; if (strcmp(cs,word)=0) value2=1; break; c=fgetc(finput); fclose(finput); if (value2=1) foutput=fopen(output.txt,a); fprintf(foutput,4t1t%dt%sn,line,word); fclose(foutput); else foutput=fopen(temp_c41,a); fpr

    19、intf(foutput,%sn,word); fclose(foutput); temp_c41+; foutput=fopen(output.txt,a); fprintf(foutput,4t1t%dt%sn,temp_c41,word); fclose(foutput); foutput=fopen(c40.txt,a); fprintf(foutput,4t1t%dt%sn,temp_c41,word); fclose(foutput); /* 字符串常量判断函数 */void cc_search(char *word) FILE *foutput,*finput; char c;

    20、char cs100; int csi=0; int line=0; int value2=0; if (temp_c43=0) foutput=fopen(temp_c43,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c43+; foutput=fopen(c43.txt,a); fprintf(foutput,4t3t1t%sn,word); fclose(foutput); finput=fopen(temp_c43,r); c=fgetc(finput); while (c!=EOF) while (c!=n) cscsi+

    21、=c; c=fgetc(finput); cscsi=0; csi=0; line+; if (strcmp(cs,word)=0) value2=1; break; c=fgetc(finput); fclose(finput); if (value2=1) foutput=fopen(output.txt,a); fprintf(foutput,4t3t%dt%sn,line,word); fclose(foutput); else foutput=fopen(temp_c43,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c43

    22、+; foutput=fopen(output.txt,a); fprintf(foutput,4t3t%dt%sn,temp_c43,word); fclose(foutput); foutput=fopen(c43.txt,a); fprintf(foutput,4t3t%dt%sn,temp_c43,word); fclose(foutput); /* 字符常量判断函数 */void c_search(char *word) FILE *foutput,*finput; char c; char cs100; int csi=0; int line=0; int value2=0; if

    23、 (temp_c42=0) foutput=fopen(temp_c42,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c42+; foutput=fopen(c42.txt,a); fprintf(foutput,4t2t1t%sn,word); fclose(foutput); finput=fopen(temp_c42,r); c=fgetc(finput); while (c!=EOF) while (c!=n) cscsi+=c; c=fgetc(finput); cscsi=0; csi=0; line+; if (str

    24、cmp(cs,word)=0) value2=1; break; c=fgetc(finput); fclose(finput); if (value2=1) foutput=fopen(output.txt,a); fprintf(foutput,4t2t%dt%sn,line,word); fclose(foutput); else foutput=fopen(temp_c42,a); fprintf(foutput,%sn,word); fclose(foutput); temp_c42+; foutput=fopen(output.txt,a); fprintf(foutput,4t2

    25、t%dt%sn,temp_c42,word); fclose(foutput); foutput=fopen(c42.txt,a); fprintf(foutput,4t2t%dt%sn,temp_c42,word); fclose(foutput); /* 主扫描函数 */void scan() int count; char chin; FILE *fin; FILE *fout; char filename50; char temp100; char target3=; printf(请输入文件名:); scanf(%s,filename); if (fin=fopen(filename,r)=NULL) printf(Error! Cant open file : %sn,filename); return; chin=fge


    注意事项

    本文(C语言词法分析器源代码风君版.docx)为本站会员主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    copyright@ 2008-2023 冰点文库 网站版权所有

    经营许可证编号:鄂ICP备19020893号-2


    收起
    展开