1987-03-10 17:51:10 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1986-03-10 13:07:55 +00:00
|
|
|
/* $Header$ */
|
|
|
|
/* PREPROCESSOR: INITIALIZATION ROUTINES */
|
|
|
|
|
|
|
|
#include "nopp.h"
|
|
|
|
|
|
|
|
#ifndef NOPP
|
1986-03-25 10:39:23 +00:00
|
|
|
#include <system.h>
|
1987-01-24 00:25:56 +00:00
|
|
|
#include <alloc.h>
|
1986-03-10 13:07:55 +00:00
|
|
|
#include "class.h"
|
|
|
|
#include "macro.h"
|
|
|
|
#include "idf.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
PRIVATE struct mkey {
|
|
|
|
char *mk_reserved;
|
|
|
|
int mk_key;
|
|
|
|
} mkey[] = {
|
|
|
|
{"define", K_DEFINE},
|
|
|
|
{"elif", K_ELIF},
|
|
|
|
{"else", K_ELSE},
|
|
|
|
{"endif", K_ENDIF},
|
|
|
|
{"if", K_IF},
|
|
|
|
{"ifdef", K_IFDEF},
|
|
|
|
{"ifndef", K_IFNDEF},
|
|
|
|
{"include", K_INCLUDE},
|
|
|
|
{"line", K_LINE},
|
|
|
|
{"undef", K_UNDEF},
|
|
|
|
{0, K_UNKNOWN}
|
|
|
|
};
|
|
|
|
|
1986-03-26 16:58:43 +00:00
|
|
|
char *strcpy();
|
|
|
|
|
1986-03-10 13:07:55 +00:00
|
|
|
EXPORT
|
|
|
|
init_pp()
|
|
|
|
{
|
1986-08-22 09:20:13 +00:00
|
|
|
long clock, sys_time();
|
1986-03-10 13:07:55 +00:00
|
|
|
static char date[30];
|
|
|
|
char *ctime();
|
|
|
|
|
|
|
|
/* Initialise the control line keywords (if, include, define, etc)
|
|
|
|
Although the lexical analyzer treats them as identifiers, the
|
|
|
|
control line handler can recognize them as keywords by the
|
|
|
|
id_resmac field of the identifier.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
register struct mkey *mk = &mkey[0];
|
|
|
|
|
|
|
|
while (mk->mk_reserved) {
|
1987-02-09 23:19:42 +00:00
|
|
|
register struct idf *idf = str2idf(mk->mk_reserved);
|
1986-03-10 13:07:55 +00:00
|
|
|
|
|
|
|
if (idf->id_resmac)
|
|
|
|
fatal("maximum identifier length insufficient");
|
|
|
|
idf->id_resmac = mk->mk_key;
|
|
|
|
mk++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize __DATE__, __FILE__ and __LINE__ macro
|
1986-12-04 16:29:44 +00:00
|
|
|
definitions.
|
1986-03-10 13:07:55 +00:00
|
|
|
*/
|
|
|
|
/* __DATE__ */
|
1986-03-25 10:39:23 +00:00
|
|
|
clock = sys_time();
|
1986-03-10 13:07:55 +00:00
|
|
|
strcpy(&date[1], ctime(&clock));
|
|
|
|
date[26] = '\0'; /* zap nl */
|
|
|
|
date[0] = date[25] = '"';
|
|
|
|
macro_def(str2idf("__DATE__"), date, -1, 26, NOFLAG);
|
|
|
|
|
|
|
|
/* __LINE__ */
|
|
|
|
macro_def(str2idf("__LINE__"), "0", -1, 1, FUNC);
|
|
|
|
|
|
|
|
/* __FILE__ */
|
|
|
|
macro_def(str2idf("__FILE__"), "", -1, 1, FUNC);
|
|
|
|
|
1986-12-01 10:00:23 +00:00
|
|
|
/* defined(??) */
|
|
|
|
macro_def(str2idf("defined"), "", 1, 1, FUNC);
|
1986-03-10 13:07:55 +00:00
|
|
|
}
|
|
|
|
#endif NOPP
|