欢迎来到天天文库
浏览记录
ID:37422305
大小:67.50 KB
页数:26页
时间:2019-05-23
《chomsky文法类型判断及消除文法的左递归(chomsky grammar type judgment and elimination of grammar left recursion)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、chomsky文法类型判断及消除文法的左递归(Chomskygrammartypejudgmentandeliminationofgrammarleftrecursion)Chomskygrammartypejudgment#include#includeUsingnamespacestd;#defineMAXS50IntNONE=1;IntRELEFT=1;String,strings,noend,end;IntN;StructSTR{Stringleft;Stringright;};Four/outputtuplesVoi
2、dprint(STR*p){Inti;Cout<<3、.left[j]>='A'&&p[i].left[j]<='Z')){If(noend.find(p[i].left[j])>100)Noend+=p[i].left[j];}Else{If(end.find(p[i].left[j])>100)End+=p[i].left[j];}}For(j=0;j<(int)p[i].right.length();j++){If((p[i].right[j]>='A'&&p[i].right[j]<='Z')){If(end.find(p[i].right[j])>100)End+=p[i].right[j];}Else{4、If(noend.find(p[i].right[j])>100)Noend+=p[i].right[j];}}}}//deleteuselessgenerativeVoiduseless(STR*p){Int,I,J,k;Stringvn;Vn+=p[0].left;For(j=0;j='A'&&p[5、i].right[k]<='Z'&&vn.find(p[i].right[k])>100)Vn+=p[i].right[k];}//cout<100){For(i=0;i6、ewnonterminalChargetnew(charVN){Inti;For(i=0;i<26;i++){If(vn=='Z')Vn='A'-1;Vn=vn+1;If(noend.find(VN)>100){Noend+=vn;Break;}}Returnvn;}Remove/directleftrecursionVoidreleft(STR,*p,int,I){Int,J,k;Charc;For(j=0;j7、;C=getnew(noend[i]);For(k=0;k8、For(i=0;i
3、.left[j]>='A'&&p[i].left[j]<='Z')){If(noend.find(p[i].left[j])>100)Noend+=p[i].left[j];}Else{If(end.find(p[i].left[j])>100)End+=p[i].left[j];}}For(j=0;j<(int)p[i].right.length();j++){If((p[i].right[j]>='A'&&p[i].right[j]<='Z')){If(end.find(p[i].right[j])>100)End+=p[i].right[j];}Else{
4、If(noend.find(p[i].right[j])>100)Noend+=p[i].right[j];}}}}//deleteuselessgenerativeVoiduseless(STR*p){Int,I,J,k;Stringvn;Vn+=p[0].left;For(j=0;j='A'&&p[
5、i].right[k]<='Z'&&vn.find(p[i].right[k])>100)Vn+=p[i].right[k];}//cout<100){For(i=0;i6、ewnonterminalChargetnew(charVN){Inti;For(i=0;i<26;i++){If(vn=='Z')Vn='A'-1;Vn=vn+1;If(noend.find(VN)>100){Noend+=vn;Break;}}Returnvn;}Remove/directleftrecursionVoidreleft(STR,*p,int,I){Int,J,k;Charc;For(j=0;j7、;C=getnew(noend[i]);For(k=0;k8、For(i=0;i
6、ewnonterminalChargetnew(charVN){Inti;For(i=0;i<26;i++){If(vn=='Z')Vn='A'-1;Vn=vn+1;If(noend.find(VN)>100){Noend+=vn;Break;}}Returnvn;}Remove/directleftrecursionVoidreleft(STR,*p,int,I){Int,J,k;Charc;For(j=0;j7、;C=getnew(noend[i]);For(k=0;k8、For(i=0;i
7、;C=getnew(noend[i]);For(k=0;k8、For(i=0;i
8、For(i=0;i
此文档下载收益归作者所有