91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-08-13
  • 語言: 其他
  • 標(biāo)簽: 三地址??編譯原理??

資源簡介

三地址代碼是編譯原理語法分析后的中間語言的一種,這是我剛完成的三地址代碼生成器,符合的語法規(guī)則及其語義規(guī)則如下(S→if C then S1 else S2,這條規(guī)則沒有加,其余都已完成,也許還有bug,歡迎大家給予指正):產(chǎn)生式 語義規(guī)則S → id = E S.code = E.code || gen(id.place’:=’E.place)S → if C then S1 C.true = newlabel; C.false = S.next;S1.next = S.next;S.code = C.code || gen(E.true’:’) || S1.codeS → if C then S1 else S2 C.true = newlabel; C.false = newlabel;S1.next = S2.next =S.next;S.code = C.code || gen(E.true’:’) || S1.code ||gen(‘goto’,S.next)|| gen(E.false’:’) || S2.codeS → while C do S1 S.begin = newlabel; C.true = newlabel;C.false = S.next; S1.next = S.begin;S.code = gen(S.begin’:’) || C.code ||gen(E.true’:’) || S1.code || gen(‘goto’S.begin);C → E1 > E2 C.code = E1.code || E2.code ||gen(‘if’E1.place’>’E2.place’goto’C.true) ||gen(‘goto’C.false)C → E1 < E2 C.code = E1.code || E2.code ||gen(‘if’E1.place’<’E2.place’goto’C.true) ||gen(‘goto’C.false)C → E1 = E2 C.code = E1.code || E2.code ||gen(‘if’E1.place’=’E2.place’goto’C.true) ||gen(‘goto’C.false)E → E1 + T E.place = newtemp;E.code = E1.code||T.code||gen(E.place’:=’E1.place’+’T.place)E → E1 - T E.place = newtemp; E.code = E1.code || T.code ||gen(E.place’:=’E1.place’-’T.place)E → T E.place = T.place; E.code = T.codeT → F T.place = F.place; T.code = F.codeT → T1 * F T.place = newtemp;T.code = T1.code || F.code ||gen(T.place’:=’T1.place’*’F.place)T → T1 / F T.place = newtemp; T.code = T1.code || F.code ||gen(T.place’:=’T1.place’/’F.place)F → ( E ) F.place = E

資源截圖

代碼片段和文件信息

#include
#include
#include
#include
#include
char?input[200]mech[10];????????/*input存放最先輸入的字符串,在輸入的過程中,就進行了預(yù)處理*/
char?ech[100][10];
char?echattr[100][10];
char?nch[10];
char?Fplace[10]Eplace[10]Tplace[10]TTplace[10]EEplace[10]E1place[10]E2place[10]idplace[10]Splace[10]Snext[10]Ctrue[10]Cfalse[10]Sbegin[10];
char?S1next[10]S2next[10];
char?Fcode[50]Ecode[50]Tcode[50]TTcode[50]EEcode[50]E1code[50]E2code[50]idcode[50]Scode[50]Ccode[50];
int?temp=1;
int?label=0;
int?stack;
int?nuattr;
int?flag=0;
char?attr[10];
int?number=0;
int?now;
void?init(char?*ch)
{
????char?newc[10];???????????????????????????????????/*xinlingsoft?http://hi.csdn.net/bjutlife??sxlbjut@gmail.com*/
????newc[0]=NULL;
????strcpy(chnewc);
}
int?S();
int?SS();
int?E();
int?C();
int?CC();
int?T();
int?TT();
int?EE();
int?F();
int?scan();
void?newtemp(char?*ch)
{
????sprintf(attr“%d“temp);
????strcpy(ch“t“);
????strcat(chattr);
????temp++;
}
void?newlabel(char?*ch)
{
????sprintf(attr“%d“l(fā)abel);
????strcpy(ch“L“);
????strcat(chattr);
????label++;
}
main()
{
????int?i=0j=0t;
????char?c;
????char?c1[2];
????c1[1]=‘\0‘;
????printf(“Please?input?the?String?end?with?#:\n“);????/*以#代表結(jié)束*/
????do
????{
????????c=getchar();
????????if(c==‘?‘)
????????{
????????????if(i==0)
????????????{
????????????????while(c==‘?‘)
????????????????{
????????????????????c=getchar();
????????????????}
????????????????input[i]=c;
????????????????i++;
????????????}
????????????else
????????????{
????????????????while(c==‘?‘)
????????????????{
????????????????????c=getchar();
????????????????}
????????????????input[i]=‘?‘;
????????????????i++;
????????????????input[i]=c;
????????????????i++;
????????????}
????????}
????????else
????????{
????????????input[i]=c;
????????????i++;
????????}
????}while(c!=‘#‘);???????????????????????????????????/*輸入字符串,輸入的過程中進行預(yù)處理,去掉多余的空格*/
????i=0;
????while(input[i]!=‘#‘)
????{
????????c1[0]=input[i];
????????if(c1[0]==‘+‘||c1[0]==‘-‘||c1[0]==‘*‘||c1[0]==‘/‘||c1[0]==‘>‘||c1[0]==‘<‘||c1[0]==‘=‘||c1[0]==‘(‘||c1[0]==‘)‘)
????????{
????????????if(strlen(mech)!=0)
????????????{
????????????????t=scan(mech);
????????????????if(t==15)
????????????????{
????????????????????sprintf(attr“%d“nuattr);
????????????????????strcpy(echattr[j]attr);?????????????????/*xinlingsoft?http://hi.csdn.net/bjutlife??sxlbjut@gmail.com*/
????????????????????strcpy(mech“int10“);
????????????????}
????????????????if(t==16)
????????????????{
????????????????????sprintf(attr“%d“nuattr);
????????????????????strcpy(echattr[j]attr);
????????????????????strcpy(mech“int16“);
????????????????}
????????????????if(t==17)
????????????????{
????????????????????sprintf(attr“%d“nuattr);
????????????????????strcpy(echattr[j]attr);
????????????????????strcpy(mech“int8“);
????????????????}
????????????????if(t==18)
????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????23283??2008-05-30?10:18??sandizhifinal.c

-----------?---------??----------?-----??----

????????????????23283????????????????????1


評論

共有 條評論