Checking in Martin's changes.

This commit is contained in:
em 1985-01-17 14:10:27 +00:00
parent e75b8772ca
commit 6512a304a0
8 changed files with 39 additions and 31 deletions

View file

@ -87,6 +87,7 @@ int chann; /* input/output channel */
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
@ -417,8 +418,8 @@ factor : INTVALUE {$$=loadint(ival);}
| '(' 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;
@ -426,8 +427,8 @@ factor : INTVALUE {$$=loadint(ival);}
| 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));
@ -460,4 +461,4 @@ exprlist: expression { typetable[0]= $1; $$=1;}
#ifndef NORCSID
static char rcs_id[] = "$Header$" ;
#endif
#include "lex.c"
#include "basic.lex"

View file

@ -61,3 +61,5 @@ extern char *itoa();
extern char *datalabel();
extern char *instrlabel();
extern char *typesize();
extern char *typestring();
extern void sprintf();

View file

@ -6,13 +6,15 @@ static char rcs_id[] = "$Header$" ;
/* 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);
}

View file

@ -321,7 +321,6 @@ int type;
{
/* load a simple variable its address is on the stack*/
emcode("loi",typestring(type));
return(type);
}
loadint(value)
int value;
@ -343,7 +342,6 @@ loadstr(value)
int value;
{
emcode("lae",datalabel(value));
return(STRINGTYPE);
}
loadaddr(s)
Symbol *s;

View file

@ -11,6 +11,13 @@ Linerecord *firstline,
*currline,
*lastline;
List *newlist()
{
List *l;
l= (List *) salloc(sizeof(List));
return(l);
}
/* Line management is handled here */
Linerecord *srchline(nr)
@ -94,7 +101,7 @@ int 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;
@ -108,7 +115,7 @@ int nr;
{
/* 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;
@ -132,9 +139,8 @@ int gosubcnt=1;
List *gosublabel()
{
List *l;
int n;
l= (List *) salloc(sizeof(List));
l= newlist();
l->nextlist=0;
l->emlabel=genlabel();
if( gotail){
@ -192,7 +198,7 @@ int nr;
{
List *l;
l= (List *) salloc(sizeof(List));
l= newlist();
l->emlabel= gotolabel(nr);
l->nextlist=0;
if( jumphead==0) jumphead= jumptail= l;
@ -247,7 +253,7 @@ int type;
}
jumphead= jumptail=0; jumpcnt=0;
l= (List *) salloc(sizeof(List));
l= newlist();
l->nextlist=0;
l->emlabel=firstlabel;
if( gotail){
@ -277,12 +283,12 @@ simpleprogram()
/* 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);
}

View file

@ -15,10 +15,9 @@ parseparams(argc,argv)
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]);
@ -32,7 +31,7 @@ char **argv;
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;

View file

@ -41,8 +41,8 @@ List *l;
phase1()
{
/* copy all offloaded blocks */
Linerecord *lr, *lf,*lr2;
int blksize;
Linerecord *lr, *lf;
long blksize;
lf= lr= firstline;
blksize= lr->codelines;

View file

@ -191,8 +191,7 @@ heading( )
if( fcn->symtype== DEFAULTTYPE)
fcn->symtype= DOUBLETYPE;
}
fcnsize(s)
Symbol *s;
fcnsize()
{
/* generate portable function size */
int i;
@ -210,7 +209,7 @@ int type;
emcode("ret", typestring(fcn->symtype));
/* generate portable EM code */
fprintf(tmpfile," end ");
fcnsize(fcn);
fcnsize();
s= firstsym;
while(s)
{
@ -226,7 +225,7 @@ int type;
dclparm(s)
Symbol *s;
{
int i,size=0;
int size=0;
if( s->symtype== DEFAULTTYPE)
s->symtype= DOUBLETYPE;
s->isparam=1;
@ -257,9 +256,10 @@ Symbol *s;
fcnindex++;
fcntable[fcnindex]=s;
}
return(s->symtype);
}
fcnend(fcntype, parmcount)
int fcntype, parmcount;
fcnend(parmcount)
int parmcount;
{
int type;
/* check number of arguments */
@ -270,7 +270,7 @@ int fcntype, parmcount;
fprintf(tmpfile," cal $_%s\n",fcn->symname);
emlinecount++;
fprintf(tmpfile," asp ");
fcnsize(fcn);
fcnsize();
emcode("lfr",typestring(fcn->symtype));
type= fcn->symtype;
fcnindex--;