?? jp jp(0).c
字號:
clh->line[0]=getdq[0].line;
clh->line[1]=-1;
clh->layer=llayer;
clh->next=NULL;/* fill over the const form,and the deal with const var node*/
fprintf(out,"\n%d %d",2,clh);/*output length*/
getsy();/*重新讀入一個章詞到輸入棧*/
}/*end if,deal the length over*/
else{/*if the length value is not a digtal,then*/
shzh->length=-1;/*define arrays error*/
shzh->start=-1;
yfchc(" ","illegal length of array");
return;
}
if(strcmp(getdq[0].name,"]")==0)
{
fprintf(out,"\n%d %d",0,28);/*output ']'*/
getsy();/*重新讀入一個章詞到輸入棧*/
}
else{
yfchc(" ","Statement missing']'");
return;
}
if(strcmp(getdq[0].name,",")==0){
fprintf(out,"\n%d %d",0,32);/*output ','*/
getsy();/*重新讀入一個章詞到輸入棧*/
}
else if(strcmp(getdq[0].name,";")==0)
{
fprintf(out,"\n%d %d",0,33);/*output ';'*/
getsy();/*重新讀入一個章詞到輸入棧*/
return;/*over*/
}
else{
yfchc(" ","Statement missing ','or';'");
return;
}
}/*end if,define array over*/
else{/*deal with the var*/
blh=malloc(sizeof(struct bl));
style=1;
bln=set(llayer,&style," ");
*bln=blh;
strcpy(blh->name,getdq[0].name);
blh->type=record;
blh->line[0]=getdq[0].line;
blh->line[1]=-1;
blh->layer=llayer;
blh->start=addr;
switch(record)/*count the next var`s began address*/
{
case 1:addr=addr+2;break;
case 2:addr=addr+1;break;
case 3:addr=addr+4;break;
}/*end switch*/
blh->next=NULL;/*fill var form over,deal the var node over*/
fprintf(out,"\n%d %d",1,blh);/*output var name*/
getsy();/*重新讀入一個章詞到輸入棧*/
if(strcmp(getdq[0].name,",")==0)
{
fprintf(out,"\n%d %d",0,32);/*output ','*/
getsy();/*重新讀入一個章詞到輸入棧*/
}
else if(strcmp(getdq[0].name,";")==0)
{
fprintf(out,"\n%d %d",0,33);/*output ','*/
getsy();/*重新讀入一個章詞到輸入棧*/
return;/*deal over and exit*/
}
else{
yfchc(" ","Statement missing ',' or ';'");
return;
}
}/*end else ,over deal the var*/
}/*deal over one var*/
else{
yfchc(getdq[0].name,"illegal name of variable");
return;
}
}/*end while*/
}
void testpro(void){
int type,num;
int i;
int door,doorskip=0;
char c;
union all
{
struct bl *a;/*1*/
struct cl *b;/*2*/
struct shz *c;/*3*/
struct hsh *d;
struct cjbl *e;/*5*/
struct cch *f;/*6*/
}pp,ll;
printf("\n\n\n");
printf("\n Now,the cffx() programe have finished,");
printf("\nand all words of source program have been analyzed!");
printf("\n\n Press 's' to skip,or press other any key will show the message of one word...");
if(getch()=='s') doorskip=1;
door=1;
while(door>1)
{
if(door==1&&(feof(out)!=0||doorskip==1))
{
printf("\n\n Press'e'to exit,or press'y' enter chain-table.");
while((c=getch())!='e'&&c!='y');
if(c=='e')
break;
else door=2;
}
if(door==1&&feof(out)==0)
fscanf(out,"%d %d",&type,&num);
if(door==2)
{
printf("\n\n Please input your choic:\n Press'h'enter head-node;");
printf("press'e'to exit !");
printf("\n press'n'enter next node:");
printf("Press'a'to go to the address you input.");
while((c=getch())!='h'&&c!='n'&&c!='a'&&c!='e');
switch(c)
{
case 'h':type=5;
num=(int)head;
break;
case 'n':switch(type)
{
case 11:type=1;
case 1:pp.a=(struct bl*)num;
if(pp.a->next!=NULL)
num=(int)pp.a->next;
else{
printf("\n\n The next node is NULL! press any key to continue.");
getch();
type=11;
}
break;
case 12:type=2;
case 2:pp.b=(struct cl *)num;
if(pp.b->next!=NULL)
num=(int)pp.b->next;
else{
printf("\n\n the next node is NULL! Press any key to continue.");
getch();
type=12;
}
break;
case 13:type=3;
case 3:pp.c=(struct shz *)num;
if(pp.c->next!=NULL)
num=(int)pp.c->next;
else{
printf("\n\n the next node is NULL! Press any key to continue.");
getch();
type=13;
}
break;
case 14:type=4;
case 4:pp.d=(struct hsh *)num;
if(pp.d->next!=NULL)
num=(int)pp.d->next;
else{
printf("\n\n the next node is NULL! Press any key to continue.");
getch();
type=14;
}
break;
case 15:type=5;
case 5:pp.e=(struct cjbl *)num;
if(pp.e->next!=NULL)
{
num=(int)pp.e->next;
type=4;
}
else{
printf("\n\n the next node is NULL! Press any key to continue.");
getch();
type=15;
}
break;
case 16:type=6;
case 6:pp.f=(struct cch *)num;
if(pp.f->next!=NULL)
num=(int)pp.f->next;
else{
printf("\n\n the next node is NULL! Press any key to continue.");
getch();
type=16;
}
}/*end switch(type)*/
break;
case 'a':printf("\n\n Please input your address and number of struct.");
printf("\n The address=");
scanf("%d",&num);
printf("The number=");
scanf("%d",&type);
break;
case 'e':return;
}/*end switch(c)*/
}/*end if(door==2)*/
switch(type)
{
case 0:printf("\n\n%d&d",type,num);
printf(" %s",word[num].name);
break;
case 7:printf("\n\n%d&d",type,num);
break;
case 1:printf("\n\n%d&d",type,num);
pp.a=(struct bl*)num;
printf("\n name=%s",pp.a->name);
printf("\n type=%d",pp.a->type);
printf("\n start=%d",pp.a->start);
printf("\n layer=%d",pp.a->layer);
i=0;
printf("\n line=");
while(pp.a->line[i]!=1)
{
printf("%d,",pp.a->line[i]);
i=i+1;
}
printf("\n next=%d,",pp.a->next);
break;
case 2:printf("\n\n%d&d",type,num);
pp.b=(struct cl*)num;
printf("\n name=%s",pp.b->name);
printf("\n type=%d",pp.b->type);
printf("\n layer=%d",pp.b->layer);
switch(pp.b->type)
{
case 1:printf("\n int=%d",pp.b->a);
break;
case 2:printf("\n int=%s",pp.b->c);
break;
case 3:printf("\n int=%f",pp.b->b);
}
i=0;
printf("\n line=");
while(pp.b->line[i]!=-1)
{
printf("%d,",pp.b->line[i]);
i=i+1;
}
printf("\n next=%d,",pp.b->next);
break;
case 3:printf("\n\n%d&d",type,num);
pp.c=(struct shz*)num;
printf("\n name=%s",pp.c->name);
printf("\n type=%d",pp.c->type);
printf("\n start=%d",pp.c->layer);
printf("\n layer=%d",pp.c->layer);
printf("\n length=%d",pp.c->length);
i=0;
printf("\n line=");
while(pp.c->line[i]!=-1)
{
printf("%d,",pp.c->line[i]);
i=i+1;
}
printf("\n next=%d,",pp.c->next);
break;
case 4:printf("\n\n%d&d",type,num);
pp.d=(struct hsh*)num;
printf("\n name=%s",pp.d->name);
printf("\n type=%d",pp.d->type);
printf("\n layer=%d",pp.d->layer);
i=0;
printf("\n line=");
{
printf("%d,",pp.c->line[i]);
i=i+1;
}
printf("\n struct b1*a =%d,",pp.d->a);
printf("\n struct c1*b=%d,",pp.d->b);
printf("\n struct shz*c=%d,",pp.d->c);
i=0;
printf("\n csh[5].p= ");
while(i<5&&pp.d->csh[i].p!=NULL)
{
printf("%-7d",pp.d->csh[i].p);
i=i+1;
}
i=0;
printf("\n csh[5].style");
while(i<5&&pp.d->csh[i].p!=NULL)
{
printf("%-7d",pp.d->csh[i].style);
i=i+1;
}
printf("\n next=%d,",pp.d->next);
break;
case 5:printf("\n\n%d&d",type,num);
pp.e=(struct cjbl*)num;
printf("\n name=%d",pp.e->layer);
printf("\n struct b1*a =%d,",pp.e->a);
printf("\n struct c1*b =%d,",pp.e->b);
printf("\n struct shz*c =%d,",pp.e->c);
printf("\n struct cch*f =%d,",pp.e->f);
printf("\n next=%d",pp.e->next);
break;
case 6:printf("\n\n%d&d",type,num);
pp.f=(struct cch*)num;
printf("\n name=%s",pp.f->name);
printf("\n layer=%d",pp.f->layer);
printf("\n why=%s",pp.f->why);
i=0;
printf("\n line=");
{
printf("%d,",pp.c->line[i]);
i=i+1;
}
printf("\n next=%d",pp.f->next);
}/*end switch */
if(door==1)
getch();
}/*end switch */
}/*end testpro */
void cldy(void)
{
int i;
int record,typee,style;
struct cl *clh,*clh1,**cln;
fprintf(out,"\n%d %d",0,5);/*輸出"const" */
getsy();
while(1)/*進入常量處理 */
{
record=0;
typee=chjtb(getdq[0].name);
if(typee==1||typee==2||typee==3)/*單詞為合法的變量類型 */
{
record=typee;/*記下變量的類型*/
fprintf(out,"\n%d%d",0,typee);/*output 變量類型 */
getsy();/*重新讀入一個單詞到輸入棧*/
typee=chjtb(getdq[0].name);
}
else{
yfchc("","declaration stntax error");/*記錄出錯誤信息*/
return;/*常量定義出錯,退出常量定義處理函數*/
}
if(record!=0&&getdq[0].t==1&&typee==0)/*定義的變量名合法*/
{
if(chjtb(getdq[1].name)==27)/*確定為數組定義,27號表示'['*/
{
if(record!=2)
{
yfchc("","Sorry,only char array is legal in const definition");/*記錄出錯誤信息*/
return; /*在常量定義中僅支持字符數組,如不是,退出常量定義處理函數*/
}
clh=malloc(sizeof(struct cl));/*申請一個常量節點,并連接*/
style=2;
cln=set(llayer,&style,"");
*cln=clh;
strcpy(clh->name,getdq[0].name);
clh->type=2;
clh->c[0]='\0';
clh->line[0]=getdq[0].line;
clh->line[1]=-1;
clh->layer=llayer;
clh->next=NULL;/*填完部分常量表,但是內容沒填*/
fprintf(out,"\n%d%d",2,clh);/*output 常量名*/
getsy();/*重新讀入一個單詞到輸入棧*/
fprintf(out,"\n%d%d",0,27);/*output '['*/
getsy();/*重新讀入一個單詞到輸入棧*/
if(getdq[0].t==2)/*如果是數字,則長度有效*/
{
clh1=malloc(sizeof(struct cl));/*申請一個常量節點,并連接*/
style=2;
cln=set(llayer,&style,"");
*cln=clh1;
strcpy(clh1->name,"");
clh1->type=1;
clh1->a=atoi(getdq[0].name);
clh1->line[0]=getdq[0].line;
clh1->layer=-1;
clh1->layer=llayer;
clh->next=NULL;/*填完部分常量表,但是內容沒填*/
fprintf(out,"\n%d%d",2,clh1);/*output 常量名*/
getsy();/*重新讀入一個單詞到輸入棧*/
}/* end if,長度處理完畢*/
else/*如果長度值不是數字,則進行以下處理*/
{
clh->c[0]='\0';
yfchc("","illegal length of array");/*記錄出錯誤信息*/
return;/*數組的定義不合法,退出常量定義處理函數*/
}
if(strcmp(getdq[0].name,"]")==0)
{
fprintf(out,"\n%d%d",0,28);/*output ']'*/
getsy();/*重新讀入一個單詞到輸入棧*/
}
else{
yfchc("","Statemen missing']'");/*記錄出錯誤信息*/
return;/*數組的定義不合法,退出常量定義處理函數*/
}
if(strcmp(getdq[0].name,":=")==0)
{
fprintf(out,"\n%d%d",0,36);/*output ':='*/
getsy();/*重新讀入一個單詞到輸入棧*/
}
else{
yfchc("","Statemen missing':='");/*記錄出錯誤信息*/
return;/*數組的定義不合法,退出常量定義處理函數*/
}
if(strcmp(getdq[0].name,"\"")==0)
{
fprintf(out,"\n%d%d",0,38);/*output '['*/
getsy();/*重新讀入一個單詞到輸入棧*/
}
else{
yfchc("","Statemen missing'\"'");/*記錄出錯誤信息*/
return;/*數組的定義不合法,退出常量定義處理函數*/
}
i=1;
while(getdq[0].t==5&&i<=clh1->a&&i<80&&doorkey<=3)
{
i=i+1;
strcat(clh->c,getdq[0].name);
getsy();
}
clh1=malloc(sizeof(struct cl));/*申請一個常量節點,并連接*/
style=2;
cln=set(llayer,&style,"");
strcpy(clh1->name,"");
clh1->type=2;
strcpy(clh->c,clh->c);
while(getdq[0].t==5&&i<80&&doorkey<=3)
{
i=i+1;
strcat(clh1->c,getdq[0].name);
getsy();
}
clh1->line[0]=getdq[0].line;
clh1->line[1]=-1;
clh1->layer=llayer;
clh1->next=NULL;
if(clh->c[0]=='\0')
free(clh1);
else{
*cln=clh1;
fprintf(out,"\n%d %d",2,clh1);
}
if(strcmp(getdq[0].name,"\"")==0)
{
fprintf(out,"\n%d %d",0,38);
getsy();
}
else{
yfchc("","Statement missint'\"'");
return;
}
if(strcmp(getdq[0].name,",")==0)
{
fprintf(out,"\n%d %d",0,32);
getsy();
}
else if(strcmp(getdq[0].name,";")==0)
{
fprintf(out,"\n%d %d",0,33);
getsy();
return;
}
else{
yfchc("","Statement missing ','or ';'");
return;
}
}
else{
if(strcmp(getdq[1].name,":=")!=0)
{yfchc("","Statement missing':='");
return;
}
if (record==2 && strcmp(getdq[2].name,"\"")!=0)
{
yfchc("","Statement missing '\"'");
return;
}
clh=malloc(sizeof(struct cl));/*申請一個常量節點,并連接*/
style=2;
cln=set(llayer,&style,"");
*cln=clh;
strcpy(clh->name,getdq[0].name);
clh->type=record;
clh->line[0]=getdq[0].line;
clh->line[1]=-1;
clh->layer=llayer;
clh->next=NULL;/*填完部分常量表,但是內容沒填*/
fprintf(out,"\n%d%d",2,clh);/*output 常量名*/
getsy();/*重新讀入一個單詞到輸入棧*/
fprintf(out,"\n%d%d",0,36);/*output '['*/
getsy();/*重新讀入一個單詞到輸入棧*/
clh1=malloc(sizeof(struct cl));/*申請一個常量節點,并連接*/
style=2;
cln=set(llayer,&style,"");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -