第一范文网 - 专业文章范例文档资料分享平台

编译原理课程设计-词法分析器(附含源代码)

来源:用户分享 时间:2025/6/6 20:17:37 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

.

else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\ else if(strcmp(p,\

else {fprintf(outfile,\未定义\\n\ }

void main() {FILE *fp,*out; int i=0,x=0,y=0; int EA=0;

char ch,str[10000],idstr[10],systr[2]; if((fp=fopen(\ {printf(\ exit(0);}

if((out=fopen(\ {printf(\ exit(0);} ch=fgetc(fp);

while(ch!=EOF)

{str[i]=ch;str[i+1]='\\0';i++;ch=fgetc(fp);} i=0;

while(1) {

if(str[i]=='@') break; else

if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')|| (str[i]>='0'&&str[i]<='9')||(str[i]=='_')) {idstr[x]=str[i];idstr[x+1]='\\0';x++;i++;EA=1;} else {

精选文档

.

x=0;

if((strlen(idstr)!=0)&&(EA)) analzid(out,idstr); idstr[x]='\\0';

if(str[i]<'0'||(str[i]>'9'&&str[i]<'A')|| (str[i]>'Z'&&str[i]<'a')||str[i]>'z') {

if(str[i]!='!'&&str[i]!='='&&str[i]!='<'&&str[i]!='>') {

systr[y]=str[i];systr[y+1]='\\0';analzsy(out,systr);i++; }

else

if((str[i]=='!'&&str[i+1]=='=')||(str[i]=='='&&str[i+1]=='=')||

(str[i]=='>'&&str[i+1]=='=')||(str[i]=='<'&&str[i+1]=='=')||

(str[i]=='<'&&str[i+1]=='<')||(str[i]=='>'&&str[i+1]=='>')) {

systr[y]=str[i];systr[y+1]=str[i+1];systr[y+2]='\\0'; analzsy(out,systr);i++;i++; } else {

systr[y]=str[i];systr[y+1]='\\0';analzsy(out,systr);i++; }}}}

printf(\全部结果已经存入outfile.txt文档-----\\n\ fprintf(out,\完成--------\ fclose(fp); fclose(out); }

精选文档

编译原理课程设计-词法分析器(附含源代码).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1xmyo7vkaw85bn78arf2570pk9t82300b5z_2.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top