my version (CJ)
This commit is contained in:
parent
cf04776017
commit
a5d96ae90f
9 changed files with 146 additions and 55 deletions
|
@ -1,12 +1,19 @@
|
||||||
|
EMHOME = ../../..
|
||||||
|
MODLIB = $(EMHOME)/modules/lib
|
||||||
|
INCL = -I$(EMHOME)/modules/h
|
||||||
GFILES= occam.g
|
GFILES= occam.g
|
||||||
PRIMARY= occam.o Lpars.o keytab.o lex.yy.o code.o em.o
|
PRIMARY= occam.o Lpars.o keytab.o lex.yy.o code.o em.o
|
||||||
SECUNDARY= symtab.o expr.o builtin.o
|
SECUNDARY= symtab.o expr.o builtin.o
|
||||||
TERTIARY= report.o
|
TERTIARY= report.o
|
||||||
LLOPT=
|
LLOPT=
|
||||||
LIBRARY= -lln libemk.a libsystem.a
|
LIBRARY= $(MODLIB)/libem_mes.a $(MODLIB)/libemk.a \
|
||||||
|
$(MODLIB)/libprint.a $(MODLIB)/libstring.a \
|
||||||
|
$(MODLIB)/libsystem.a -lln
|
||||||
|
CFLAGS = -O $(INCL)
|
||||||
|
HSRC = code.h em.h expr.h sizes.h symtab.h token.h
|
||||||
|
CSRC = builtin.c code.c em.c expr.c keytab.c report.c symtab.c
|
||||||
|
|
||||||
all:
|
all: dummy
|
||||||
make dummy
|
|
||||||
make oc
|
make oc
|
||||||
|
|
||||||
dummy: $(GFILES)
|
dummy: $(GFILES)
|
||||||
|
@ -19,6 +26,22 @@ oc: $(PRIMARY) $(SECUNDARY) $(TERTIARY)
|
||||||
lex.yy.c: lex.l
|
lex.yy.c: lex.l
|
||||||
lex lex.l
|
lex lex.l
|
||||||
|
|
||||||
|
install: all
|
||||||
|
rm -f $(EMHOME)/lib/em_occam
|
||||||
|
cp oc $(EMHOME)/lib/em_occam
|
||||||
|
|
||||||
|
cmp: all
|
||||||
|
-cmp oc $(EMHOME)/lib/em_occam
|
||||||
|
|
||||||
|
pr:
|
||||||
|
@pr Makefile $(HSRC) occam.g lex.l $(CSRC)
|
||||||
|
|
||||||
|
opr:
|
||||||
|
make pr | opr
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f lex.yy.c occam.c *.o oc
|
||||||
|
|
||||||
$(PRIMARY): Lpars.h
|
$(PRIMARY): Lpars.h
|
||||||
occam.o keytab.o: token.h
|
occam.o keytab.o: token.h
|
||||||
occam.o $(SECUNDARY): symtab.h expr.h
|
occam.o $(SECUNDARY): symtab.h expr.h
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include "symtab.h"
|
#include "symtab.h"
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "sizes.h"
|
#include "sizes.h"
|
||||||
|
@ -32,43 +31,43 @@ void init_builtins()
|
||||||
|
|
||||||
info.vc.st.builtin=file;
|
info.vc.st.builtin=file;
|
||||||
info.vc.offset=0;
|
info.vc.offset=0;
|
||||||
insert(file, T_CHAN|T_ARR|T_BUILTIN, _NFILE, info);
|
insert(file, T_CHAN|T_ARR|T_BUILTIN, 20, &info);
|
||||||
|
|
||||||
info.vc.st.builtin=file;
|
info.vc.st.builtin=file;
|
||||||
info.vc.offset=0;
|
info.vc.offset=0;
|
||||||
insert("input", T_CHAN|T_BUILTIN, 1, info);
|
insert("input", T_CHAN|T_BUILTIN, 1, &info);
|
||||||
|
|
||||||
info.vc.st.builtin=file;
|
info.vc.st.builtin=file;
|
||||||
info.vc.offset=wz+pz;
|
info.vc.offset=wz+pz;
|
||||||
insert("output", T_CHAN|T_BUILTIN, 1, info);
|
insert("output", T_CHAN|T_BUILTIN, 1, &info);
|
||||||
|
|
||||||
info.vc.st.builtin=file;
|
info.vc.st.builtin=file;
|
||||||
info.vc.offset=2*(wz+pz);
|
info.vc.offset=2*(wz+pz);
|
||||||
insert("error", T_CHAN|T_BUILTIN, 1, info);
|
insert("error", T_CHAN|T_BUILTIN, 1, &info);
|
||||||
|
|
||||||
/* DEF EOF= -1, TEXT= -2, RAW= -3: */
|
/* DEF EOF= -1, TEXT= -2, RAW= -3: */
|
||||||
|
|
||||||
info.const=new_const(-1L);
|
info.const=new_const(-1L);
|
||||||
insert("EOF", T_CONST|T_BUILTIN, 0, info);
|
insert("EOF", T_CONST|T_BUILTIN, 0, &info);
|
||||||
|
|
||||||
info.const=new_const(-2L);
|
info.const=new_const(-2L);
|
||||||
insert("TEXT", T_CONST|T_BUILTIN, 0, info);
|
insert("TEXT", T_CONST|T_BUILTIN, 0, &info);
|
||||||
|
|
||||||
info.const=new_const(-3L);
|
info.const=new_const(-3L);
|
||||||
insert("RAW", T_CONST|T_BUILTIN, 0, info);
|
insert("RAW", T_CONST|T_BUILTIN, 0, &info);
|
||||||
|
|
||||||
/* PROC open(VAR fd, VALUE name[], mode[])= .... : */
|
/* PROC open(VAR fd, VALUE name[], mode[])= .... : */
|
||||||
info.proc.st.builtin="b_open";
|
info.proc.st.builtin="b_open";
|
||||||
info.proc.pars=open_list;
|
info.proc.pars=open_list;
|
||||||
insert("open", T_PROC|T_BUILTIN, 0, info);
|
insert("open", T_PROC|T_BUILTIN, 0, &info);
|
||||||
|
|
||||||
/* PROC close(VALUE fd)= .... : */
|
/* PROC close(VALUE fd)= .... : */
|
||||||
info.proc.st.builtin="b_close";
|
info.proc.st.builtin="b_close";
|
||||||
info.proc.pars=close_list;
|
info.proc.pars=close_list;
|
||||||
insert("close", T_PROC|T_BUILTIN, 0, info);
|
insert("close", T_PROC|T_BUILTIN, 0, &info);
|
||||||
|
|
||||||
/* PROC exit(VALUE code)= .... : */
|
/* PROC exit(VALUE code)= .... : */
|
||||||
info.proc.st.builtin="b_exit";
|
info.proc.st.builtin="b_exit";
|
||||||
info.proc.pars=exit_list;
|
info.proc.pars=exit_list;
|
||||||
insert("exit", T_PROC|T_BUILTIN, 0, info);
|
insert("exit", T_PROC|T_BUILTIN, 0, &info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include <stdio.h>
|
|
||||||
#include "sizes.h"
|
#include "sizes.h"
|
||||||
#include "Lpars.h"
|
#include "Lpars.h"
|
||||||
#include "em_arith.h"
|
#include <em.h>
|
||||||
#include "em_label.h"
|
|
||||||
#include "em.h"
|
#include "em.h"
|
||||||
|
|
||||||
/* This file is used to shield code.c as much as possible from em dependant
|
/* This file is used to shield code.c as much as possible from em dependant
|
||||||
|
@ -12,7 +10,8 @@
|
||||||
* word or double word arith.
|
* word or double word arith.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int wz, pz;
|
int wz = 4, pz = 4, vz = 4;
|
||||||
|
int Lflag;
|
||||||
static Lab=0;
|
static Lab=0;
|
||||||
char *malloc();
|
char *malloc();
|
||||||
|
|
||||||
|
@ -23,15 +22,14 @@ void init()
|
||||||
|
|
||||||
void openfile(file) char *file;
|
void openfile(file) char *file;
|
||||||
{
|
{
|
||||||
C_open(file);
|
if (C_open(file) < 0) {
|
||||||
|
fatal("Could not open output file");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void meswp()
|
void meswp()
|
||||||
{
|
{
|
||||||
C_mes_begin(2);
|
C_ms_emx((arith) wz, (arith) pz);
|
||||||
C_cst((arith) wz);
|
|
||||||
C_cst((arith) pz);
|
|
||||||
C_mes_end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void maxdes()
|
void maxdes()
|
||||||
|
@ -82,7 +80,7 @@ char *proc_label(L, name) register L; register char *name;
|
||||||
lab=malloc(strlen(name)+(1+sizeof(int)*3+1));
|
lab=malloc(strlen(name)+(1+sizeof(int)*3+1));
|
||||||
/* That is: P<L><name>\0 */
|
/* That is: P<L><name>\0 */
|
||||||
|
|
||||||
sprintf(lab, "P%d", L);
|
sprint(lab, "P%d", L);
|
||||||
|
|
||||||
n=lab+strlen(lab);
|
n=lab+strlen(lab);
|
||||||
|
|
||||||
|
@ -278,7 +276,7 @@ void lol(offset) int offset; { C_lol((arith) offset); }
|
||||||
void lor0() { C_lor((arith) 0); }
|
void lor0() { C_lor((arith) 0); }
|
||||||
void lxa(offset) int offset; { C_lxa((arith) offset); }
|
void lxa(offset) int offset; { C_lxa((arith) offset); }
|
||||||
void lxl(offset) int offset; { C_lxl((arith) offset); }
|
void lxl(offset) int offset; { C_lxl((arith) offset); }
|
||||||
void meserr() { C_mes_begin(0); C_mes_end(); }
|
void meserr() { C_ms_err(); }
|
||||||
void ngi() { C_ngi((arith) vz); }
|
void ngi() { C_ngi((arith) vz); }
|
||||||
void pro(lab) char *lab; { C_pro_narg(lab); }
|
void pro(lab) char *lab; { C_pro_narg(lab); }
|
||||||
void ret(size) int size; { C_ret((arith) size); }
|
void ret(size) int size; { C_ret((arith) size); }
|
||||||
|
@ -300,7 +298,7 @@ void zne(lab) int lab; { C_zne((label) lab); }
|
||||||
char *itoa(i) long i;
|
char *itoa(i) long i;
|
||||||
{
|
{
|
||||||
static char a[sizeof(long)*3];
|
static char a[sizeof(long)*3];
|
||||||
sprintf(a, "%D", i);
|
sprint(a, "%ld", i);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,6 +312,7 @@ void lin()
|
||||||
static oldline=0;
|
static oldline=0;
|
||||||
extern yylineno;
|
extern yylineno;
|
||||||
|
|
||||||
|
if (Lflag) return;
|
||||||
if (yylineno!=oldline)
|
if (yylineno!=oldline)
|
||||||
C_lin((arith) (oldline=yylineno));
|
C_lin((arith) (oldline=yylineno));
|
||||||
}
|
}
|
||||||
|
@ -328,9 +327,10 @@ char *curr_file="stdin";
|
||||||
|
|
||||||
static void do_fil(f) struct ftree *f;
|
static void do_fil(f) struct ftree *f;
|
||||||
{
|
{
|
||||||
|
if (Lflag) return;
|
||||||
if (f->lab==0) {
|
if (f->lab==0) {
|
||||||
dot_label(new_dot_label(&f->lab));
|
dot_label(new_dot_label(&f->lab));
|
||||||
C_rom_scon(f->file, (arith) strlen(f->file));
|
C_rom_scon(f->file, (arith) (strlen(f->file)+1));
|
||||||
}
|
}
|
||||||
C_fil_dlb((label) f->lab);
|
C_fil_dlb((label) f->lab);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,3 +19,4 @@ void init_rt(), exp(), rom(), blt(), magic(), lin(), tst(), fil(), trp();
|
||||||
void main_fil(), init(), openfile(), closefile(), maxdes();
|
void main_fil(), init(), openfile(), closefile(), maxdes();
|
||||||
|
|
||||||
void par_begin(), par_fork(), par_end(), resumenext(), no_deadlock();
|
void par_begin(), par_fork(), par_end(), resumenext(), no_deadlock();
|
||||||
|
extern int Lflag;
|
||||||
|
|
|
@ -271,9 +271,9 @@ char *tokenname(tk, inst) register tk, inst;
|
||||||
static char c[7];
|
static char c[7];
|
||||||
|
|
||||||
if (' '<tk && tk<='~')
|
if (' '<tk && tk<='~')
|
||||||
sprintf(c, "'%c'", tk);
|
sprint(c, "'%c'", tk);
|
||||||
else
|
else
|
||||||
sprintf(c, "'*#%02x'", tk);
|
sprint(c, "'*#%02x'", tk);
|
||||||
return c;
|
return c;
|
||||||
} else {
|
} else {
|
||||||
switch (tk) {
|
switch (tk) {
|
||||||
|
@ -284,7 +284,7 @@ char *tokenname(tk, inst) register tk, inst;
|
||||||
return keyname(tk);
|
return keyname(tk);
|
||||||
case IDENTIFIER:
|
case IDENTIFIER:
|
||||||
if (inst) {
|
if (inst) {
|
||||||
sprintf(fake_id, "_%d", ++fake_cnt);
|
sprint(fake_id, "_%d", ++fake_cnt);
|
||||||
token.t_sval=strcpy(malloc(strlen(fake_id)+1),
|
token.t_sval=strcpy(malloc(strlen(fake_id)+1),
|
||||||
fake_id);
|
fake_id);
|
||||||
return "IDENTIFIER";
|
return "IDENTIFIER";
|
||||||
|
@ -315,7 +315,7 @@ char *tokenname(tk, inst) register tk, inst;
|
||||||
static char qopc[5];
|
static char qopc[5];
|
||||||
|
|
||||||
for (i=0; op[i]!=tk; i++) ;
|
for (i=0; op[i]!=tk; i++) ;
|
||||||
sprintf(qopc, "'%s'", opc[i]);
|
sprint(qopc, "'%s'", opc[i]);
|
||||||
return qopc;
|
return qopc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "expr.h"
|
#include "expr.h"
|
||||||
#include "code.h"
|
#include "code.h"
|
||||||
#include "sizes.h"
|
#include "sizes.h"
|
||||||
|
#include <system.h>
|
||||||
|
#include <em.h>
|
||||||
|
|
||||||
#define MAXERRORS 10 /* Maximum number of insert/delete errors */
|
#define MAXERRORS 10 /* Maximum number of insert/delete errors */
|
||||||
|
|
||||||
|
@ -158,7 +160,7 @@ replicator(register struct symbol **s; register struct expr **e1, **e2; )
|
||||||
sym_down();
|
sym_down();
|
||||||
var_memory(&info, T_VAR, 1);
|
var_memory(&info, T_VAR, 1);
|
||||||
*s=insert(index,
|
*s=insert(index,
|
||||||
T_VAR|T_REP|T_USED|T_ASSIGNED, 1, info);
|
T_VAR|T_REP|T_USED|T_ASSIGNED, 1, &info);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -306,7 +308,7 @@ chan { register type, arr_siz=1; register char *name; struct expr *e; }:
|
||||||
]?
|
]?
|
||||||
{ chan_memory(&info, arr_siz);
|
{ chan_memory(&info, arr_siz);
|
||||||
chan_init(&info, arr_siz);
|
chan_init(&info, arr_siz);
|
||||||
insert(name, type, arr_siz, info);
|
insert(name, type, arr_siz, &info);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -332,7 +334,7 @@ var { register type, byte=0, arr_siz=1;
|
||||||
}
|
}
|
||||||
]?
|
]?
|
||||||
{ var_memory(&info, type, arr_siz);
|
{ var_memory(&info, type, arr_siz);
|
||||||
insert(name, type, arr_siz, info);
|
insert(name, type, arr_siz, &info);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -342,7 +344,7 @@ const_def { register char *name; struct expr *e; }:
|
||||||
{ if (!constant(e) && !arr_constant(e))
|
{ if (!constant(e) && !arr_constant(e))
|
||||||
nonconst("expression in constant definition");
|
nonconst("expression in constant definition");
|
||||||
info.const=e;
|
info.const=e;
|
||||||
insert(name, T_CONST|T_USED, 0, info);
|
insert(name, T_CONST|T_USED, 0, &info);
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -366,7 +368,7 @@ form_parm(register struct par_list ***aapars; register *g_type;)
|
||||||
{ type|=T_ARR; }
|
{ type|=T_ARR; }
|
||||||
]?
|
]?
|
||||||
{ pars_add(aapars, type&(T_TYPE|T_ARR),
|
{ pars_add(aapars, type&(T_TYPE|T_ARR),
|
||||||
insert(name, type|T_PARAM, 0, none));
|
insert(name, type|T_PARAM, 0, &none));
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -394,7 +396,7 @@ proc_declaration { struct par_list *pars=nil;
|
||||||
}:
|
}:
|
||||||
PROC IDENTIFIER { branch(&OVER);
|
PROC IDENTIFIER { branch(&OVER);
|
||||||
proc=insert(token.t_sval,
|
proc=insert(token.t_sval,
|
||||||
T_PROC|T_RECURS, 0, none);
|
T_PROC|T_RECURS, 0, &none);
|
||||||
old_min_offset=min_offset;
|
old_min_offset=min_offset;
|
||||||
sym_down();
|
sym_down();
|
||||||
prologue(proc);
|
prologue(proc);
|
||||||
|
@ -614,12 +616,14 @@ val_expr(register struct expr **e;) :
|
||||||
%lexical scanner;
|
%lexical scanner;
|
||||||
{
|
{
|
||||||
int err=0;
|
int err=0;
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
main(argc, argv) register argc; register char **argv;
|
main(argc, argv) register argc; register char **argv;
|
||||||
{
|
{
|
||||||
wz= (argc>1 && strcmp(argv[1], "4")==0) ? 4 : 2;
|
while (argc > 1 && argv[1][0] == '-') {
|
||||||
pz= (argc>2 && strcmp(argv[2], "4")==0) ? 4 : wz;
|
do_option(&argv[1][1]);
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
|
||||||
leader();
|
leader();
|
||||||
occam();
|
occam();
|
||||||
|
@ -628,6 +632,64 @@ main(argc, argv) register argc; register char **argv;
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_option(text)
|
||||||
|
char *text;
|
||||||
|
{
|
||||||
|
extern int Lflag;
|
||||||
|
|
||||||
|
switch(*text++) {
|
||||||
|
|
||||||
|
default:
|
||||||
|
fatal("illegal option: %c", *--text);
|
||||||
|
|
||||||
|
case 'L' : /* no fil/lin */
|
||||||
|
Lflag++;
|
||||||
|
break;
|
||||||
|
case 'V' : /* set object sizes and alignment requirements */
|
||||||
|
{
|
||||||
|
arith size, align;
|
||||||
|
char c;
|
||||||
|
|
||||||
|
while (c = *text++) {
|
||||||
|
size = txt2int(&text);
|
||||||
|
switch (c) {
|
||||||
|
case 'w': /* word */
|
||||||
|
if (size != (arith)0)
|
||||||
|
wz = size;
|
||||||
|
break;
|
||||||
|
case 'p': /* pointer */
|
||||||
|
if (size != (arith)0)
|
||||||
|
pz = size;
|
||||||
|
break;
|
||||||
|
case 'l': /* long */
|
||||||
|
if (size != (arith)0)
|
||||||
|
vz = size;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fatal("-V: bad type indicator %c\n", c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
txt2int(tp)
|
||||||
|
char **tp;
|
||||||
|
{
|
||||||
|
/* the integer pointed to by *tp is read, while increasing
|
||||||
|
*tp; the resulting value is yielded.
|
||||||
|
*/
|
||||||
|
register int val = 0, ch;
|
||||||
|
|
||||||
|
while (ch = **tp, ch >= '0' && ch <= '9') {
|
||||||
|
val = val * 10 + ch - '0';
|
||||||
|
(*tp)++;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
LLmessage(tk) register tk;
|
LLmessage(tk) register tk;
|
||||||
{
|
{
|
||||||
static errors=0;
|
static errors=0;
|
||||||
|
@ -639,11 +701,10 @@ LLmessage(tk) register tk;
|
||||||
if (tk==0)
|
if (tk==0)
|
||||||
warning("syntax error: bad token %s (deleted)", tokenname(LLsymb, 0));
|
warning("syntax error: bad token %s (deleted)", tokenname(LLsymb, 0));
|
||||||
else { /* tk<0 */
|
else { /* tk<0 */
|
||||||
fprintf(stderr, "Compiler stack overflow. Compiler ends.");
|
warning("syntax error: garbage at end of program");
|
||||||
err=1; trailer(); exit(1);
|
|
||||||
}
|
}
|
||||||
if (++errors==MAXERRORS) {
|
if (++errors==MAXERRORS) {
|
||||||
fprintf(stderr, "Too many insert/delete errors. Compiler ends.\n");
|
fprint(STDERR, "Too many insert/delete errors. Compiler ends.\n");
|
||||||
err=1; trailer(); exit(1);
|
err=1; trailer(); exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
#include <stdio.h>
|
#include <system.h>
|
||||||
|
|
||||||
extern int err, yylineno;
|
extern int err, yylineno;
|
||||||
extern char *curr_file;
|
extern char *curr_file;
|
||||||
|
|
||||||
report(fmt, arg1, arg2, arg3) char *fmt;
|
report(fmt, arg1, arg2, arg3) char *fmt;
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s (%d) F: ", curr_file, yylineno);
|
fprint(STDERR, "%s (%d) F: ", curr_file, yylineno);
|
||||||
fprintf(stderr, fmt, arg1, arg2, arg3);
|
fprint(STDERR, fmt, arg1, arg2, arg3);
|
||||||
putc('\n', stderr);
|
fprint(STDERR,"\n");
|
||||||
err=1;
|
err=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
warning(fmt, arg1, arg2, arg3) char *fmt, *arg1;
|
warning(fmt, arg1, arg2, arg3) char *fmt, *arg1;
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s (%d) E: ", curr_file, yylineno);
|
fprint(STDERR, "%s (%d) E: ", curr_file, yylineno);
|
||||||
fprintf(stderr, fmt, arg1, arg2, arg3);
|
fprint(STDERR, fmt, arg1, arg2, arg3);
|
||||||
putc('\n', stderr);
|
fprint(STDERR,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fatal(fmt, arg1, arg2, arg3) char *fmt, *arg1;
|
||||||
|
{
|
||||||
|
fprint(STDERR, "%s (%d) X: ", curr_file, yylineno);
|
||||||
|
fprint(STDERR, fmt, arg1, arg2, arg3);
|
||||||
|
fprint(STDERR,"\n");
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
/* Variable size, wordsize, pointer size. Offsets for local variables. */
|
/* Variable size, wordsize, pointer size. Offsets for local variables. */
|
||||||
|
|
||||||
#define vz 4
|
extern int wz, pz, vz;
|
||||||
extern int wz, pz;
|
|
||||||
extern int curr_level, curr_offset, min_offset;
|
extern int curr_level, curr_offset, min_offset;
|
||||||
|
|
|
@ -27,7 +27,7 @@ static struct symbol **search_sym(tree, name)
|
||||||
struct symbol *insert(name, type, arr_siz, info)
|
struct symbol *insert(name, type, arr_siz, info)
|
||||||
char *name;
|
char *name;
|
||||||
int type, arr_siz;
|
int type, arr_siz;
|
||||||
union type_info info;
|
union type_info *info;
|
||||||
/* Inserts an object with given name and other info into the current symbol
|
/* Inserts an object with given name and other info into the current symbol
|
||||||
* tree. A pointer is returned to the inserted symbol so that more info may
|
* tree. A pointer is returned to the inserted symbol so that more info may
|
||||||
* or changed. Nil is returned on redeclaration.
|
* or changed. Nil is returned on redeclaration.
|
||||||
|
@ -49,7 +49,7 @@ struct symbol *insert(name, type, arr_siz, info)
|
||||||
type|=T_USED; /* are always used */
|
type|=T_USED; /* are always used */
|
||||||
ps->type=type;
|
ps->type=type;
|
||||||
ps->arr_siz=arr_siz;
|
ps->arr_siz=arr_siz;
|
||||||
ps->info=info;
|
ps->info= *info;
|
||||||
ps->left=ps->right=nil;
|
ps->left=ps->right=nil;
|
||||||
*aps=ps;
|
*aps=ps;
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ struct symbol *searchall(name) char *name;
|
||||||
tab=tab->global;
|
tab=tab->global;
|
||||||
}
|
}
|
||||||
report("%s not declared", name);
|
report("%s not declared", name);
|
||||||
return insert(name, T_NOTDECL, 0, none);
|
return insert(name, T_NOTDECL, 0, &none);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_recursion(proc)
|
void check_recursion(proc)
|
||||||
|
|
Loading…
Reference in a new issue