最近在写编译器,有这样一段代码
1 typedef struct{ 2 int symbolnum; 3 char *name; //id36 4 int i; //int37 5 float f; //float38 6 char *s; //string39 7 }To; 8 typedef To* Token;
1 Token ReadToken() //从fp文件中读取一行形如(36,sum)的行,返回值被压栈 2 { 3 char strLine[1024]; 4 char n1[10]; 5 char n2[20]; 6 int i=0,j=0; 7 int t1; 8 Token rt = (Token)malloc(sizeof(To)); 9 if(feof(fp)||(NULL == fgets(strLine,1024,fp))) 10 { 11 rt->symbolnum = 0; 12 return rt; 13 } 14 15 for(i=1;;i++) 16 { 17 if(strLine[i] == ',') 18 { 19 n1[i-1] = '