欢迎来到天天文库
浏览记录
ID:61499916
大小:121.50 KB
页数:13页
时间:2021-02-07
《编译原理程序代码.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、voidmain(){intg,h,i,j,l,p,y,z,count;inta[10];//状态栈intni[10];//存放输出逆波兰式的参数charb[10];//符号栈charstr[10];//放输入的表达式charc1;inttop1,top2,top3,top,topn,m,n;charx;charcopy[10];//放Si,ri,看移进还是归约charcopy1[10];charvt[6]={'+','*','i','(',')','#'};//存放非终结符charvn='E';//存放终结符char*LR[4]={"E->E+E","E->E*E","
2、E->(E)","E->i"};//存放产生式};top1=0;top2=0;top3=0;top=0;topn=0;a[0]=0;y=a[0];b[0]='#';count=0;z=0;cout<<"文法G[E]:"<3、i"<4、***********************"<>str;l=strlen(str);str[l]='#';for(i=l+1;i<10;i++){str[i]=NULL;}cout<5、"符号栈"<<'t'<<'t'<<"输入串"<<'t'<<'t'<<"ACTION"<<'t'<<"GOTO"<6、t<<'t'<<'t';while(x!=vt[j]&&j<=6)j++;//vt[6]={'+','*','i','(',')','#'}存放终结符if(j==6&&x!=vt[j]){cout<>i;return;}if(action[y][j]==NU7、LL){cout<>i;return;}else//cout<<"y="<8、op1=top1+1;top2=top2+1;a[top1]=z;//a[10]状态栈b[top2]=x;//b[10]符号栈x=str[top]top=top+1;i=0;while(copy[i]!='#'){cout<
3、i"<4、***********************"<>str;l=strlen(str);str[l]='#';for(i=l+1;i<10;i++){str[i]=NULL;}cout<5、"符号栈"<<'t'<<'t'<<"输入串"<<'t'<<'t'<<"ACTION"<<'t'<<"GOTO"<6、t<<'t'<<'t';while(x!=vt[j]&&j<=6)j++;//vt[6]={'+','*','i','(',')','#'}存放终结符if(j==6&&x!=vt[j]){cout<>i;return;}if(action[y][j]==NU7、LL){cout<>i;return;}else//cout<<"y="<8、op1=top1+1;top2=top2+1;a[top1]=z;//a[10]状态栈b[top2]=x;//b[10]符号栈x=str[top]top=top+1;i=0;while(copy[i]!='#'){cout<
4、***********************"<>str;l=strlen(str);str[l]='#';for(i=l+1;i<10;i++){str[i]=NULL;}cout<5、"符号栈"<<'t'<<'t'<<"输入串"<<'t'<<'t'<<"ACTION"<<'t'<<"GOTO"<6、t<<'t'<<'t';while(x!=vt[j]&&j<=6)j++;//vt[6]={'+','*','i','(',')','#'}存放终结符if(j==6&&x!=vt[j]){cout<>i;return;}if(action[y][j]==NU7、LL){cout<>i;return;}else//cout<<"y="<8、op1=top1+1;top2=top2+1;a[top1]=z;//a[10]状态栈b[top2]=x;//b[10]符号栈x=str[top]top=top+1;i=0;while(copy[i]!='#'){cout<
5、"符号栈"<<'t'<<'t'<<"输入串"<<'t'<<'t'<<"ACTION"<<'t'<<"GOTO"<6、t<<'t'<<'t';while(x!=vt[j]&&j<=6)j++;//vt[6]={'+','*','i','(',')','#'}存放终结符if(j==6&&x!=vt[j]){cout<>i;return;}if(action[y][j]==NU7、LL){cout<>i;return;}else//cout<<"y="<8、op1=top1+1;top2=top2+1;a[top1]=z;//a[10]状态栈b[top2]=x;//b[10]符号栈x=str[top]top=top+1;i=0;while(copy[i]!='#'){cout<
6、t<<'t'<<'t';while(x!=vt[j]&&j<=6)j++;//vt[6]={'+','*','i','(',')','#'}存放终结符if(j==6&&x!=vt[j]){cout<>i;return;}if(action[y][j]==NU
7、LL){cout<>i;return;}else//cout<<"y="<8、op1=top1+1;top2=top2+1;a[top1]=z;//a[10]状态栈b[top2]=x;//b[10]符号栈x=str[top]top=top+1;i=0;while(copy[i]!='#'){cout<
8、op1=top1+1;top2=top2+1;a[top1]=z;//a[10]状态栈b[top2]=x;//b[10]符号栈x=str[top]top=top+1;i=0;while(copy[i]!='#'){cout<
此文档下载收益归作者所有