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

编译原理课设

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

{

fprintf(p,\ MOV %s,AX\\n\ } }

if (c=='/') {

fprintf(p,\ CWD\\n\

fprintf(p,\ MOV BX,%s\\n\ fprintf(p,\ IDIV BX\\n\ strcpy(last_ax,\ if (!os_flag)

fprintf(p,\ MOV %s,AX\\n\ else

if (strcmp(ans[i].arg3,ans[i+1].arg1)||ans[i].arg3[0]!='k') fprintf(p,\ MOV %s,AX\\n\

}

if (c=='j') {

char temp[3];

if (!os_flag)

fprintf(p,\ MOV BX,%s\\n\ else

if (strcmp(ans[i].arg2,last_bx)) {

fprintf(p,\ MOV BX,%s\\n\ strcpy(last_bx,ans[i].arg2); }

fprintf(p,\ CMP AX,BX\\n\ if (ans[i].op[1]=='n') {

temp[0]=ans[i].op[2];temp[1]=ans[i].op[3];temp[2]=0; if (!strcmp(temp,\

fprintf(p,\ JE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JNE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JGE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JLE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JG L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JL L%d\\n\ } else {

temp[0]=ans[i].op[1];temp[1]=ans[i].op[2];temp[2]=0; if (!strcmp(temp,\

fprintf(p,\ JNE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JL L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JG L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JLE L%d\\n\ if (!strcmp(temp,\

fprintf(p,\ JGE L%d\\n\ } } }

fprintf(p,\ fprintf(p,\ END START\\n\ fclose(p); }

int main() {

int os_flag;

char s[maxlen],temp[maxlen]; FILE *p,*q;

/****************************** ****get input filename********* ******************************/

printf(\ while (1) {

scanf(\

if ((p=fopen(temp,\

printf(\ else

break; }

printf(\ while (1) {

char temp2[100]; scanf(\

if (toupper(temp2[0])=='Y') {

os_flag=1; break; } else

if (toupper(temp2[0])=='N') {

os_flag=0; break; } else

printf(\ }

/***************************** ********init input file*******

*****************************/ q=fopen(\ init2(p,q); fclose(q); line=1;

memset(flag,0,sizeof(flag));

memset(token_data,0,sizeof(token_data));

/************************************* ************get token***************** *************************************/ p=fopen(\

while (fgets(s,maxlen,p)!=NULL) {

s[strlen(s)-1]=0; GetToken(s); }

fclose(p);

// for (int i=0;i

*************************************************/ int l=init();

for (int i=0;i

if (token_data[i].type==1) {

int j;

for (j=0;j

if (!strcmp(token_data[i].name,var[j])) break; if (j==var_num) {

printf(\ remove(\ return 0; } } }

printf(\ /****************************** *******grammar check*********** ******************************/

if (grammar(l)) printf(\ else {

printf(\ remove(\ return 0; }

/****************************** ******output four_tetrad******* ******************************/ gettetrad(temp);

/******************************** ********output asm*************** ********************************/ getasm(temp,os_flag);

remove(\ return 0; }

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