1989-02-07 11:04:05 +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".
|
|
|
|
*/
|
1994-06-27 08:03:14 +00:00
|
|
|
/* $Id$ */
|
1989-02-07 11:04:05 +00:00
|
|
|
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
|
|
|
|
|
2018-09-02 09:36:15 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2019-02-18 16:42:15 +00:00
|
|
|
#include "domacro.h"
|
2018-09-02 09:36:15 +00:00
|
|
|
#include "parameters.h"
|
|
|
|
#include "idf.h"
|
2019-02-18 16:42:15 +00:00
|
|
|
#include "interface.h"
|
2018-09-02 09:36:15 +00:00
|
|
|
#include "arith.h"
|
|
|
|
#include "LLlex.h"
|
|
|
|
#include "Lpars.h"
|
|
|
|
#include "input.h"
|
2019-02-18 16:42:15 +00:00
|
|
|
#include "pragma.h"
|
|
|
|
#include "skip.h"
|
|
|
|
#include "error.h"
|
1989-02-07 11:04:05 +00:00
|
|
|
|
1990-10-19 11:50:32 +00:00
|
|
|
#ifdef DBSYMTAB
|
2018-09-02 09:36:15 +00:00
|
|
|
#include <stb.h>
|
|
|
|
#include <em.h>
|
|
|
|
int IncludeLevel = 0;
|
1990-10-19 11:50:32 +00:00
|
|
|
#endif
|
1989-02-07 11:04:05 +00:00
|
|
|
|
1989-10-27 13:33:10 +00:00
|
|
|
extern char options[];
|
2018-09-02 10:39:00 +00:00
|
|
|
|
2019-02-18 16:42:15 +00:00
|
|
|
static void do_line(unsigned int);
|
|
|
|
|
|
|
|
struct idf* GetIdentifier(int skiponerr) /* skip the rest of the line on error */
|
1989-10-16 12:38:25 +00:00
|
|
|
{
|
|
|
|
/* returns a pointer to the descriptor of the identifier that is
|
2018-09-02 09:36:15 +00:00
|
|
|
read from the input stream. When the input does not contain
|
|
|
|
an identifier, the rest of the line is skipped when
|
|
|
|
skiponerr is on, and a null-pointer is returned.
|
|
|
|
The substitution of macros is disabled.
|
1989-10-16 12:38:25 +00:00
|
|
|
*/
|
|
|
|
int tok;
|
|
|
|
struct token tk;
|
|
|
|
|
|
|
|
tok = GetToken(&tk);
|
2018-09-02 09:36:15 +00:00
|
|
|
if (tok != IDENTIFIER)
|
|
|
|
{
|
|
|
|
if (skiponerr && tok != EOI)
|
|
|
|
SkipToNewLine();
|
|
|
|
return (struct idf*)0;
|
1989-10-16 12:38:25 +00:00
|
|
|
}
|
|
|
|
return tk.tk_idf;
|
|
|
|
}
|
|
|
|
|
2019-02-18 16:42:15 +00:00
|
|
|
void domacro(void)
|
1989-02-07 11:04:05 +00:00
|
|
|
{
|
|
|
|
int tok;
|
|
|
|
struct token tk;
|
|
|
|
|
|
|
|
EoiForNewline = 1;
|
2018-09-02 09:36:15 +00:00
|
|
|
if ((tok = GetToken(&tk)) == IDENTIFIER)
|
|
|
|
{
|
|
|
|
if (!strcmp(tk.tk_idf->id_text, "pragma"))
|
|
|
|
{
|
1989-09-29 16:20:38 +00:00
|
|
|
do_pragma();
|
|
|
|
EoiForNewline = 0;
|
|
|
|
return;
|
|
|
|
}
|
2018-09-02 09:36:15 +00:00
|
|
|
}
|
|
|
|
else if (tok == INTEGER)
|
|
|
|
{
|
|
|
|
do_line((unsigned int)tk.tk_ival);
|
1989-10-24 15:02:02 +00:00
|
|
|
EoiForNewline = 0;
|
|
|
|
return;
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
1991-03-01 13:51:37 +00:00
|
|
|
lexerror("illegal # line");
|
1989-02-07 11:04:05 +00:00
|
|
|
EoiForNewline = 0;
|
1989-10-19 14:53:25 +00:00
|
|
|
SkipToNewLine();
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|
|
|
|
|
2019-02-18 16:42:15 +00:00
|
|
|
static void do_line(unsigned int l)
|
1989-02-07 11:04:05 +00:00
|
|
|
{
|
|
|
|
struct token tk;
|
1989-11-22 13:58:36 +00:00
|
|
|
int t = GetToken(&tk);
|
1989-02-07 11:04:05 +00:00
|
|
|
|
2018-09-02 09:36:15 +00:00
|
|
|
if (t != EOI)
|
|
|
|
SkipToNewLine();
|
|
|
|
LineNumber = l; /* the number of the next input line */
|
|
|
|
if (t == STRING)
|
|
|
|
{ /* is there a filespecifier? */
|
|
|
|
/*
|
|
|
|
* Do not attempt to free the old string, since it might
|
|
|
|
* be used in a def structure.
|
|
|
|
*/
|
1992-07-02 10:23:46 +00:00
|
|
|
#ifdef DBSYMTAB
|
2018-09-02 09:36:15 +00:00
|
|
|
if (options['g'] && strcmp(FileName, tk.tk_bts) != 0)
|
|
|
|
{
|
1992-07-02 10:23:46 +00:00
|
|
|
C_ms_std(tk.tk_bts, N_SOL, 0);
|
|
|
|
}
|
|
|
|
#endif /* DBSYMTAB */
|
1989-11-22 13:58:36 +00:00
|
|
|
FileName = tk.tk_bts;
|
1990-01-16 15:21:15 +00:00
|
|
|
}
|
1989-02-07 11:04:05 +00:00
|
|
|
}
|