mod.sources Volume 7, Issue 73 (BASIC)
Stan Barber
sob at soma.bcm.tmc.edu
Fri Jan 16 03:22:03 AEST 1987
There was a basic interpreter posted in Mod.sources in late November/early December.
It was great, but there was a problem (on my compiler at least) with bas3.c.
The problem was due to a typedef called "value" and a structure member called "value".
I altered the latter to "valuename" and all was happy.
Here is the diff!
*** bas3.c.BAK Wed Dec 17 17:01:54 1986
--- bas3.c Thu Jan 15 11:14:41 1987
***************
*** 36,42
struct m {
value r1;
int lastop;
! char value;
char vty;
};
--- 36,42 -----
struct m {
value r1;
int lastop;
! char valuename;
char vty;
};
***************
*** 63,69
checksp();
j=restab;
! j->value=0;
for(;;){
c=getch();
--- 63,69 -----
checksp();
j=restab;
! j->valuename=0;
for(;;){
c=getch();
***************
*** 160,166
}
if(i>2)
firsttime = 0;
! ame: if(j->value< (char)i){ /* current operator has higher */
(++j)->lastop=c; /* precedence */
#ifndef V6C
j->r1 = res;
--- 160,166 -----
}
if(i>2)
firsttime = 0;
! ame: if(j->valuename< (char)i){ /* current operator has higher */
(++j)->lastop=c; /* precedence */
#ifndef V6C
j->r1 = res;
***************
*** 167,173
#else
push(&j->r1); /* block moving */
#endif
! j->value=i;
j->vty=vartype;
continue;
}
--- 167,173 -----
#else
push(&j->r1); /* block moving */
#endif
! j->valuename=i;
j->vty=vartype;
continue;
}
***************
*** 171,177
j->vty=vartype;
continue;
}
! if(! j->value ){ /* end of expression */
point--;
return;
}
--- 171,177 -----
j->vty=vartype;
continue;
}
! if(! j->valuename ){ /* end of expression */
point--;
return;
}
***************
*** 182,188
cvt(&j->r1); /* if changed then they must be */
vartype=0; /* changed to reals */
}
! (*mbin[(j->value<<1)+vartype])(&j->r1,&res,j->lastop);
j--; /* execute it then pop the stack and */
goto ame; /* deal with the next operator */
}
--- 182,188 -----
cvt(&j->r1); /* if changed then they must be */
vartype=0; /* changed to reals */
}
! (*mbin[(j->valuename<<1)+vartype])(&j->r1,&res,j->lastop);
j--; /* execute it then pop the stack and */
goto ame; /* deal with the next operator */
}
More information about the Comp.sources.bugs
mailing list