SCCS-vsn: usr.bin/pascal/pc3/pc3.h 1.5
SCCS-vsn: usr.bin/pascal/pc3/pc3.c 1.9
SCCS-vsn: usr.bin/pascal/src/pstab.h 1.3
/* Copyright (c) 1980 Regents of the University of California */
/* Copyright (c) 1980 Regents of the University of California */
-static char sccsid[] = "@(#)pc3.c 1.8 %G%";
+static char sccsid[] = "@(#)pc3.c 1.9 %G%";
/*
* Pc3 is a pass in the Berkeley Pascal compilation
/*
* Pc3 is a pass in the Berkeley Pascal compilation
static struct symbol *pfilep = NIL;
static struct symbol *ifilep = NIL;
register struct symbol *symbolp;
static struct symbol *pfilep = NIL;
static struct symbol *ifilep = NIL;
register struct symbol *symbolp;
# ifdef DEBUG
if ( pfilep && ifilep ) {
# ifdef DEBUG
if ( pfilep && ifilep ) {
case N_PGVAR:
case N_PGFUNC:
case N_PGPROC:
case N_PGVAR:
case N_PGFUNC:
case N_PGPROC:
+ case N_PLDATA:
+ case N_PLTEXT:
symbolp -> sym_un.sym_str.rfilep = ifilep;
symbolp -> sym_un.sym_str.rline = nlp -> n_value;
symbolp -> sym_un.sym_str.fromp = pfilep;
symbolp -> sym_un.sym_str.rfilep = ifilep;
symbolp -> sym_un.sym_str.rline = nlp -> n_value;
symbolp -> sym_un.sym_str.fromp = pfilep;
fprintf( stderr , "[checksymbol] ->name %s is OLD\n"
, symbolp -> name );
# endif DEBUG
fprintf( stderr , "[checksymbol] ->name %s is OLD\n"
, symbolp -> name );
# endif DEBUG
switch ( symbolp -> desc ) {
default:
error( FATAL , "panic [checksymbol] OLD" );
switch ( symbolp -> desc ) {
default:
error( FATAL , "panic [checksymbol] OLD" );
*/
if ( symbolp -> sym_un.sym_str.rfilep == NIL ) {
error( ERROR ,
*/
if ( symbolp -> sym_un.sym_str.rfilep == NIL ) {
error( ERROR ,
- "%s, line %d: %s already defined (%s, line %d)." ,
+ "%s, line %d: %s is already defined\n\t(%s, line %d)." ,
ifilep -> name , nlp -> n_value ,
nlp -> n_un.n_name ,
symbolp -> sym_un.sym_str.fromi -> name ,
ifilep -> name , nlp -> n_value ,
nlp -> n_un.n_name ,
symbolp -> sym_un.sym_str.fromi -> name ,
}
symbolp -> sym_un.sym_str.fromp = pfilep;
return;
}
symbolp -> sym_un.sym_str.fromp = pfilep;
return;
+ case N_PLDATA:
+ case N_PLTEXT:
+ switch ( nlp -> n_desc ) {
+ default:
+ error( FATAL , "pc3: unknown stab 0x%x"
+ , nlp -> n_desc );
+ return;
+ case N_PSO:
+ case N_PSOL:
+ case N_PGCONST:
+ case N_PGTYPE:
+ /* these won't conflict with library */
+ return;
+ case N_PGLABEL:
+ case N_PGVAR:
+ case N_PGFUNC:
+ case N_PGPROC:
+ case N_PEFUNC:
+ case N_PEPROC:
+ case N_PLDATA:
+ case N_PLTEXT:
+ errtype = WARNING;
+ break;
+ }
+ break;
}
/*
* this is the breaks
*/
}
/*
* this is the breaks
*/
- error( ERROR , "%s, line %d: %s already defined (%s, line %d)."
- , ifilep -> name , nlp -> n_value , nlp -> n_un.n_name
- , symbolp -> sym_un.sym_str.rfilep -> name
- , symbolp -> sym_un.sym_str.rline );
+ error( errtype
+ , "%s, line %d: %s %s is already defined\n\t%s%s (%s, line %d)."
+ , ifilep -> name
+ , nlp -> n_value
+ , classify( nlp -> n_desc )
+ , nlp -> n_un.n_name
+ , ( symbolp -> desc == nlp -> n_desc ? "" : " as " )
+ , ( symbolp -> desc == nlp -> n_desc
+ ? "" : article( symbolp -> desc ) )
+ , symbolp -> sym_un.sym_str.rfilep -> name
+ , symbolp -> sym_un.sym_str.rline );
/*
* variable number of arguments to error, like printf.
*/
/*
* variable number of arguments to error, like printf.
*/
-error( type , message , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 )
+error( type , message , arg1 , arg2 , arg3 , arg4 , arg5 , arg6 , arg7 , arg8 )
int type;
char *message;
{
int type;
char *message;
{
fprintf( stderr , "Ooops: " );
break;
}
fprintf( stderr , "Ooops: " );
break;
}
- fprintf( stderr , message , arg1,arg2,arg3,arg4,arg5,arg6 );
+ fprintf( stderr , message , arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8 );
fprintf( stderr , "\n" );
if ( type == FATAL ) {
exit( FATAL );
fprintf( stderr , "\n" );
if ( type == FATAL ) {
exit( FATAL );
return "external function";
case N_PEPROC:
return "external procedure";
return "external function";
case N_PEPROC:
return "external procedure";
+ case N_PLDATA:
+ return "library variable";
+ case N_PLTEXT:
+ return "library routine";
default:
return "unknown symbol";
}
}
default:
return "unknown symbol";
}
}
+
+char *
+article( type )
+ unsigned char type;
+ {
+ switch ( type ) {
+ case N_PSO:
+ return "a source file";
+ case N_PSOL:
+ return "an include file";
+ case N_PGLABEL:
+ return "a label";
+ case N_PGCONST:
+ return "a constant";
+ case N_PGTYPE:
+ return "a type";
+ case N_PGVAR:
+ return "a variable";
+ case N_PGFUNC:
+ return "a function";
+ case N_PGPROC:
+ return "a procedure";
+ case N_PEFUNC:
+ return "an external function";
+ case N_PEPROC:
+ return "an external procedure";
+ case N_PLDATA:
+ return "a library variable";
+ case N_PLTEXT:
+ return "a library routine";
+ default:
+ return "an unknown symbol";
+ }
+ }
/* Copyright (c) 1980 Regents of the University of California */
/* Copyright (c) 1980 Regents of the University of California */
- /* static char sccsid[] = "@(#)pc3.h 1.4 %G%"; */
+ /* static char sccsid[] = "@(#)pc3.h 1.5 %G%"; */
/*
* a symbol table entry.
/*
* a symbol table entry.
BOOL nextelement();
time_t mtime();
char *classify();
BOOL nextelement();
time_t mtime();
char *classify();
- /* static char sccsid[] = "@(#)pstab.h 1.2 %G%"; */
+ /* static char sccsid[] = "@(#)pstab.h 1.3 %G%"; */
/*
* subtypes within the above type
/*
* subtypes within the above type
#define N_PGPROC 0x8 /* global procedure */
#define N_PEFUNC 0x9 /* external function */
#define N_PEPROC 0xa /* external procedure */
#define N_PGPROC 0x8 /* global procedure */
#define N_PEFUNC 0x9 /* external function */
#define N_PEPROC 0xa /* external procedure */
+#define N_PLDATA 0xb /* library variable */
+#define N_PLTEXT 0xc /* library routine */