char *formatstring; /* formatstring used for printing */
Symbol *s; /* Symbol dummy */
%}
+/* We need to type things properly to limit complaints of lint*/
%%
programline : INTVALUE {newblock(ival); newemblock(ival);} stmts EOLN
| '#' INTVALUE STRVALUE EOLN
| '(' expression ')' {$$=$2;}
| '-' factor { $$=negate($2);}
| FLTVALUE {$$=loaddbl(dval);}
- | STRVALUE {$$=loadstr($1);}
- | variable {$$=loadvar($1);}
+ | STRVALUE {$$= STRINGTYPE; loadstr($1);}
+ | variable {$$=$1; loadvar($1);}
| INKEYSYM '$' { emcode("cal","$_inkey");
emcode("lfr",EMPTRSIZE);
$$= STRINGTYPE;
| VARPTR '(' '#' intvalue ')' { warning("Not supported"); $$=INTTYPE;}
| FUNCTION {$$= callfcn($1,0);}
| FUNCTION '(' cross exprlist')' {$$=callfcn($1,$4);}
- | funcname { $$=fcnend($1);}
- | funcname funccall ')' { $$=fcnend($1,$2);}
+ | funcname { $$=fcnend(0);}
+ | funcname funccall ')' { $$=fcnend($2);}
| MIDSYM '$' midparms
{ emcode("cal","$_mid");
emcode("asp",itoa($3));
#ifndef NORCSID
static char rcs_id[] = "$Header$" ;
#endif
-#include "lex.c"
+#include "basic.lex"
extern char *datalabel();
extern char *instrlabel();
extern char *typesize();
+extern char *typestring();
+extern void sprintf();
/* compile the next program in the list */
+/* Here we should open the input file. (for the future) */
FILE *yyin;
-compileprogram()
+compileprogram(dummyprog)
+char *dummyprog;
{
while( getline())
- yyparse();
- fclose(yyin);
+ (void) yyparse();
+ (void) fclose(yyin);
}
{
/* load a simple variable its address is on the stack*/
emcode("loi",typestring(type));
- return(type);
}
loadint(value)
int value;
int value;
{
emcode("lae",datalabel(value));
- return(STRINGTYPE);
}
loadaddr(s)
Symbol *s;
*currline,
*lastline;
+List *newlist()
+{
+ List *l;
+ l= (List *) salloc(sizeof(List));
+ return(l);
+}
+
/* Line management is handled here */
Linerecord *srchline(nr)
if(debug) printf("goto label %d\n",nr);
/* update currline */
- ll= (List *) salloc( sizeof(*ll));
+ ll= newlist();
ll-> linenr=nr;
ll-> nextlist= currline->gotos;
currline->gotos= ll;
{
/* declare forward label */
if(debug) printf("declare forward %d\n",nr);
- ll= (List *) salloc( sizeof(*ll));
+ ll= newlist();
ll->emlabel= genlabel();
ll-> linenr=nr;
ll->nextlist= forwardlabel;
List *gosublabel()
{
List *l;
- int n;
- l= (List *) salloc(sizeof(List));
+ l= newlist();
l->nextlist=0;
l->emlabel=genlabel();
if( gotail){
{
List *l;
- l= (List *) salloc(sizeof(List));
+ l= newlist();
l->emlabel= gotolabel(nr);
l->nextlist=0;
if( jumphead==0) jumphead= jumptail= l;
}
jumphead= jumptail=0; jumpcnt=0;
- l= (List *) salloc(sizeof(List));
+ l= newlist();
l->nextlist=0;
l->emlabel=firstlabel;
if( gotail){
/* a small EM programs has been found */
prologcode();
prolog2();
- fclose(tmpfile);
+ (void) fclose(tmpfile);
tmpfile= fopen(tmpfname,"r");
if( tmpfile==NULL)
fatal("tmp file disappeared");
while( (length=fread(buf,1,512,tmpfile)) != 0)
- fwrite(buf,1,length,emfile);
+ (void) fwrite(buf,1,length,emfile);
epilogcode();
- unlink(tmpfname);
+ (void) unlink(tmpfname);
}
int argc;
char **argv;
{
- int i,j,k;
+ int i;
char *ext;
- j=k=0;
if(argc< 4)
{
fprintf(stderr,"usage %s <flags> <file>.i <file>.e <source>\n", argv[0]);
case 't': traceflag++; break; /* line tracing */
case 'h':/* split EM file */
hflag=0;
- threshold= (long) atol(argv[i][2]);
+ threshold= atoi(argv[i][2]);
if( threshold==0)
threshold= THRESHOLD;
break;
phase1()
{
/* copy all offloaded blocks */
- Linerecord *lr, *lf,*lr2;
- int blksize;
+ Linerecord *lr, *lf;
+ long blksize;
lf= lr= firstline;
blksize= lr->codelines;
if( fcn->symtype== DEFAULTTYPE)
fcn->symtype= DOUBLETYPE;
}
-fcnsize(s)
-Symbol *s;
+fcnsize()
{
/* generate portable function size */
int i;
emcode("ret", typestring(fcn->symtype));
/* generate portable EM code */
fprintf(tmpfile," end ");
- fcnsize(fcn);
+ fcnsize();
s= firstsym;
while(s)
{
dclparm(s)
Symbol *s;
{
- int i,size=0;
+ int size=0;
if( s->symtype== DEFAULTTYPE)
s->symtype= DOUBLETYPE;
s->isparam=1;
fcnindex++;
fcntable[fcnindex]=s;
}
+ return(s->symtype);
}
-fcnend(fcntype, parmcount)
-int fcntype, parmcount;
+fcnend(parmcount)
+int parmcount;
{
int type;
/* check number of arguments */
fprintf(tmpfile," cal $_%s\n",fcn->symname);
emlinecount++;
fprintf(tmpfile," asp ");
- fcnsize(fcn);
+ fcnsize();
emcode("lfr",typestring(fcn->symtype));
type= fcn->symtype;
fcnindex--;