Remove the K&R cpp, which is obsolete and unused.
This commit is contained in:
		
							parent
							
								
									e9687e90b5
								
							
						
					
					
						commit
						bf8dda7aa3
					
				
					 34 changed files with 0 additions and 3770 deletions
				
			
		
							
								
								
									
										375
									
								
								util/cpp/LLlex.c
									
										
									
									
									
								
							
							
						
						
									
										375
									
								
								util/cpp/LLlex.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,375 +0,0 @@
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*		    L E X I C A L   A N A L Y Z E R			*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	<string.h>
 | 
					 | 
				
			||||||
#include	"idfsize.h"
 | 
					 | 
				
			||||||
#include	"numsize.h"
 | 
					 | 
				
			||||||
#include	"strsize.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	<alloc.h>
 | 
					 | 
				
			||||||
#include	"input.h"
 | 
					 | 
				
			||||||
#include	"idf.h"
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
#include	"class.h"
 | 
					 | 
				
			||||||
#include	"bits.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* Data about the token yielded */
 | 
					 | 
				
			||||||
struct token dot;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int ReplaceMacros = 1;		/* replacing macros			*/
 | 
					 | 
				
			||||||
int AccFileSpecifier = 0;	/* return filespecifier <...>		*/
 | 
					 | 
				
			||||||
int AccDefined = 0;		/* accept "defined(...)"		*/
 | 
					 | 
				
			||||||
int UnknownIdIsZero = 0;	/* interpret unknown id as integer 0	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *string_token();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PushLex()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	DOT = 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PopLex()
 | 
					 | 
				
			||||||
{}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
LLlex()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return (DOT != EOF) ? GetToken(&dot) : EOF;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define BUFSIZ 1024
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
GetToken(ptok)
 | 
					 | 
				
			||||||
	register struct token *ptok;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char buf[BUFSIZ];
 | 
					 | 
				
			||||||
	register int c, nch;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
again:	/* rescan the input after an error or replacement	*/
 | 
					 | 
				
			||||||
	LoadChar(c);
 | 
					 | 
				
			||||||
	if ((c & 0200) && c != EOI)
 | 
					 | 
				
			||||||
		fatal("non-ascii '\\%03o' read", c & 0377);
 | 
					 | 
				
			||||||
	switch (class(c)) {	/* detect character class	*/
 | 
					 | 
				
			||||||
	case STNL:
 | 
					 | 
				
			||||||
		LineNumber++;
 | 
					 | 
				
			||||||
		return ptok->tk_symb = EOF;
 | 
					 | 
				
			||||||
	case STSKIP:
 | 
					 | 
				
			||||||
		goto again;
 | 
					 | 
				
			||||||
	case STGARB:		/* garbage character			*/
 | 
					 | 
				
			||||||
		if (c == '\\') {
 | 
					 | 
				
			||||||
			/* a '\\' is allowed in #if/#elif expression	*/
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (class(c) == STNL) {	/* vt , ff ?	*/
 | 
					 | 
				
			||||||
				++LineNumber;
 | 
					 | 
				
			||||||
				goto again;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			c = '\\';
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (040 < c && c < 0177)
 | 
					 | 
				
			||||||
			error("garbage char %c", c);
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			error("garbage char \\%03o", c);
 | 
					 | 
				
			||||||
		goto again;
 | 
					 | 
				
			||||||
	case STSIMP:	/* a simple character, no part of compound token*/
 | 
					 | 
				
			||||||
		if (c == '/') { /* probably the start of comment	*/
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (c == '*') { /* start of comment	*/
 | 
					 | 
				
			||||||
				skipcomment();
 | 
					 | 
				
			||||||
				goto again;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				PushBack();
 | 
					 | 
				
			||||||
				c = '/';	/* restore c	*/
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		return ptok->tk_symb = c;
 | 
					 | 
				
			||||||
	case STCOMP:	/* maybe the start of a compound token		*/
 | 
					 | 
				
			||||||
		LoadChar(nch);			/* character lookahead	*/
 | 
					 | 
				
			||||||
		switch (c) {
 | 
					 | 
				
			||||||
		case '!':
 | 
					 | 
				
			||||||
			if (nch == '=')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = NOTEQUAL;
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			return ptok->tk_symb = c;
 | 
					 | 
				
			||||||
		case '&':
 | 
					 | 
				
			||||||
			if (nch == '&')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = AND;
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			return ptok->tk_symb = c;
 | 
					 | 
				
			||||||
		case '<':
 | 
					 | 
				
			||||||
			if (AccFileSpecifier) {
 | 
					 | 
				
			||||||
				PushBack();	/* pushback nch */
 | 
					 | 
				
			||||||
				ptok->tk_str =
 | 
					 | 
				
			||||||
					string_token("file specifier", '>');
 | 
					 | 
				
			||||||
				return ptok->tk_symb = FILESPECIFIER;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if (nch == '<')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = LEFT;
 | 
					 | 
				
			||||||
			if (nch == '=')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = LESSEQ;
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			return ptok->tk_symb = c;
 | 
					 | 
				
			||||||
		case '=':
 | 
					 | 
				
			||||||
			if (nch != '=') {
 | 
					 | 
				
			||||||
				PushBack();
 | 
					 | 
				
			||||||
				error("missing =");
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return ptok->tk_symb = EQUAL;
 | 
					 | 
				
			||||||
		case '>':
 | 
					 | 
				
			||||||
			if (nch == '=')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = GREATEREQ;
 | 
					 | 
				
			||||||
			if (nch == '>')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = RIGHT;
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			return ptok->tk_symb = c;
 | 
					 | 
				
			||||||
		case '|':
 | 
					 | 
				
			||||||
			if (nch == '|')
 | 
					 | 
				
			||||||
				return ptok->tk_symb = OR;
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			return ptok->tk_symb = c;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	case STIDF:
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		extern int idfsize;		/* ??? */
 | 
					 | 
				
			||||||
		register char *tg = &buf[0];
 | 
					 | 
				
			||||||
		register char *maxpos = &buf[idfsize];
 | 
					 | 
				
			||||||
		register struct idf *idef;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define tstmac(bx)	if (!(bits[c] & bx)) goto nomac
 | 
					 | 
				
			||||||
#define cpy		if (Unstacked) EnableMacros(); *tg++ = c
 | 
					 | 
				
			||||||
#define load		LoadChar(c); if (!in_idf(c)) goto endidf
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef DOBITS
 | 
					 | 
				
			||||||
		cpy; tstmac(bit0); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit1); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit2); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit3); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit4); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit5); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit6); load;
 | 
					 | 
				
			||||||
		cpy; tstmac(bit7); load;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		for(;;) {
 | 
					 | 
				
			||||||
			if (tg < maxpos) {
 | 
					 | 
				
			||||||
				cpy;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			load;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	endidf:
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		*tg = '\0';	/* mark the end of the identifier */
 | 
					 | 
				
			||||||
		if (ReplaceMacros) {
 | 
					 | 
				
			||||||
			idef = findidf(buf);
 | 
					 | 
				
			||||||
			if ((idef && idef->id_macro && replace(idef))) {
 | 
					 | 
				
			||||||
				goto again;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	nomac:
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
		while (in_idf(c)) {
 | 
					 | 
				
			||||||
			if (tg < maxpos) *tg++ = c;
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		*tg++ = '\0';	/* mark the end of the identifier	*/
 | 
					 | 
				
			||||||
		if (UnknownIdIsZero) {
 | 
					 | 
				
			||||||
			ptok->tk_val = 0;
 | 
					 | 
				
			||||||
			return ptok->tk_symb = INTEGER;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		ptok->tk_str = Malloc(tg - buf);
 | 
					 | 
				
			||||||
		strcpy(ptok->tk_str, buf);
 | 
					 | 
				
			||||||
		return ptok->tk_symb = IDENTIFIER;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	case STCHAR:				/* character constant	*/
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		register arith val = 0;
 | 
					 | 
				
			||||||
		register int size = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
		if (c == '\'')
 | 
					 | 
				
			||||||
			error("character constant too short");
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
		while (c != '\'') {
 | 
					 | 
				
			||||||
			if (c == '\n') {
 | 
					 | 
				
			||||||
				error("newline in character constant");
 | 
					 | 
				
			||||||
				PushBack();
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if (c == '\\') {
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				if (c == '\n') {
 | 
					 | 
				
			||||||
					LineNumber++;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				c = quoted(c);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if (c >= 128) c -= 256;
 | 
					 | 
				
			||||||
			val = val*256 + c;
 | 
					 | 
				
			||||||
			size++;
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (size > sizeof(arith))
 | 
					 | 
				
			||||||
			error("character constant too long");
 | 
					 | 
				
			||||||
		ptok->tk_val = val;
 | 
					 | 
				
			||||||
		return ptok->tk_symb = INTEGER;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	case STNUM:
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		register char *np = &buf[1];
 | 
					 | 
				
			||||||
		register int base = 10;
 | 
					 | 
				
			||||||
		register int vch;
 | 
					 | 
				
			||||||
		register arith val = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (c == '0') {
 | 
					 | 
				
			||||||
			*np++ = c;
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (c == 'x' || c == 'X') {
 | 
					 | 
				
			||||||
				base = 16;
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				base = 8;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		while (vch = val_in_base(c, base), vch >= 0) {
 | 
					 | 
				
			||||||
			val = val*base + vch;
 | 
					 | 
				
			||||||
			if (np < &buf[NUMSIZE])
 | 
					 | 
				
			||||||
				*np++ = c;
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (c == 'l' || c == 'L')
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		ptok->tk_val = val;
 | 
					 | 
				
			||||||
		return ptok->tk_symb = INTEGER;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	case STSTR:
 | 
					 | 
				
			||||||
		ptok->tk_str = string_token("string", '"');
 | 
					 | 
				
			||||||
		return ptok->tk_symb = STRING;
 | 
					 | 
				
			||||||
	case STEOI:			/* end of text on source file	*/
 | 
					 | 
				
			||||||
		return ptok->tk_symb = EOF;
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		crash("Impossible character class");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/*NOTREACHED*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
skipcomment()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	NoUnstack++;
 | 
					 | 
				
			||||||
	LoadChar(c);
 | 
					 | 
				
			||||||
	do {
 | 
					 | 
				
			||||||
		while (c != '*') {
 | 
					 | 
				
			||||||
			if (class(c) == STNL)
 | 
					 | 
				
			||||||
				++LineNumber;
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
			if (c == EOI) {
 | 
					 | 
				
			||||||
				NoUnstack--;
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		/* Last Character seen was '*' */
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
	} while (c != '/');
 | 
					 | 
				
			||||||
	NoUnstack--;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *
 | 
					 | 
				
			||||||
string_token(nm, stop_char)
 | 
					 | 
				
			||||||
	char *nm;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
	register unsigned int str_size;
 | 
					 | 
				
			||||||
	register char *str = Malloc(str_size = ISTRSIZE);
 | 
					 | 
				
			||||||
	register int pos = 0;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	LoadChar(c);
 | 
					 | 
				
			||||||
	while (c != stop_char) {
 | 
					 | 
				
			||||||
		if (c == '\n') {
 | 
					 | 
				
			||||||
			error("newline in %s", nm);
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (c == EOI) {
 | 
					 | 
				
			||||||
			error("end-of-file inside %s", nm);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (c == '\\') {
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (c == '\n') {
 | 
					 | 
				
			||||||
				LineNumber++;
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			c = quoted(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		str[pos++] = c;
 | 
					 | 
				
			||||||
		if (pos == str_size)
 | 
					 | 
				
			||||||
			str = Realloc(str, str_size <<= 1);
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	str[pos++] = '\0'; /* for filenames etc. */
 | 
					 | 
				
			||||||
	str = Realloc(str, pos);
 | 
					 | 
				
			||||||
	return str;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
quoted(c)
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
{	
 | 
					 | 
				
			||||||
	/*	quoted() replaces an escaped character sequence by the
 | 
					 | 
				
			||||||
		character meant.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	/* first char after backslash already in c */
 | 
					 | 
				
			||||||
	if (!is_oct(c)) {		/* a quoted char */
 | 
					 | 
				
			||||||
		switch (c) {
 | 
					 | 
				
			||||||
		case 'n':
 | 
					 | 
				
			||||||
			c = '\n';
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case 't':
 | 
					 | 
				
			||||||
			c = '\t';
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case 'b':
 | 
					 | 
				
			||||||
			c = '\b';
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case 'r':
 | 
					 | 
				
			||||||
			c = '\r';
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case 'f':
 | 
					 | 
				
			||||||
			c = '\f';
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {				/* a quoted octal */
 | 
					 | 
				
			||||||
		register int oct = 0, cnt = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		do {
 | 
					 | 
				
			||||||
			oct = oct*8 + (c-'0');
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		} while (is_oct(c) && ++cnt < 3);
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		c = oct;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return c&0377;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* provisional */
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
val_in_base(c, base)
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	return
 | 
					 | 
				
			||||||
		is_dig(c) ? c - '0' :
 | 
					 | 
				
			||||||
		base != 16 ? -1 :
 | 
					 | 
				
			||||||
		is_hex(c) ? (c - 'a' + 10) & 017 :
 | 
					 | 
				
			||||||
		-1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,44 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* D E F I N I T I O N S   F O R   T H E   L E X I C A L   A N A L Y Z E R */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	A token from the input stream is represented by an integer,
 | 
					 | 
				
			||||||
	called a "symbol", but it may have other information associated
 | 
					 | 
				
			||||||
	to it.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <em_arith.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* the structure of a token:	*/
 | 
					 | 
				
			||||||
struct token	{
 | 
					 | 
				
			||||||
	int tok_symb;		/* the token itself */
 | 
					 | 
				
			||||||
	union {
 | 
					 | 
				
			||||||
		arith tok_val;		/* numeric values */
 | 
					 | 
				
			||||||
		char *tok_str;		/* string/filespecifier */
 | 
					 | 
				
			||||||
	} tok_data;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "file_info.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define tk_symb	tok_symb
 | 
					 | 
				
			||||||
#define tk_val	tok_data.tok_val
 | 
					 | 
				
			||||||
#define tk_str	tok_data.tok_str
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern struct token dot;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int ReplaceMacros;	/* "LLlex.c"	*/
 | 
					 | 
				
			||||||
extern int AccFileSpecifier;	/* "LLlex.c"	*/
 | 
					 | 
				
			||||||
extern int AccDefined;		/* "LLlex.c"	*/
 | 
					 | 
				
			||||||
extern int UnknownIdIsZero;	/* "LLlex.c"	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int NoUnstack;		/* "input.c"	*/
 | 
					 | 
				
			||||||
extern int Unstacked;		/* "input.c"	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int err_occurred;	/* "error.c"	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	DOT	dot.tk_symb
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define EOF	(-1)
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,23 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/*		PARSER ERROR ADMINISTRATION		*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char *symbol2str();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
LLmessage(tk)	{
 | 
					 | 
				
			||||||
	if (tk < 0)
 | 
					 | 
				
			||||||
		error("garbage at end of line");
 | 
					 | 
				
			||||||
	else if (tk)	{
 | 
					 | 
				
			||||||
		error("%s missing", symbol2str(tk));
 | 
					 | 
				
			||||||
		skipline();
 | 
					 | 
				
			||||||
		DOT = EOF;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		error("%s deleted", symbol2str(DOT));
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,72 +0,0 @@
 | 
				
			||||||
!File: pathlength.h
 | 
					 | 
				
			||||||
#define PATHLENGTH	1024	/* max. length of path to file		*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: errout.h
 | 
					 | 
				
			||||||
#define	ERROUT		STDERR	/* file pointer for writing messages	*/
 | 
					 | 
				
			||||||
#define	MAXERR_LINE	5	/* maximum number of error messages given
 | 
					 | 
				
			||||||
					on the same input line.		*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: idfsize.h
 | 
					 | 
				
			||||||
#define	IDFSIZE	64	/* maximum significant length of an identifier	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: numsize.h
 | 
					 | 
				
			||||||
#define	NUMSIZE	256	/* maximum length of a numeric constant		*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: nparams.h
 | 
					 | 
				
			||||||
#define	NPARAMS 32	/* maximum number of parameters of macros	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: ifdepth.h
 | 
					 | 
				
			||||||
#define	IFDEPTH	256	/* maximum number of nested if-constructions	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: lapbuf.h
 | 
					 | 
				
			||||||
#define	LAPBUF	4096	/* size of macro actual parameter buffer	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: strsize.h
 | 
					 | 
				
			||||||
#define ISTRSIZE	16	/* minimum number of bytes allocated for
 | 
					 | 
				
			||||||
					storing a string		*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: botch_free.h
 | 
					 | 
				
			||||||
/*#define BOTCH_FREE	1	/* botch freed memory, as a check	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: debug.h
 | 
					 | 
				
			||||||
/*#define DEBUG		1	/* perform various self-tests		*/
 | 
					 | 
				
			||||||
#define NDEBUG		1	/* disable assertions			*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: parbufsize.h
 | 
					 | 
				
			||||||
#define PARBUFSIZE	1024
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: textsize.h
 | 
					 | 
				
			||||||
#define ITEXTSIZE	16	/* 1st piece of memory for repl. text	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: inputtype.h
 | 
					 | 
				
			||||||
/*#define INP_READ_IN_ONE	1	/* read input file in one.  */
 | 
					 | 
				
			||||||
				/* If defined, we cannot read from a pipe */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: obufsize.h
 | 
					 | 
				
			||||||
#define OBUFSIZE	8192	/* output buffer size */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: dobits.h
 | 
					 | 
				
			||||||
#define DOBITS		1	/* use trick to reduce symboltable accesses */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
!File: line_prefix.h
 | 
					 | 
				
			||||||
#define LINE_PREFIX	"#"	/* prefix for generated line directives,
 | 
					 | 
				
			||||||
				   either "#" or "#line"
 | 
					 | 
				
			||||||
				*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,18 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#include "dobits.h"
 | 
					 | 
				
			||||||
#ifdef DOBITS
 | 
					 | 
				
			||||||
#define bit0	0x01
 | 
					 | 
				
			||||||
#define bit1	0x02
 | 
					 | 
				
			||||||
#define bit2	0x04
 | 
					 | 
				
			||||||
#define bit3	0x08
 | 
					 | 
				
			||||||
#define bit4	0x10
 | 
					 | 
				
			||||||
#define bit5	0x20
 | 
					 | 
				
			||||||
#define bit6	0x40
 | 
					 | 
				
			||||||
#define bit7	0x80
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char bits[];
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,80 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* EVALUATION OF BINARY OPERATORS */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
#include	<em_arith.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ch7bin(pval, oper, val)
 | 
					 | 
				
			||||||
	register arith *pval, val;
 | 
					 | 
				
			||||||
	int oper;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	switch (oper)	{
 | 
					 | 
				
			||||||
	case '%':
 | 
					 | 
				
			||||||
		if (val == 0)
 | 
					 | 
				
			||||||
			error("%% by 0");
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			*pval = *pval % val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '/':
 | 
					 | 
				
			||||||
		if (val == 0)
 | 
					 | 
				
			||||||
			error("/ by 0");
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			*pval = *pval / val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '*':
 | 
					 | 
				
			||||||
		*pval = *pval * val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '+':
 | 
					 | 
				
			||||||
		*pval = *pval + val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '-':
 | 
					 | 
				
			||||||
		*pval = *pval - val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case LEFT:
 | 
					 | 
				
			||||||
		*pval = *pval << val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case RIGHT:
 | 
					 | 
				
			||||||
		*pval = *pval >> val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '<':
 | 
					 | 
				
			||||||
		*pval = (*pval < val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '>':
 | 
					 | 
				
			||||||
		*pval = (*pval > val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case LESSEQ:
 | 
					 | 
				
			||||||
		*pval = (*pval <= val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case GREATEREQ:
 | 
					 | 
				
			||||||
		*pval = (*pval >= val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case EQUAL:
 | 
					 | 
				
			||||||
		*pval = (*pval == val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case NOTEQUAL:
 | 
					 | 
				
			||||||
		*pval = (*pval != val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '&':
 | 
					 | 
				
			||||||
		*pval = *pval & val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '^':
 | 
					 | 
				
			||||||
		*pval = *pval ^ val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '|':
 | 
					 | 
				
			||||||
		*pval = *pval | val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case AND:
 | 
					 | 
				
			||||||
		*pval = (*pval && val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case OR:
 | 
					 | 
				
			||||||
		*pval = (*pval || val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case ',':
 | 
					 | 
				
			||||||
		*pval = val;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,25 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* EVALUATION OF MONADIC OPERATORS */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
#include	<em_arith.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
ch7mon(oper, pval)
 | 
					 | 
				
			||||||
	register arith *pval;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	switch (oper)	{
 | 
					 | 
				
			||||||
	case '~':
 | 
					 | 
				
			||||||
		*pval = ~(*pval);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '-':
 | 
					 | 
				
			||||||
		*pval = -(*pval);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case '!':
 | 
					 | 
				
			||||||
		*pval = !(*pval);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,36 +0,0 @@
 | 
				
			||||||
%
 | 
					 | 
				
			||||||
%	CHARACTER CLASSES
 | 
					 | 
				
			||||||
%
 | 
					 | 
				
			||||||
% some general settings:
 | 
					 | 
				
			||||||
%F	%s,
 | 
					 | 
				
			||||||
%S257
 | 
					 | 
				
			||||||
%
 | 
					 | 
				
			||||||
%	START OF TOKEN
 | 
					 | 
				
			||||||
%
 | 
					 | 
				
			||||||
%iSTGARB
 | 
					 | 
				
			||||||
STSKIP:\r \t\f\013
 | 
					 | 
				
			||||||
STNL:\n
 | 
					 | 
				
			||||||
STCOMP:!&<=>|
 | 
					 | 
				
			||||||
STSIMP:-%()+*,/:?^~
 | 
					 | 
				
			||||||
STCHAR:'
 | 
					 | 
				
			||||||
STIDF:a-zA-Z_
 | 
					 | 
				
			||||||
STNUM:0-9
 | 
					 | 
				
			||||||
STSTR:"
 | 
					 | 
				
			||||||
STEOI:\200
 | 
					 | 
				
			||||||
%T/* character classes */
 | 
					 | 
				
			||||||
%T#include "class.h"
 | 
					 | 
				
			||||||
%Tchar tkclass[] = {
 | 
					 | 
				
			||||||
%p
 | 
					 | 
				
			||||||
%T};
 | 
					 | 
				
			||||||
%
 | 
					 | 
				
			||||||
%	other kinds of classes
 | 
					 | 
				
			||||||
%
 | 
					 | 
				
			||||||
%C
 | 
					 | 
				
			||||||
_D_|_H_|_I_|_O_:0-7
 | 
					 | 
				
			||||||
_D_|_H_|_I_:89
 | 
					 | 
				
			||||||
_H_|_I_:a-fA-F
 | 
					 | 
				
			||||||
_I_:g-zG-Z_
 | 
					 | 
				
			||||||
%Tchar tk2class[] = {
 | 
					 | 
				
			||||||
%F	%s,
 | 
					 | 
				
			||||||
%p
 | 
					 | 
				
			||||||
%T};
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,44 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* U S E   O F   C H A R A C T E R   C L A S S E S */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	As a starter, chars are divided into classes, according to which
 | 
					 | 
				
			||||||
	token they can be the start of.
 | 
					 | 
				
			||||||
	At present such a class number is supposed to fit in 4 bits.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	class(ch)	(tkclass[(unsigned char) ch])
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	Being the start of a token is, fortunately, a mutual exclusive
 | 
					 | 
				
			||||||
	property, so, as there are less than 16 classes they can be
 | 
					 | 
				
			||||||
	packed in 4 bits.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	STSKIP	0	/* spaces and so on: skipped characters		*/
 | 
					 | 
				
			||||||
#define	STNL	1	/* newline character(s): update linenumber etc.	*/
 | 
					 | 
				
			||||||
#define	STGARB	2	/* garbage ascii character: not allowed		*/
 | 
					 | 
				
			||||||
#define	STSIMP	3	/* this character can occur as token		*/
 | 
					 | 
				
			||||||
#define	STCOMP	4	/* this one can start a compound token		*/
 | 
					 | 
				
			||||||
#define	STIDF	5	/* being the initial character of an identifier	*/
 | 
					 | 
				
			||||||
#define	STCHAR	6	/* the starter of a character constant		*/
 | 
					 | 
				
			||||||
#define	STSTR	7	/* the starter of a string			*/
 | 
					 | 
				
			||||||
#define	STNUM	8	/* the starter of a numeric constant		*/
 | 
					 | 
				
			||||||
#define	STEOI	9	/* End-Of-Information mark			*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	But occurring inside a token is not, so we need 1 bit for each
 | 
					 | 
				
			||||||
	class.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define _I_	01
 | 
					 | 
				
			||||||
#define _O_	02
 | 
					 | 
				
			||||||
#define _D_	04
 | 
					 | 
				
			||||||
#define _H_	010
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	in_idf(ch)	(tk2class[(unsigned char)ch] & _I_)
 | 
					 | 
				
			||||||
#define	is_oct(ch)	(tk2class[(unsigned char)ch] & _O_)
 | 
					 | 
				
			||||||
#define	is_dig(ch)	(tk2class[(unsigned char)ch] & _D_)
 | 
					 | 
				
			||||||
#define	is_hex(ch)	(tk2class[(unsigned char)ch] & _H_)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char tkclass[], tk2class[];
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,76 +0,0 @@
 | 
				
			||||||
.TH CPP 6 "$Revision$"
 | 
					 | 
				
			||||||
.ad
 | 
					 | 
				
			||||||
.SH NAME
 | 
					 | 
				
			||||||
cpp \- C Pre-Processor
 | 
					 | 
				
			||||||
.SH SYNOPSIS
 | 
					 | 
				
			||||||
.B ~em/lib.bin/cpp
 | 
					 | 
				
			||||||
[\-options] [ file ]
 | 
					 | 
				
			||||||
.SH DESCRIPTION
 | 
					 | 
				
			||||||
.I Cpp
 | 
					 | 
				
			||||||
reads a file, expands macros and include
 | 
					 | 
				
			||||||
files, and writes an input file for the C compiler.
 | 
					 | 
				
			||||||
All output is to standard output.
 | 
					 | 
				
			||||||
.br
 | 
					 | 
				
			||||||
The following options are supported.
 | 
					 | 
				
			||||||
.IP -\fBI\fIdirectory\fR
 | 
					 | 
				
			||||||
.br
 | 
					 | 
				
			||||||
add this directory to the list of
 | 
					 | 
				
			||||||
directories searched for #include "..." and #include <...>
 | 
					 | 
				
			||||||
commands.  Note that there is no space between the
 | 
					 | 
				
			||||||
"-I" and the directory string.  More than one -I command
 | 
					 | 
				
			||||||
is permitted.
 | 
					 | 
				
			||||||
.IP -\fBI\fR
 | 
					 | 
				
			||||||
end the list of directories to be searched, and also do not look in
 | 
					 | 
				
			||||||
default places.
 | 
					 | 
				
			||||||
.IP -\fBD\fIname\fR=\fItext\fR
 | 
					 | 
				
			||||||
.br
 | 
					 | 
				
			||||||
define 
 | 
					 | 
				
			||||||
.I name
 | 
					 | 
				
			||||||
as a macro with
 | 
					 | 
				
			||||||
.I text
 | 
					 | 
				
			||||||
as its replacement text.
 | 
					 | 
				
			||||||
.IP -\fBD\fIname\fR
 | 
					 | 
				
			||||||
the same as -\fBD\fIname\fR=1.
 | 
					 | 
				
			||||||
.IP -\fBU\fIname\fR
 | 
					 | 
				
			||||||
.br
 | 
					 | 
				
			||||||
undefine the macro name
 | 
					 | 
				
			||||||
.IR name .
 | 
					 | 
				
			||||||
.IP -\fBC\fR
 | 
					 | 
				
			||||||
leave comments in. By default, C-comments are deleted.
 | 
					 | 
				
			||||||
.IP -\fBP\fR
 | 
					 | 
				
			||||||
do not generate line directives
 | 
					 | 
				
			||||||
.IP -\fBM\fIn\fR
 | 
					 | 
				
			||||||
set maximum identifier length to
 | 
					 | 
				
			||||||
.IR n .
 | 
					 | 
				
			||||||
.IP -\fBd\fR[\fIfile\fR]
 | 
					 | 
				
			||||||
.br
 | 
					 | 
				
			||||||
if \fIfile\fR is not given, do not preprocess, but instead generate a list
 | 
					 | 
				
			||||||
of makefile dependencies and write them to the standard output.
 | 
					 | 
				
			||||||
If \fIfile\fP is given, generate preprocessor output on standard output,
 | 
					 | 
				
			||||||
and generate the list of makefile dependencies on file \fIfile\fP.
 | 
					 | 
				
			||||||
.IP -\fBA\fR[\fIfile\fR]
 | 
					 | 
				
			||||||
identical to the -d option.
 | 
					 | 
				
			||||||
.IP -\fBi\fR
 | 
					 | 
				
			||||||
when generating makefile dependencies, do not include files from
 | 
					 | 
				
			||||||
/usr/include.
 | 
					 | 
				
			||||||
.IP -\fBm\fR
 | 
					 | 
				
			||||||
when generating makefile dependencies, generate them in the following format:
 | 
					 | 
				
			||||||
.RS
 | 
					 | 
				
			||||||
.IP "file.o: file1.h"
 | 
					 | 
				
			||||||
.RE
 | 
					 | 
				
			||||||
.IP ""
 | 
					 | 
				
			||||||
where "file.o" is derived from the source file name. Normally, only a list
 | 
					 | 
				
			||||||
of files included is generated.
 | 
					 | 
				
			||||||
.IP -\fBundef\fR
 | 
					 | 
				
			||||||
.br
 | 
					 | 
				
			||||||
this flag is silently ignored, for compatibility with other preprocessors.
 | 
					 | 
				
			||||||
.PP
 | 
					 | 
				
			||||||
The following names are always available unless undefined:
 | 
					 | 
				
			||||||
.IP __FILE__
 | 
					 | 
				
			||||||
The input (or #include) file being compiled
 | 
					 | 
				
			||||||
(as a quoted string).
 | 
					 | 
				
			||||||
.IP __LINE__
 | 
					 | 
				
			||||||
The line number being compiled.
 | 
					 | 
				
			||||||
.IP __DATE__
 | 
					 | 
				
			||||||
The date and time of compilation as
 | 
					 | 
				
			||||||
a Unix ctime quoted string (the trailing newline is removed).
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,718 +0,0 @@
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/* PREPROCESSOR: CONTROLLINE INTERPRETER */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"interface.h"
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
#include	"debug.h"
 | 
					 | 
				
			||||||
#include	"idf.h"
 | 
					 | 
				
			||||||
#include	"input.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"ifdepth.h"	
 | 
					 | 
				
			||||||
#include	"botch_free.h"	
 | 
					 | 
				
			||||||
#include	"nparams.h"	
 | 
					 | 
				
			||||||
#include	"parbufsize.h"	
 | 
					 | 
				
			||||||
#include	"textsize.h"	
 | 
					 | 
				
			||||||
#include	"idfsize.h"	
 | 
					 | 
				
			||||||
#include	<assert.h>
 | 
					 | 
				
			||||||
#include	<alloc.h>
 | 
					 | 
				
			||||||
#include	"class.h"
 | 
					 | 
				
			||||||
#include	"macro.h"
 | 
					 | 
				
			||||||
#include	"bits.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
IMPORT char **inctable;		/* list of include directories		*/
 | 
					 | 
				
			||||||
IMPORT char *getwdir();
 | 
					 | 
				
			||||||
PRIVATE char ifstack[IFDEPTH];	/* if-stack: the content of an entry is	*/
 | 
					 | 
				
			||||||
				/* 1 if a corresponding ELSE has been	*/
 | 
					 | 
				
			||||||
				/* encountered.				*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int nestlevel = -1;
 | 
					 | 
				
			||||||
int svnestlevel[30] = {-1};
 | 
					 | 
				
			||||||
int nestcount;
 | 
					 | 
				
			||||||
extern int do_preprocess;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *
 | 
					 | 
				
			||||||
GetIdentifier()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	returns a pointer to the descriptor of the identifier that is
 | 
					 | 
				
			||||||
		read from the input stream. A null-pointer is returned if
 | 
					 | 
				
			||||||
		the input does not contain an identifier.
 | 
					 | 
				
			||||||
		The substitution of macros is disabled.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	int tok;
 | 
					 | 
				
			||||||
	struct token tk;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ReplaceMacros = 0;
 | 
					 | 
				
			||||||
	tok = GetToken(&tk);
 | 
					 | 
				
			||||||
	ReplaceMacros = 1;
 | 
					 | 
				
			||||||
	return tok == IDENTIFIER ? tk.tk_str : (char *)0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	domacro() is the control line interpreter. The '#' has already
 | 
					 | 
				
			||||||
	been read by the lexical analyzer by which domacro() is called.
 | 
					 | 
				
			||||||
	The token appearing directly after the '#' is obtained by calling
 | 
					 | 
				
			||||||
	the basic lexical analyzing function GetToken() and is interpreted
 | 
					 | 
				
			||||||
	to perform the action belonging to that token.
 | 
					 | 
				
			||||||
	An error message is produced when the token is not recognized,
 | 
					 | 
				
			||||||
	i.e. it is not one of "define" .. "undef" , integer or newline.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
EXPORT
 | 
					 | 
				
			||||||
domacro()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct token tk;	/* the token itself			*/
 | 
					 | 
				
			||||||
	register struct idf *id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	switch(GetToken(&tk)) {		/* select control line action	*/
 | 
					 | 
				
			||||||
	case IDENTIFIER:		/* is it a macro keyword?	*/
 | 
					 | 
				
			||||||
		id = findidf(tk.tk_str);
 | 
					 | 
				
			||||||
		if (!id) {
 | 
					 | 
				
			||||||
			error("%s: unknown control", tk.tk_str);
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			free(tk.tk_str);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		free(tk.tk_str);
 | 
					 | 
				
			||||||
		switch (id->id_resmac) {
 | 
					 | 
				
			||||||
		case K_DEFINE:				/* "define"	*/
 | 
					 | 
				
			||||||
			do_define();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_ELIF:				/* "elif"	*/
 | 
					 | 
				
			||||||
			do_elif();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_ELSE:				/* "else"	*/
 | 
					 | 
				
			||||||
			do_else();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_ENDIF:				/* "endif"	*/
 | 
					 | 
				
			||||||
			do_endif();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_IF:				/* "if"		*/
 | 
					 | 
				
			||||||
			do_if();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_IFDEF:				/* "ifdef"	*/
 | 
					 | 
				
			||||||
			do_ifdef(1);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_IFNDEF:				/* "ifndef"	*/
 | 
					 | 
				
			||||||
			do_ifdef(0);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_INCLUDE:				/* "include"	*/
 | 
					 | 
				
			||||||
			do_include();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_LINE:				/* "line"	*/
 | 
					 | 
				
			||||||
			/*	set LineNumber and FileName according to
 | 
					 | 
				
			||||||
				the arguments.
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
			if (GetToken(&tk) != INTEGER) {
 | 
					 | 
				
			||||||
				error("#line without linenumber");
 | 
					 | 
				
			||||||
				PushBack();
 | 
					 | 
				
			||||||
				skipline();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				do_line((unsigned int)tk.tk_val);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_UNDEF:				/* "undef"	*/
 | 
					 | 
				
			||||||
			do_undef();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_PRAGMA:				/* "pragma"	*/
 | 
					 | 
				
			||||||
			/*	ignore for now
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			/* invalid word seen after the '#'	*/
 | 
					 | 
				
			||||||
			error("%s: unknown control", id->id_text);
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case INTEGER:		/* # <integer> [<filespecifier>]?	*/
 | 
					 | 
				
			||||||
		do_line((unsigned int)tk.tk_val);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case EOF:	/* only `#' on this line: do nothing, ignore	*/
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	default:	/* invalid token following '#'		*/
 | 
					 | 
				
			||||||
		error("illegal # line");
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		skipline();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
skip_block(to_endif)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	skip_block() skips the input from
 | 
					 | 
				
			||||||
		1)	a false #if, #ifdef, #ifndef or #elif until the
 | 
					 | 
				
			||||||
			corresponding #elif (resulting in true), #else or
 | 
					 | 
				
			||||||
			#endif is read.
 | 
					 | 
				
			||||||
		2)	a #else corresponding to a true #if, #ifdef,
 | 
					 | 
				
			||||||
			#ifndef or #elif until the corresponding #endif is
 | 
					 | 
				
			||||||
			seen.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register int ch;
 | 
					 | 
				
			||||||
	register int skiplevel = nestlevel; /* current nesting level	*/
 | 
					 | 
				
			||||||
	struct token tk;
 | 
					 | 
				
			||||||
	struct idf *id;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	NoUnstack++;
 | 
					 | 
				
			||||||
	for (;;) {
 | 
					 | 
				
			||||||
		LoadChar(ch);	/* read first character after newline	*/
 | 
					 | 
				
			||||||
		if (ch != '#') {
 | 
					 | 
				
			||||||
			if (ch == EOI) {
 | 
					 | 
				
			||||||
				NoUnstack--;
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (GetToken(&tk) != IDENTIFIER) {
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		/*	an IDENTIFIER: look for #if, #ifdef and #ifndef
 | 
					 | 
				
			||||||
			without interpreting them.
 | 
					 | 
				
			||||||
			Interpret #else, #elif and #endif if they occur
 | 
					 | 
				
			||||||
			on the same level.
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		id = findidf(tk.tk_str);
 | 
					 | 
				
			||||||
		free(tk.tk_str);
 | 
					 | 
				
			||||||
		if (id) switch(id->id_resmac) {
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_IF:
 | 
					 | 
				
			||||||
		case K_IFDEF:
 | 
					 | 
				
			||||||
		case K_IFNDEF:
 | 
					 | 
				
			||||||
			push_if();
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		case K_ELIF:
 | 
					 | 
				
			||||||
			if (ifstack[nestlevel])
 | 
					 | 
				
			||||||
				warning("#elif after #else/#elif");
 | 
					 | 
				
			||||||
			if (! to_endif && nestlevel == skiplevel) {
 | 
					 | 
				
			||||||
				nestlevel--;
 | 
					 | 
				
			||||||
				push_if();
 | 
					 | 
				
			||||||
				if (ifexpr()) {	/* implicit skipline() */
 | 
					 | 
				
			||||||
					NoUnstack--;
 | 
					 | 
				
			||||||
					return;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else skipline();
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_ELSE:
 | 
					 | 
				
			||||||
			if (ifstack[nestlevel])
 | 
					 | 
				
			||||||
				warning("#else after #else/#elif");
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			if (! to_endif) {
 | 
					 | 
				
			||||||
				++(ifstack[nestlevel]);
 | 
					 | 
				
			||||||
				if (nestlevel == skiplevel) {
 | 
					 | 
				
			||||||
					NoUnstack--;
 | 
					 | 
				
			||||||
					return;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case K_ENDIF:
 | 
					 | 
				
			||||||
			assert(nestlevel >= 0);
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			if (nestlevel == skiplevel) {
 | 
					 | 
				
			||||||
				nestlevel--;
 | 
					 | 
				
			||||||
				NoUnstack--;
 | 
					 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			nestlevel--;
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
ifexpr()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	ifexpr() returns whether the restricted constant
 | 
					 | 
				
			||||||
		expression following #if or #elif evaluates to true.  This
 | 
					 | 
				
			||||||
		is done by calling the LLgen generated subparser for
 | 
					 | 
				
			||||||
		constant expressions.  The result of this expression will
 | 
					 | 
				
			||||||
		be given in the extern long variable "ifval".
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	IMPORT arith ifval;
 | 
					 | 
				
			||||||
	int errors = err_occurred;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	ifval = (arith)0;
 | 
					 | 
				
			||||||
	AccDefined = 1;
 | 
					 | 
				
			||||||
	UnknownIdIsZero = 1;
 | 
					 | 
				
			||||||
	PushLex();	/* NEW parser */
 | 
					 | 
				
			||||||
	If_expr();	/* invoke constant expression parser	*/
 | 
					 | 
				
			||||||
	PopLex();	/* OLD parser */
 | 
					 | 
				
			||||||
	AccDefined = 0;
 | 
					 | 
				
			||||||
	UnknownIdIsZero = 0;
 | 
					 | 
				
			||||||
	return (errors == err_occurred) && (ifval != (arith)0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_include()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	do_include() performs the inclusion of a file.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	char *filenm;
 | 
					 | 
				
			||||||
	char *result;
 | 
					 | 
				
			||||||
	int tok;
 | 
					 | 
				
			||||||
	struct token tk;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	AccFileSpecifier = 1;
 | 
					 | 
				
			||||||
	if (((tok = GetToken(&tk)) == FILESPECIFIER) || tok == STRING)
 | 
					 | 
				
			||||||
		filenm = tk.tk_str;
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		error("bad include syntax");
 | 
					 | 
				
			||||||
		filenm = (char *)0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	AccFileSpecifier = 0;
 | 
					 | 
				
			||||||
	PushBack();
 | 
					 | 
				
			||||||
	skipline();
 | 
					 | 
				
			||||||
	inctable[0] = WorkingDir;
 | 
					 | 
				
			||||||
	if (filenm) {
 | 
					 | 
				
			||||||
		if (!InsertFile(filenm, &inctable[tok==FILESPECIFIER],&result)){
 | 
					 | 
				
			||||||
			if (do_preprocess) error("cannot find include file \"%s\"", filenm);
 | 
					 | 
				
			||||||
			else warning("cannot find include file \"%s\"", filenm);
 | 
					 | 
				
			||||||
			add_dependency(filenm);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			add_dependency(result);
 | 
					 | 
				
			||||||
			WorkingDir = getwdir(result);
 | 
					 | 
				
			||||||
			svnestlevel[++nestcount] = nestlevel;
 | 
					 | 
				
			||||||
			FileName = result;
 | 
					 | 
				
			||||||
			LineNumber = 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_define()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	do_define() interprets a #define control line.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	char *str;
 | 
					 | 
				
			||||||
	int nformals = -1;	/* keep track of the number of formals	*/
 | 
					 | 
				
			||||||
	char *formals[NPARAMS];	/* pointers to the names of the formals	*/
 | 
					 | 
				
			||||||
	char parbuf[PARBUFSIZE];		/* names of formals	*/
 | 
					 | 
				
			||||||
	char *repl_text;	/* start of the replacement text	*/
 | 
					 | 
				
			||||||
	int length;		/* length of the replacement text	*/
 | 
					 | 
				
			||||||
	register ch;
 | 
					 | 
				
			||||||
	char *get_text();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* read the #defined macro's name	*/
 | 
					 | 
				
			||||||
	if (!(str = GetIdentifier())) {
 | 
					 | 
				
			||||||
		error("#define: illegal macro name");
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		skipline();
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/*	there is a formal parameter list if the identifier is
 | 
					 | 
				
			||||||
		followed immediately by a '('. 
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	LoadChar(ch);
 | 
					 | 
				
			||||||
	if (ch == '(') {
 | 
					 | 
				
			||||||
		if ((nformals = getparams(formals, parbuf)) == -1) {
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			skipline();
 | 
					 | 
				
			||||||
			free(str);
 | 
					 | 
				
			||||||
			return;	/* an error occurred	*/
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		LoadChar(ch);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/* read the replacement text if there is any			*/
 | 
					 | 
				
			||||||
	ch = skipspaces(ch,0);	/* find first character of the text	*/
 | 
					 | 
				
			||||||
	assert(ch != EOI);
 | 
					 | 
				
			||||||
	if (class(ch) == STNL) {
 | 
					 | 
				
			||||||
		/*	Treat `#define something' as `#define something ""'
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		repl_text = "";
 | 
					 | 
				
			||||||
		length = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		repl_text = get_text((nformals > 0) ? formals : 0, &length);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	macro_def(str2idf(str, 0), repl_text, nformals, length, NOFLAG);
 | 
					 | 
				
			||||||
	LineNumber++;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
push_if()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (nestlevel >= IFDEPTH)
 | 
					 | 
				
			||||||
		fatal("too many nested #if/#ifdef/#ifndef");
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		ifstack[++nestlevel] = 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_elif()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel])) {
 | 
					 | 
				
			||||||
		error("#elif without corresponding #if");
 | 
					 | 
				
			||||||
		skipline();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else { /* restart at this level as if a #if is detected.  */
 | 
					 | 
				
			||||||
		nestlevel--;
 | 
					 | 
				
			||||||
		push_if();
 | 
					 | 
				
			||||||
		skip_block(1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_else()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	skipline();
 | 
					 | 
				
			||||||
	if (nestlevel <= svnestlevel[nestcount] || (ifstack[nestlevel]))
 | 
					 | 
				
			||||||
		error("#else without corresponding #if");
 | 
					 | 
				
			||||||
	else {	/* mark this level as else-d		*/
 | 
					 | 
				
			||||||
		++(ifstack[nestlevel]);
 | 
					 | 
				
			||||||
		skip_block(1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_endif()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	skipline();
 | 
					 | 
				
			||||||
	if (nestlevel <= svnestlevel[nestcount])
 | 
					 | 
				
			||||||
		error("#endif without corresponding #if");
 | 
					 | 
				
			||||||
	else nestlevel--;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_if()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	push_if();
 | 
					 | 
				
			||||||
	if (!ifexpr())	/* a false #if/#elif expression */
 | 
					 | 
				
			||||||
		skip_block(0);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_ifdef(how)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register struct idf *id;
 | 
					 | 
				
			||||||
	char *str;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*	how == 1 : ifdef; how == 0 : ifndef
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	push_if();
 | 
					 | 
				
			||||||
	str = GetIdentifier();
 | 
					 | 
				
			||||||
	if (!str) {
 | 
					 | 
				
			||||||
		error("illegal #ifdef construction");
 | 
					 | 
				
			||||||
		id = 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else	{
 | 
					 | 
				
			||||||
		id = findidf(str);
 | 
					 | 
				
			||||||
		free(str);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* The next test is a shorthand for:
 | 
					 | 
				
			||||||
		(how && !id->id_macro) || (!how && id->id_macro)
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	if (how ^ (id && id->id_macro != 0))
 | 
					 | 
				
			||||||
		skip_block(0);
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
		skipline();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_undef()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register struct idf *id;
 | 
					 | 
				
			||||||
	register char *str = GetIdentifier();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* Forget a macro definition.	*/
 | 
					 | 
				
			||||||
	if (str) {
 | 
					 | 
				
			||||||
		if (id = findidf(str)) {
 | 
					 | 
				
			||||||
			if (id->id_macro) { /* forget the macro */
 | 
					 | 
				
			||||||
				free_macro(id->id_macro);
 | 
					 | 
				
			||||||
				id->id_macro = (struct macro *) 0;
 | 
					 | 
				
			||||||
			} /* else: don't complain */
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		free(str);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		error("illegal #undef construction");
 | 
					 | 
				
			||||||
	PushBack();
 | 
					 | 
				
			||||||
	skipline();
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
do_line(l)
 | 
					 | 
				
			||||||
	unsigned int l;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	struct token tk;
 | 
					 | 
				
			||||||
	int t = GetToken(&tk);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	PushBack();
 | 
					 | 
				
			||||||
	skipline();
 | 
					 | 
				
			||||||
	LineNumber = l;		/* the number of the next input line */
 | 
					 | 
				
			||||||
	if (t == STRING)	/* is there a filespecifier? */
 | 
					 | 
				
			||||||
		FileName = tk.tk_str;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE int
 | 
					 | 
				
			||||||
getparams(buf, parbuf)
 | 
					 | 
				
			||||||
	char *buf[];
 | 
					 | 
				
			||||||
	char parbuf[];
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	getparams() reads the formal parameter list of a macro
 | 
					 | 
				
			||||||
		definition.
 | 
					 | 
				
			||||||
		The number of parameters is returned.
 | 
					 | 
				
			||||||
		As a formal parameter list is expected when calling this
 | 
					 | 
				
			||||||
		routine, -1 is returned if an error is detected, for
 | 
					 | 
				
			||||||
		example:
 | 
					 | 
				
			||||||
			#define one(1), where 1 is not an identifier.
 | 
					 | 
				
			||||||
		Note that the '(' has already been eaten.
 | 
					 | 
				
			||||||
		The names of the formal parameters are stored into parbuf.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register char **pbuf = &buf[0];
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
	register char *ptr = &parbuf[0];
 | 
					 | 
				
			||||||
	register char **pbuf2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	LoadChar(c);
 | 
					 | 
				
			||||||
	c = skipspaces(c,0);
 | 
					 | 
				
			||||||
	if (c == ')') {		/* no parameters: #define name()	*/
 | 
					 | 
				
			||||||
		*pbuf = (char *) 0;
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	for (;;) {		/* eat the formal parameter list	*/
 | 
					 | 
				
			||||||
		if (class(c) != STIDF) {	/* not an identifier	*/
 | 
					 | 
				
			||||||
			error("#define: bad formal parameter");
 | 
					 | 
				
			||||||
			return -1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		*pbuf = ptr;	/* name of the formal	*/
 | 
					 | 
				
			||||||
		*ptr++ = c;
 | 
					 | 
				
			||||||
		if (ptr >= &parbuf[PARBUFSIZE])
 | 
					 | 
				
			||||||
			fatal("formal parameter buffer overflow");
 | 
					 | 
				
			||||||
		do {			/* eat the identifier name	*/
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			*ptr++ = c;
 | 
					 | 
				
			||||||
			if (ptr >= &parbuf[PARBUFSIZE])
 | 
					 | 
				
			||||||
				fatal("formal parameter buffer overflow");
 | 
					 | 
				
			||||||
		} while (in_idf(c));
 | 
					 | 
				
			||||||
		*(ptr - 1) = '\0';	/* mark end of the name		*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/*	Check if this formal parameter is already used.
 | 
					 | 
				
			||||||
			Usually, macros do not have many parameters, so ...
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		for (pbuf2 = pbuf - 1; pbuf2 >= &buf[0]; pbuf2--) {
 | 
					 | 
				
			||||||
			if (!strcmp(*pbuf2, *pbuf)) {
 | 
					 | 
				
			||||||
				warning("formal parameter \"%s\" already used",
 | 
					 | 
				
			||||||
					*pbuf);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		pbuf++;
 | 
					 | 
				
			||||||
		c = skipspaces(c,0);
 | 
					 | 
				
			||||||
		if (c == ')') {	/* end of the formal parameter list	*/
 | 
					 | 
				
			||||||
			*pbuf = (char *) 0;
 | 
					 | 
				
			||||||
			return pbuf - buf;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (c != ',') {
 | 
					 | 
				
			||||||
			error("#define: bad formal parameter list");
 | 
					 | 
				
			||||||
			return -1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
		c = skipspaces(c,0);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/*NOTREACHED*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXPORT
 | 
					 | 
				
			||||||
macro_def(id, text, nformals, length, flags)
 | 
					 | 
				
			||||||
	register struct idf *id;
 | 
					 | 
				
			||||||
	char *text;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	macro_def() puts the contents and information of a macro
 | 
					 | 
				
			||||||
		definition into a structure and stores it into the symbol
 | 
					 | 
				
			||||||
		table entry belonging to the name of the macro.
 | 
					 | 
				
			||||||
		A warning is given if the definition overwrites another.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register struct macro *newdef = id->id_macro;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	if (newdef) {		/* is there a redefinition?	*/
 | 
					 | 
				
			||||||
		if (macroeq(newdef->mc_text, text))
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		warning("redefine \"%s\"", id->id_text);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
#ifdef DOBITS
 | 
					 | 
				
			||||||
		register char *p = id->id_text;
 | 
					 | 
				
			||||||
#define setbit(bx)	if (!*p) goto go_on; bits[*p++] |= (bx)
 | 
					 | 
				
			||||||
		setbit(bit0);
 | 
					 | 
				
			||||||
		setbit(bit1);
 | 
					 | 
				
			||||||
		setbit(bit2);
 | 
					 | 
				
			||||||
		setbit(bit3);
 | 
					 | 
				
			||||||
		setbit(bit4);
 | 
					 | 
				
			||||||
		setbit(bit5);
 | 
					 | 
				
			||||||
		setbit(bit6);
 | 
					 | 
				
			||||||
		setbit(bit7);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	go_on:
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		id->id_macro = newdef = new_macro();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	newdef->mc_text = text;		/* replacement text	*/
 | 
					 | 
				
			||||||
	newdef->mc_nps  = nformals;	/* nr of formals	*/
 | 
					 | 
				
			||||||
	newdef->mc_length = length;	/* length of repl. text	*/
 | 
					 | 
				
			||||||
	newdef->mc_flag = flags;	/* special flags	*/
 | 
					 | 
				
			||||||
	newdef->mc_count = 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE int
 | 
					 | 
				
			||||||
find_name(nm, index)
 | 
					 | 
				
			||||||
	char *nm, *index[];
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	find_name() returns the index of "nm" in the namelist
 | 
					 | 
				
			||||||
		"index" if it can be found there.  0 is returned if it is
 | 
					 | 
				
			||||||
		not there.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register char **ip = &index[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while (*ip)
 | 
					 | 
				
			||||||
		if (strcmp(nm, *ip++) == 0)
 | 
					 | 
				
			||||||
			return ip - &index[0];
 | 
					 | 
				
			||||||
	/* arrived here, nm is not in the name list.	*/
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE char *
 | 
					 | 
				
			||||||
get_text(formals, length)
 | 
					 | 
				
			||||||
	char *formals[];
 | 
					 | 
				
			||||||
	int *length;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	get_text() copies the replacement text of a macro
 | 
					 | 
				
			||||||
		definition with zero, one or more parameters, thereby
 | 
					 | 
				
			||||||
		substituting each formal parameter by a special character
 | 
					 | 
				
			||||||
		(non-ascii: 0200 & (order-number in the formal parameter
 | 
					 | 
				
			||||||
		list)) in order to substitute this character later by the
 | 
					 | 
				
			||||||
		actual parameter.  The replacement text is copied into
 | 
					 | 
				
			||||||
		itself because the copied text will contain fewer or the
 | 
					 | 
				
			||||||
		same amount of characters.  The length of the replacement
 | 
					 | 
				
			||||||
		text is returned.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		Implementation:
 | 
					 | 
				
			||||||
		finite automaton : we are only interested in
 | 
					 | 
				
			||||||
		identifiers, because they might be replaced by some actual
 | 
					 | 
				
			||||||
		parameter.  Other tokens will not be seen as such.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
	register unsigned int text_size;
 | 
					 | 
				
			||||||
	char *text = Malloc(text_size = ITEXTSIZE);
 | 
					 | 
				
			||||||
	register unsigned int pos = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	LoadChar(c);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while ((c != EOI) && (class(c) != STNL)) {
 | 
					 | 
				
			||||||
		if (c == '\\') {	/* check for "\\\n"	*/
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (c == '\n') {
 | 
					 | 
				
			||||||
				/*	More than one line is used for the
 | 
					 | 
				
			||||||
					replacement text.
 | 
					 | 
				
			||||||
					Replace "\\\n" by " ".
 | 
					 | 
				
			||||||
				*/
 | 
					 | 
				
			||||||
				text[pos++] = ' ';
 | 
					 | 
				
			||||||
				++LineNumber;
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				text[pos++] = '\\';
 | 
					 | 
				
			||||||
			if (pos == text_size)
 | 
					 | 
				
			||||||
				text = Realloc(text, text_size <<= 1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
		if ( c == '/') {
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (c == '*') {
 | 
					 | 
				
			||||||
				skipcomment();
 | 
					 | 
				
			||||||
				/* text[pos++] = ' '; ??? Why ??? */
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				text[pos++] = '/';
 | 
					 | 
				
			||||||
			if (pos == text_size)
 | 
					 | 
				
			||||||
				text = Realloc(text, text_size <<= 1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
		if (formals && class(c) == STIDF) {
 | 
					 | 
				
			||||||
			char id_buf[IDFSIZE + 1];
 | 
					 | 
				
			||||||
			register char *idp = id_buf;
 | 
					 | 
				
			||||||
			int n;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			/* read identifier: it may be a formal parameter */
 | 
					 | 
				
			||||||
			*idp++ = c;
 | 
					 | 
				
			||||||
			do {
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				if (idp <= &id_buf[IDFSIZE])
 | 
					 | 
				
			||||||
					*idp++ = c;
 | 
					 | 
				
			||||||
			} while (in_idf(c));
 | 
					 | 
				
			||||||
			*--idp = '\0';
 | 
					 | 
				
			||||||
			if (n = find_name(id_buf, formals)) {
 | 
					 | 
				
			||||||
				/* construct the formal parameter mark	*/
 | 
					 | 
				
			||||||
				text[pos++] = FORMALP | (char) n;
 | 
					 | 
				
			||||||
				if (pos == text_size)
 | 
					 | 
				
			||||||
					text = Realloc(text,
 | 
					 | 
				
			||||||
						text_size <<= 1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else {
 | 
					 | 
				
			||||||
				int sz = idp - id_buf + 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				idp = id_buf;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				while (pos + sz >= text_size) text_size <<= 1;
 | 
					 | 
				
			||||||
				text = Realloc(text, text_size);
 | 
					 | 
				
			||||||
				while (text[pos++] = *idp++) ;
 | 
					 | 
				
			||||||
				pos--;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			text[pos++] = c;
 | 
					 | 
				
			||||||
			if (pos == text_size)
 | 
					 | 
				
			||||||
				text = Realloc(text, text_size <<= 1);
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	text[pos++] = '\0';
 | 
					 | 
				
			||||||
	text = Realloc(text, pos);
 | 
					 | 
				
			||||||
	*length = pos - 1;
 | 
					 | 
				
			||||||
	return text;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	BLANK(ch)	((ch == ' ') || (ch == '\t'))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	macroeq() decides whether two macro replacement texts are
 | 
					 | 
				
			||||||
	identical.  This version compares the texts, which occur
 | 
					 | 
				
			||||||
	as strings, without taking care of the leading and trailing
 | 
					 | 
				
			||||||
	blanks (spaces and tabs).
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
macroeq(s, t)
 | 
					 | 
				
			||||||
	register char *s, *t;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	/* skip leading spaces	*/
 | 
					 | 
				
			||||||
	while (BLANK(*s)) s++;
 | 
					 | 
				
			||||||
	while (BLANK(*t)) t++;
 | 
					 | 
				
			||||||
	/* first non-blank encountered in both strings	*/
 | 
					 | 
				
			||||||
	/* The actual comparison loop:			*/
 | 
					 | 
				
			||||||
	while (*s && *s == *t)
 | 
					 | 
				
			||||||
		s++, t++;
 | 
					 | 
				
			||||||
	/* two cases are possible when arrived here:	*/
 | 
					 | 
				
			||||||
	if (*s == '\0')	{	/* *s == '\0'		*/
 | 
					 | 
				
			||||||
		while (BLANK(*t)) t++;
 | 
					 | 
				
			||||||
		return *t == '\0';
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else	{		/* *s != *t		*/
 | 
					 | 
				
			||||||
		while (BLANK(*s)) s++;
 | 
					 | 
				
			||||||
		while (BLANK(*t)) t++;
 | 
					 | 
				
			||||||
		return (*s == '\0') && (*t == '\0');
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										148
									
								
								util/cpp/error.c
									
										
									
									
									
								
							
							
						
						
									
										148
									
								
								util/cpp/error.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,148 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/*	E R R O R   A N D  D I A G N O S T I C   R O U T I N E S	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	<system.h>
 | 
					 | 
				
			||||||
#if __STDC__
 | 
					 | 
				
			||||||
#include	<stdarg.h>
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#include	<varargs.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"errout.h"
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	This file contains the (non-portable) error-message and diagnostic
 | 
					 | 
				
			||||||
	functions.  Beware, they are called with a variable number of
 | 
					 | 
				
			||||||
	arguments!
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int err_occurred;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
err_hdr(s)
 | 
					 | 
				
			||||||
	char *s;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (FileName) {
 | 
					 | 
				
			||||||
		fprint(ERROUT, "\"%s\", line %d: %s", FileName, LineNumber, s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else	fprint(ERROUT, s);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if __STDC__
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
error(char *fmt, ...)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	va_start(ap, fmt);
 | 
					 | 
				
			||||||
	err_hdr("");
 | 
					 | 
				
			||||||
	err_occurred = 1;
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
warning(char *fmt, ...)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	va_start(ap, fmt);
 | 
					 | 
				
			||||||
	err_hdr("(warning) ");
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
crash(char *fmt, ...)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	va_start(ap, fmt);
 | 
					 | 
				
			||||||
	err_hdr("CRASH\007 ");
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
	sys_stop(S_ABORT);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
fatal(char *fmt, ...)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	va_start(ap, fmt);
 | 
					 | 
				
			||||||
	err_hdr("fatal error -- ");
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
	sys_stop(S_EXIT);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#else /* __STDC__ */
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
error(va_alist)
 | 
					 | 
				
			||||||
	va_dcl
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *fmt;
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	err_hdr("");
 | 
					 | 
				
			||||||
	err_occurred = 1;
 | 
					 | 
				
			||||||
	va_start(ap);
 | 
					 | 
				
			||||||
	fmt = va_arg(ap, char *);
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
warning(va_alist)
 | 
					 | 
				
			||||||
	va_dcl
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *fmt;
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	err_hdr("(warning) ");
 | 
					 | 
				
			||||||
	va_start(ap);
 | 
					 | 
				
			||||||
	fmt = va_arg(ap, char *);
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
crash(va_alist)
 | 
					 | 
				
			||||||
	va_dcl
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *fmt;
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	err_hdr("CRASH\007 ");
 | 
					 | 
				
			||||||
	va_start(ap);
 | 
					 | 
				
			||||||
	fmt = va_arg(ap, char *);
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
	sys_stop(S_ABORT);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*VARARGS1*/
 | 
					 | 
				
			||||||
fatal(va_alist)
 | 
					 | 
				
			||||||
	va_dcl
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	char *fmt;
 | 
					 | 
				
			||||||
	va_list ap;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	err_hdr("fatal error -- ");
 | 
					 | 
				
			||||||
	va_start(ap);
 | 
					 | 
				
			||||||
	fmt = va_arg(ap, char *);
 | 
					 | 
				
			||||||
	doprnt(ERROUT, fmt, ap);
 | 
					 | 
				
			||||||
	fprint(ERROUT, "\n");
 | 
					 | 
				
			||||||
	va_end(ap);
 | 
					 | 
				
			||||||
	sys_stop(S_EXIT);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,58 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* OPERATOR HANDLING */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
rank_of(oper)
 | 
					 | 
				
			||||||
	int oper;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	The rank of the operator oper is returned.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	switch (oper)	{
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	case '(':
 | 
					 | 
				
			||||||
		return 1;
 | 
					 | 
				
			||||||
	case '!':
 | 
					 | 
				
			||||||
		return 2;
 | 
					 | 
				
			||||||
	case '*':
 | 
					 | 
				
			||||||
	case '/':
 | 
					 | 
				
			||||||
	case '%':
 | 
					 | 
				
			||||||
		return 3;
 | 
					 | 
				
			||||||
	case '+':
 | 
					 | 
				
			||||||
	case '-':
 | 
					 | 
				
			||||||
		return 4;
 | 
					 | 
				
			||||||
	case LEFT:
 | 
					 | 
				
			||||||
	case RIGHT:
 | 
					 | 
				
			||||||
		return 5;
 | 
					 | 
				
			||||||
	case '<':
 | 
					 | 
				
			||||||
	case '>':
 | 
					 | 
				
			||||||
	case LESSEQ:
 | 
					 | 
				
			||||||
	case GREATEREQ:
 | 
					 | 
				
			||||||
		return 6;
 | 
					 | 
				
			||||||
	case EQUAL:
 | 
					 | 
				
			||||||
	case NOTEQUAL:
 | 
					 | 
				
			||||||
		return 7;
 | 
					 | 
				
			||||||
	case '&':
 | 
					 | 
				
			||||||
		return 8;
 | 
					 | 
				
			||||||
	case '^':
 | 
					 | 
				
			||||||
		return 9;
 | 
					 | 
				
			||||||
	case '|':
 | 
					 | 
				
			||||||
		return 10;
 | 
					 | 
				
			||||||
	case AND:
 | 
					 | 
				
			||||||
		return 11;
 | 
					 | 
				
			||||||
	case OR:
 | 
					 | 
				
			||||||
		return 12;
 | 
					 | 
				
			||||||
	case '?':
 | 
					 | 
				
			||||||
	case ':':
 | 
					 | 
				
			||||||
		return 13;
 | 
					 | 
				
			||||||
	case ',':
 | 
					 | 
				
			||||||
		return 15;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/*NOTREACHED*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,130 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/*	EXPRESSION SYNTAX PARSER	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
%lexical	LLlex;
 | 
					 | 
				
			||||||
%start		If_expr, if_expression;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	<em_arith.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern arith ifval;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if_expression
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	constant_expression(&ifval)
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* 7.1 */
 | 
					 | 
				
			||||||
primary(arith *pval;)
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	constant(pval)
 | 
					 | 
				
			||||||
|
 | 
					 | 
				
			||||||
	'(' expression(pval) ')'
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unary(arith *pval;)
 | 
					 | 
				
			||||||
	{int oper;}
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	unop(&oper)
 | 
					 | 
				
			||||||
	unary(pval)
 | 
					 | 
				
			||||||
	{ ch7mon(oper, pval); }
 | 
					 | 
				
			||||||
|
 | 
					 | 
				
			||||||
	primary(pval)
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
binary_expression(int maxrank; arith *pval;)
 | 
					 | 
				
			||||||
	{int oper; arith val1;}
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	unary(pval)
 | 
					 | 
				
			||||||
	[%while (rank_of(DOT) <= maxrank)
 | 
					 | 
				
			||||||
		binop(&oper)
 | 
					 | 
				
			||||||
		binary_expression(rank_of(oper)-1, &val1)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			ch7bin(pval, oper, val1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	]*
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* 7.13 */
 | 
					 | 
				
			||||||
conditional_expression(arith *pval;)
 | 
					 | 
				
			||||||
	{arith val1 = 0, val2 = 0;}
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	/* allow all binary operators */
 | 
					 | 
				
			||||||
	binary_expression(rank_of('?') - 1, pval)
 | 
					 | 
				
			||||||
	[	'?'
 | 
					 | 
				
			||||||
		expression(&val1)
 | 
					 | 
				
			||||||
		':'
 | 
					 | 
				
			||||||
		assignment_expression(&val2)
 | 
					 | 
				
			||||||
		{ *pval = (*pval ? val1 : val2); }
 | 
					 | 
				
			||||||
	]?
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* 7.14 */
 | 
					 | 
				
			||||||
assignment_expression(arith *pval;)
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	conditional_expression(pval)
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* 7.15 */
 | 
					 | 
				
			||||||
expression(arith *pval;)
 | 
					 | 
				
			||||||
	{arith val1;}
 | 
					 | 
				
			||||||
:
 | 
					 | 
				
			||||||
	assignment_expression(pval)
 | 
					 | 
				
			||||||
	[	','
 | 
					 | 
				
			||||||
		assignment_expression(&val1)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			ch7bin(pval, ',', val1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	]*
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
unop(int *oper;) :
 | 
					 | 
				
			||||||
	[ '-' | '!' | '~' ]
 | 
					 | 
				
			||||||
	{*oper = DOT;}
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
multop:
 | 
					 | 
				
			||||||
	'*' | '/' | '%'
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
addop:
 | 
					 | 
				
			||||||
	'+' | '-'
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
shiftop:
 | 
					 | 
				
			||||||
	LEFT | RIGHT
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
relop:
 | 
					 | 
				
			||||||
	'<' | '>' | LESSEQ | GREATEREQ
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
eqop:
 | 
					 | 
				
			||||||
	EQUAL | NOTEQUAL
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
arithop:
 | 
					 | 
				
			||||||
	multop | addop | shiftop
 | 
					 | 
				
			||||||
|
 | 
					 | 
				
			||||||
	'&' | '^' | '|'
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
binop(int *oper;) :
 | 
					 | 
				
			||||||
	[ arithop | relop | eqop | AND | OR ]
 | 
					 | 
				
			||||||
	{*oper = DOT;}
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
constant(arith *pval;) :
 | 
					 | 
				
			||||||
	INTEGER
 | 
					 | 
				
			||||||
	{*pval = dot.tk_val;}
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
constant_expression (arith *pval;) :
 | 
					 | 
				
			||||||
	assignment_expression(pval)
 | 
					 | 
				
			||||||
;
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,18 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* F I L E   I N F O R M A T I O N   S T R U C T U R E */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct file_info {
 | 
					 | 
				
			||||||
	unsigned int	fil_lino;
 | 
					 | 
				
			||||||
	char		*fil_name;
 | 
					 | 
				
			||||||
	char		*fil_wdir;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define LineNumber	finfo.fil_lino
 | 
					 | 
				
			||||||
#define FileName	finfo.fil_name
 | 
					 | 
				
			||||||
#define WorkingDir	finfo.fil_wdir
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern struct file_info finfo;	/* input.c */
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,7 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#include "idf.h"
 | 
					 | 
				
			||||||
#include <idf_pkg.body>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,20 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
struct id_usr {
 | 
					 | 
				
			||||||
	union {
 | 
					 | 
				
			||||||
		struct macro *idu_macro;
 | 
					 | 
				
			||||||
		struct idf *idu_file;
 | 
					 | 
				
			||||||
	} idu_x;
 | 
					 | 
				
			||||||
	int idu_resmac;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define IDF_TYPE struct id_usr
 | 
					 | 
				
			||||||
#define IDF_HSIZE 6
 | 
					 | 
				
			||||||
#define id_macro id_user.idu_x.idu_macro
 | 
					 | 
				
			||||||
#define id_file id_user.idu_x.idu_file
 | 
					 | 
				
			||||||
#define id_resmac id_user.idu_resmac
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <idf_pkg.spec>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,77 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* PREPROCESSOR: INITIALIZATION ROUTINES */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	<string.h>
 | 
					 | 
				
			||||||
#include	<system.h>
 | 
					 | 
				
			||||||
#include	<alloc.h>
 | 
					 | 
				
			||||||
#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},
 | 
					 | 
				
			||||||
	{"pragma",	K_PRAGMA},
 | 
					 | 
				
			||||||
	{0,		K_UNKNOWN}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXPORT
 | 
					 | 
				
			||||||
init_pp()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	long clock, sys_time();
 | 
					 | 
				
			||||||
	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)	{
 | 
					 | 
				
			||||||
			struct idf *idf = str2idf(mk->mk_reserved, 0);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (idf->id_resmac)
 | 
					 | 
				
			||||||
				fatal("maximum identifier length insufficient");
 | 
					 | 
				
			||||||
			idf->id_resmac = mk->mk_key;
 | 
					 | 
				
			||||||
			mk++;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*	Initialize __DATE__, __FILE__ and __LINE__ macro
 | 
					 | 
				
			||||||
		definitions.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	/* __DATE__	*/
 | 
					 | 
				
			||||||
	clock = sys_time();
 | 
					 | 
				
			||||||
	strcpy(&date[1], ctime(&clock));
 | 
					 | 
				
			||||||
	date[26] = '\0';		/* zap nl	*/
 | 
					 | 
				
			||||||
	date[0] = date[25] = '"';
 | 
					 | 
				
			||||||
	macro_def(str2idf("__DATE__", 0), date, -1, 26, NOFLAG);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* __LINE__	*/
 | 
					 | 
				
			||||||
	macro_def(str2idf("__LINE__", 0), "0", -1, 1, FUNC);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* __FILE__	*/
 | 
					 | 
				
			||||||
	macro_def(str2idf("__FILE__", 0), "", -1, 1, FUNC);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* defined(??) */
 | 
					 | 
				
			||||||
	macro_def(str2idf("defined", 0), "", 1, 1, FUNC);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,68 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
 
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <stdio.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include "file_info.h"
 | 
					 | 
				
			||||||
#include "input.h"
 | 
					 | 
				
			||||||
#define INP_TYPE	struct file_info
 | 
					 | 
				
			||||||
#define INP_VAR		finfo
 | 
					 | 
				
			||||||
struct file_info	finfo;
 | 
					 | 
				
			||||||
#include <inp_pkg.body>
 | 
					 | 
				
			||||||
#include <alloc.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *
 | 
					 | 
				
			||||||
getwdir(fn)
 | 
					 | 
				
			||||||
	char *fn;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register char *p;
 | 
					 | 
				
			||||||
	char *strrchr();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	p = strrchr(fn, '/');
 | 
					 | 
				
			||||||
	while (p && *(p + 1) == '\0') {	/* remove trailing /'s */
 | 
					 | 
				
			||||||
		*p = '\0';
 | 
					 | 
				
			||||||
		p = strrchr(fn, '/');
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (fn[0] == '\0' || (fn[0] == '/' && p == &fn[0])) /* absolute path */
 | 
					 | 
				
			||||||
		return "";
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
	if (p) {
 | 
					 | 
				
			||||||
		*p = '\0';
 | 
					 | 
				
			||||||
		fn = Salloc(fn, p - &fn[0] + 1);
 | 
					 | 
				
			||||||
		*p = '/';
 | 
					 | 
				
			||||||
		return fn;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else return "";
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int	NoUnstack;
 | 
					 | 
				
			||||||
int	Unstacked;
 | 
					 | 
				
			||||||
int	InputLevel;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
AtEoIT()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/* if (NoUnstack) warning("unexpected EOF"); ??? */
 | 
					 | 
				
			||||||
	/* This is wrong; in an #elif, NoUnstack can be set, but you
 | 
					 | 
				
			||||||
	   can still get calls to AtEoIT().
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	InputLevel--;
 | 
					 | 
				
			||||||
	DoUnstack();
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
AtEoIF()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	extern int nestlevel;
 | 
					 | 
				
			||||||
	extern int nestcount;
 | 
					 | 
				
			||||||
	extern int svnestlevel[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (nestlevel > svnestlevel[nestcount]) warning("missing #endif");
 | 
					 | 
				
			||||||
	else if (NoUnstack) warning("unexpected EOF");
 | 
					 | 
				
			||||||
	nestlevel = svnestlevel[nestcount--];
 | 
					 | 
				
			||||||
	return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,7 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#include "inputtype.h"
 | 
					 | 
				
			||||||
#include <inp_pkg.spec>
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,8 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#define PRIVATE	
 | 
					 | 
				
			||||||
#define IMPORT extern
 | 
					 | 
				
			||||||
#define EXPORT
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,78 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	The flags of the mc_flag field of the macro structure. Note that
 | 
					 | 
				
			||||||
	these flags can be set simultaneously.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define NOFLAG		0		/* no special flags	*/
 | 
					 | 
				
			||||||
#define	FUNC		01		/* function attached    */
 | 
					 | 
				
			||||||
#define NOREPLACE	02		/* don't replace	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	FORMALP 0200	/* mask for creating macro formal parameter	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	The macro descriptor is very simple, except the fact that the
 | 
					 | 
				
			||||||
	mc_text, which points to the replacement text, contains the
 | 
					 | 
				
			||||||
	non-ascii characters \201, \202, etc, indicating the position of a
 | 
					 | 
				
			||||||
	formal parameter in this text.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
struct macro	{
 | 
					 | 
				
			||||||
	struct macro *next;
 | 
					 | 
				
			||||||
	char *	mc_text;	/* the replacement text		*/
 | 
					 | 
				
			||||||
	int	mc_nps;		/* number of formal parameters	*/
 | 
					 | 
				
			||||||
	int	mc_length;	/* length of replacement text	*/
 | 
					 | 
				
			||||||
	int	mc_count;	/* # of "concurrent" invocations*/
 | 
					 | 
				
			||||||
	char	mc_flag;	/* marking this macro		*/
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* allocation definitions of struct macro */
 | 
					 | 
				
			||||||
extern char *st_alloc();
 | 
					 | 
				
			||||||
extern struct macro *h_macro;
 | 
					 | 
				
			||||||
#ifdef DEBUG
 | 
					 | 
				
			||||||
extern int cnt_macro;
 | 
					 | 
				
			||||||
extern char *std_alloc();
 | 
					 | 
				
			||||||
#define	new_macro() ((struct macro *) std_alloc((char **)&h_macro, sizeof(struct macro), 20, &cnt_macro))
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#define	new_macro() ((struct macro *) st_alloc((char **)&h_macro, sizeof(struct macro), 20))
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#define	free_macro(p) st_free(p, &h_macro, sizeof(struct macro))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct mlist {
 | 
					 | 
				
			||||||
	struct mlist *next;
 | 
					 | 
				
			||||||
	struct macro *m_mac;
 | 
					 | 
				
			||||||
	char *m_repl;
 | 
					 | 
				
			||||||
	int m_level;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* allocation definitions of struct mlist */
 | 
					 | 
				
			||||||
extern char *st_alloc();
 | 
					 | 
				
			||||||
extern struct mlist *h_mlist;
 | 
					 | 
				
			||||||
#ifdef DEBUG
 | 
					 | 
				
			||||||
extern int cnt_mlist;
 | 
					 | 
				
			||||||
extern char *std_alloc();
 | 
					 | 
				
			||||||
#define	new_mlist() ((struct mlist *) std_alloc((char **)&h_mlist, sizeof(struct mlist), 20, &cnt_mlist))
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
#define	new_mlist() ((struct mlist *) st_alloc((char **)&h_mlist, sizeof(struct mlist), 20))
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
#define	free_mlist(p) st_free(p, &h_mlist, sizeof(struct mlist))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* `token' numbers of keywords of command-line processor
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
#define	K_UNKNOWN	0
 | 
					 | 
				
			||||||
#define	K_DEFINE	1
 | 
					 | 
				
			||||||
#define	K_ELIF		2
 | 
					 | 
				
			||||||
#define	K_ELSE		3
 | 
					 | 
				
			||||||
#define	K_ENDIF		4
 | 
					 | 
				
			||||||
#define	K_IF		5
 | 
					 | 
				
			||||||
#define	K_IFDEF		6
 | 
					 | 
				
			||||||
#define	K_IFNDEF	7
 | 
					 | 
				
			||||||
#define	K_INCLUDE	8
 | 
					 | 
				
			||||||
#define	K_LINE		9
 | 
					 | 
				
			||||||
#define	K_UNDEF		10
 | 
					 | 
				
			||||||
#define K_PRAGMA	11
 | 
					 | 
				
			||||||
#define K_FILE		100	/* for dependency generator */
 | 
					 | 
				
			||||||
							
								
								
									
										152
									
								
								util/cpp/main.c
									
										
									
									
									
								
							
							
						
						
									
										152
									
								
								util/cpp/main.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,152 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* MAIN PROGRAM */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <alloc.h>
 | 
					 | 
				
			||||||
#include <em_arith.h>
 | 
					 | 
				
			||||||
#include <assert.h>
 | 
					 | 
				
			||||||
#include <system.h>
 | 
					 | 
				
			||||||
#include "file_info.h"
 | 
					 | 
				
			||||||
#include "idfsize.h"
 | 
					 | 
				
			||||||
#include "idf.h"
 | 
					 | 
				
			||||||
#include "macro.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char *symbol2str();
 | 
					 | 
				
			||||||
extern char *getwdir();
 | 
					 | 
				
			||||||
extern int err_occurred;
 | 
					 | 
				
			||||||
extern int do_dependencies;
 | 
					 | 
				
			||||||
extern char *dep_file;
 | 
					 | 
				
			||||||
int idfsize = IDFSIZE;
 | 
					 | 
				
			||||||
extern char options[];
 | 
					 | 
				
			||||||
static File *dep_fd = STDOUT;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
arith ifval;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *prog_name;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern char **inctable;
 | 
					 | 
				
			||||||
extern int inc_max, inc_total;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
main(argc, argv)
 | 
					 | 
				
			||||||
	char *argv[];
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/* parse and interpret the command line options	*/
 | 
					 | 
				
			||||||
	prog_name = argv[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	init_idf();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	inctable = (char **) Malloc(10 * sizeof(char *));
 | 
					 | 
				
			||||||
	inc_max = 10;
 | 
					 | 
				
			||||||
	inc_total = 3;
 | 
					 | 
				
			||||||
	inctable[0] = "";
 | 
					 | 
				
			||||||
	inctable[1] = "/usr/include";
 | 
					 | 
				
			||||||
	inctable[2] = 0;
 | 
					 | 
				
			||||||
	init_pp();	/* initialise the preprocessor macros	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*	Note: source file "-" indicates that the source is supplied
 | 
					 | 
				
			||||||
		as standard input.  This is only allowed if INP_READ_IN_ONE is
 | 
					 | 
				
			||||||
		not defined!
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	while (argc > 1 && *argv[1] == '-' && argv[1][1] != '\0')	{
 | 
					 | 
				
			||||||
		char *par = &argv[1][1];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (*par == '-')
 | 
					 | 
				
			||||||
			par++;
 | 
					 | 
				
			||||||
		do_option(par);
 | 
					 | 
				
			||||||
		argc--, argv++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	compile(argc - 1, &argv[1]);
 | 
					 | 
				
			||||||
	exit(err_occurred);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
compile(argc, argv)
 | 
					 | 
				
			||||||
	char *argv[];
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register char *source = 0;
 | 
					 | 
				
			||||||
	char *dummy;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	switch (argc) {
 | 
					 | 
				
			||||||
	case 1:
 | 
					 | 
				
			||||||
		source = argv[0];
 | 
					 | 
				
			||||||
		FileName = source;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 0:
 | 
					 | 
				
			||||||
		FileName = "";
 | 
					 | 
				
			||||||
		WorkingDir = "";
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		FileName = argv[0];
 | 
					 | 
				
			||||||
		fatal("use: %s [options] [source]", prog_name);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!InsertFile(source, (char **) 0, &dummy)) /* read the source file	*/
 | 
					 | 
				
			||||||
		fatal("%s: no source file %s", prog_name, 
 | 
					 | 
				
			||||||
			source ? source : "stdin");
 | 
					 | 
				
			||||||
	if (source) WorkingDir = getwdir(dummy);
 | 
					 | 
				
			||||||
	preprocess(source);
 | 
					 | 
				
			||||||
	if (do_dependencies) list_dependencies(source);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct idf	*file_head;
 | 
					 | 
				
			||||||
extern char *strrchr();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
list_dependencies(source)
 | 
					 | 
				
			||||||
	char *source;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register struct idf *p = file_head;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (source) {
 | 
					 | 
				
			||||||
		register char *s = strrchr(source, '.');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (s && *(s+1)) {
 | 
					 | 
				
			||||||
			s++;
 | 
					 | 
				
			||||||
			*s++ = 'o';
 | 
					 | 
				
			||||||
			*s = '\0';
 | 
					 | 
				
			||||||
                        /* the source may be in another directory than the
 | 
					 | 
				
			||||||
                         * object generated, so don't include the pathname
 | 
					 | 
				
			||||||
                         * leading to it.
 | 
					 | 
				
			||||||
                         */
 | 
					 | 
				
			||||||
                        if (s = strrchr(source, '/')) {
 | 
					 | 
				
			||||||
                                source = s + 1;
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else source = 0; 
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (dep_file && !sys_open(dep_file, OP_WRITE, &dep_fd)) {
 | 
					 | 
				
			||||||
		fatal("could not open %s", dep_file);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	while (p) {
 | 
					 | 
				
			||||||
		assert(p->id_resmac == K_FILE);
 | 
					 | 
				
			||||||
		dependency(p->id_text, source);
 | 
					 | 
				
			||||||
		p = p->id_file;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
add_dependency(s)
 | 
					 | 
				
			||||||
	char *s;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register struct idf *p = str2idf(s, 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (! p->id_resmac) {
 | 
					 | 
				
			||||||
		p->id_resmac = K_FILE;
 | 
					 | 
				
			||||||
		p->id_file = file_head;
 | 
					 | 
				
			||||||
		file_head = p;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
dependency(s, source)
 | 
					 | 
				
			||||||
	char *s, *source;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (options['i'] && !strncmp(s, "/usr/include/", 13)) {
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (options['m'] && source) {
 | 
					 | 
				
			||||||
		fprint(dep_fd, "%s: %s\n", source, s);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else	fprint(dep_fd, "%s\n", s);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,35 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
: Update Files from database
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PATH=/bin:/usr/bin
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
case $# in
 | 
					 | 
				
			||||||
1) ;;
 | 
					 | 
				
			||||||
*)	echo use: $0 file >&2
 | 
					 | 
				
			||||||
	exit 1
 | 
					 | 
				
			||||||
esac
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
(
 | 
					 | 
				
			||||||
IFCOMMAND="if [ -r \$FN ] ;\
 | 
					 | 
				
			||||||
	then	if cmp -s \$FN \$TMP;\
 | 
					 | 
				
			||||||
		then	rm \$TMP;\
 | 
					 | 
				
			||||||
		else	mv \$TMP \$FN;\
 | 
					 | 
				
			||||||
			echo update \$FN;\
 | 
					 | 
				
			||||||
		fi;\
 | 
					 | 
				
			||||||
	else	mv \$TMP \$FN;\
 | 
					 | 
				
			||||||
		echo create \$FN;\
 | 
					 | 
				
			||||||
	fi"
 | 
					 | 
				
			||||||
echo 'TMP=.uf$$'
 | 
					 | 
				
			||||||
echo 'FN=$TMP'
 | 
					 | 
				
			||||||
echo 'cat >$TMP <<\!EOF!'
 | 
					 | 
				
			||||||
sed -n '/^!File:/,${
 | 
					 | 
				
			||||||
/^$/d
 | 
					 | 
				
			||||||
/^!File:[	 ]*\(.*\)$/s@@!EOF!\
 | 
					 | 
				
			||||||
'"$IFCOMMAND"'\
 | 
					 | 
				
			||||||
FN=\1\
 | 
					 | 
				
			||||||
cat >$TMP <<\\!EOF!@
 | 
					 | 
				
			||||||
p
 | 
					 | 
				
			||||||
}' $1
 | 
					 | 
				
			||||||
echo '!EOF!'
 | 
					 | 
				
			||||||
echo $IFCOMMAND
 | 
					 | 
				
			||||||
) | eval "$(cat)"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,36 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cat <<'--EOT--'
 | 
					 | 
				
			||||||
#include "Lpars.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *
 | 
					 | 
				
			||||||
symbol2str(tok)
 | 
					 | 
				
			||||||
	int tok;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	static char buf[2] = { '\0', '\0' };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (040 <= tok && tok < 0177) {
 | 
					 | 
				
			||||||
		buf[0] = tok;
 | 
					 | 
				
			||||||
		buf[1] = '\0';
 | 
					 | 
				
			||||||
		return buf;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	switch (tok) {
 | 
					 | 
				
			||||||
--EOT--
 | 
					 | 
				
			||||||
sed '
 | 
					 | 
				
			||||||
/{[A-Z]/!d
 | 
					 | 
				
			||||||
s/.*{\(.*\),.*\(".*"\).*$/	case \1 :\
 | 
					 | 
				
			||||||
		return \2;/
 | 
					 | 
				
			||||||
'
 | 
					 | 
				
			||||||
cat <<'--EOT--'
 | 
					 | 
				
			||||||
	case '\n':
 | 
					 | 
				
			||||||
	case '\f':
 | 
					 | 
				
			||||||
	case '\v':
 | 
					 | 
				
			||||||
	case '\r':
 | 
					 | 
				
			||||||
	case '\t':
 | 
					 | 
				
			||||||
		buf[0] = tok;
 | 
					 | 
				
			||||||
		return buf;
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		return "bad token";
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
--EOT--
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,8 +0,0 @@
 | 
				
			||||||
#!/bin/sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
sed '
 | 
					 | 
				
			||||||
/{[A-Z]/!d
 | 
					 | 
				
			||||||
s/.*{//
 | 
					 | 
				
			||||||
s/,.*//
 | 
					 | 
				
			||||||
s/.*/%token	&;/
 | 
					 | 
				
			||||||
'
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,12 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
#include "debug.h"
 | 
					 | 
				
			||||||
struct macro *h_macro = 0;
 | 
					 | 
				
			||||||
struct mlist *h_mlist = 0;
 | 
					 | 
				
			||||||
#ifdef DEBUG
 | 
					 | 
				
			||||||
int cnt_macro = 0;
 | 
					 | 
				
			||||||
int cnt_mlist = 0;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,148 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* USER-OPTION HANDLING */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include	<alloc.h>
 | 
					 | 
				
			||||||
#include	"idfsize.h"
 | 
					 | 
				
			||||||
#include	"class.h"
 | 
					 | 
				
			||||||
#include	"macro.h"
 | 
					 | 
				
			||||||
#include	"idf.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char options[128];			/* one for every char	*/
 | 
					 | 
				
			||||||
int inc_pos = 1;			/* place where next -I goes */
 | 
					 | 
				
			||||||
int inc_max;
 | 
					 | 
				
			||||||
int inc_total;
 | 
					 | 
				
			||||||
int do_preprocess = 1;
 | 
					 | 
				
			||||||
int do_dependencies = 0;
 | 
					 | 
				
			||||||
char **inctable;
 | 
					 | 
				
			||||||
char *dep_file = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
extern int idfsize;
 | 
					 | 
				
			||||||
int txt2int();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
do_option(text)
 | 
					 | 
				
			||||||
	char *text;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	switch(*text++)	{
 | 
					 | 
				
			||||||
	case '-':
 | 
					 | 
				
			||||||
		options[*text] = 1;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'u':
 | 
					 | 
				
			||||||
		if (! strcmp(text,"ndef")) {
 | 
					 | 
				
			||||||
			/* ignore -undef */
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		/* fall through */
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		error("illegal option: %c", text[-1]);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'C' :	/* comment output		*/
 | 
					 | 
				
			||||||
	case 'P' :	/* run preprocessor stand-alone, without #'s	*/
 | 
					 | 
				
			||||||
		options[*(text-1)] = 1;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'A' :	/* for Amake */
 | 
					 | 
				
			||||||
	case 'd' :	/* dependency generation */
 | 
					 | 
				
			||||||
		do_dependencies = 1;
 | 
					 | 
				
			||||||
		if (*text) {
 | 
					 | 
				
			||||||
			dep_file = text;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			do_preprocess = 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'm':
 | 
					 | 
				
			||||||
	case 'i':
 | 
					 | 
				
			||||||
		options[*(text-1)] = 1;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	case 'D' :	/* -Dname :	predefine name		*/
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		register char *cp = text, *name, *mactext;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (class(*cp) != STIDF)	{
 | 
					 | 
				
			||||||
			error("identifier missing in -D%s", text);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		name = cp;
 | 
					 | 
				
			||||||
		while (*cp && in_idf(*cp))
 | 
					 | 
				
			||||||
			++cp;
 | 
					 | 
				
			||||||
		if (!*cp)			/* -Dname */
 | 
					 | 
				
			||||||
			mactext = "1";
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
		if (*cp == '=')	{		/* -Dname=text	*/
 | 
					 | 
				
			||||||
			*cp++ = '\0';		/* end of name	*/
 | 
					 | 
				
			||||||
			mactext = cp;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else	{			/* -Dname?? */
 | 
					 | 
				
			||||||
			error("malformed option -D%s", text);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		macro_def(str2idf(name, 0), mactext, -1, strlen(mactext), NOFLAG);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	case 'I' :	/* -Ipath : insert "path" into include list	*/
 | 
					 | 
				
			||||||
		if (*text)	{
 | 
					 | 
				
			||||||
			register int i;
 | 
					 | 
				
			||||||
			register char *new = text;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (++inc_total > inc_max) {
 | 
					 | 
				
			||||||
				inctable = (char **)
 | 
					 | 
				
			||||||
				  Realloc((void*) inctable,(inc_max+=10)*sizeof(char *));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			for(i = inc_pos++; i < inc_total; i++) {
 | 
					 | 
				
			||||||
				char *tmp = inctable[i];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				inctable[i] = new;
 | 
					 | 
				
			||||||
				new = tmp;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else	inctable[inc_pos] = 0;
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'M':	/* maximum identifier length */
 | 
					 | 
				
			||||||
		idfsize = txt2int(&text);
 | 
					 | 
				
			||||||
		if (*text)
 | 
					 | 
				
			||||||
			error("malformed -M option");
 | 
					 | 
				
			||||||
		if (idfsize > IDFSIZE) {
 | 
					 | 
				
			||||||
			warning("maximum identifier length is %d", IDFSIZE);
 | 
					 | 
				
			||||||
			idfsize = IDFSIZE;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (idfsize < 8) {
 | 
					 | 
				
			||||||
			warning("minimum identifier length is 8");
 | 
					 | 
				
			||||||
			idfsize = 8;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'U' :	/* -Uname :	undefine predefined	*/
 | 
					 | 
				
			||||||
		if (*text)	{
 | 
					 | 
				
			||||||
			register struct idf *idef = findidf(text);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (idef && idef->id_macro) {
 | 
					 | 
				
			||||||
				free_macro(idef->id_macro);
 | 
					 | 
				
			||||||
				idef->id_macro = (struct macro *) 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		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;
 | 
					 | 
				
			||||||
	register int ch;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	while (ch = **tp, ch >= '0' && ch <= '9')	{
 | 
					 | 
				
			||||||
		val = val * 10 + ch - '0';
 | 
					 | 
				
			||||||
		(*tp)++;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return val;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,264 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* PREPROCESSOR DRIVER */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <system.h>
 | 
					 | 
				
			||||||
#include "input.h"
 | 
					 | 
				
			||||||
#include "obufsize.h"
 | 
					 | 
				
			||||||
#include "LLlex.h"
 | 
					 | 
				
			||||||
#include "class.h"
 | 
					 | 
				
			||||||
#include "idf.h"
 | 
					 | 
				
			||||||
#include "idfsize.h"
 | 
					 | 
				
			||||||
#include "bits.h"
 | 
					 | 
				
			||||||
#include "line_prefix.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef DOBITS
 | 
					 | 
				
			||||||
char bits[128];
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char _obuf[OBUFSIZE];
 | 
					 | 
				
			||||||
extern int do_preprocess;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Xflush()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	if (do_preprocess) sys_write(STDOUT, _obuf, OBUFSIZE);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
preprocess(fn)
 | 
					 | 
				
			||||||
	char *fn;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
	register char *op = _obuf;
 | 
					 | 
				
			||||||
	register char *ob = &_obuf[OBUFSIZE];
 | 
					 | 
				
			||||||
	char Xbuf[256];
 | 
					 | 
				
			||||||
	int lineno = 0;
 | 
					 | 
				
			||||||
	extern char options[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define flush(X)	(! do_preprocess || sys_write(STDOUT,_obuf,X))
 | 
					 | 
				
			||||||
#define echo(ch) 	if (op == ob) { Xflush(); op = _obuf; } *op++ = (ch);
 | 
					 | 
				
			||||||
#define newline()	echo('\n')
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (! options['P']) {
 | 
					 | 
				
			||||||
		/* Generate a line directive communicating the
 | 
					 | 
				
			||||||
		   source filename
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		register char *p = Xbuf;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		sprint(p, "%s 1 \"%s\"\n",
 | 
					 | 
				
			||||||
			LINE_PREFIX,
 | 
					 | 
				
			||||||
			FileName);
 | 
					 | 
				
			||||||
		while (*p) {
 | 
					 | 
				
			||||||
			echo(*p++);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	for (;;) {
 | 
					 | 
				
			||||||
		LineNumber++;
 | 
					 | 
				
			||||||
		lineno++;
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
		while (c == '#') {
 | 
					 | 
				
			||||||
			domacro();
 | 
					 | 
				
			||||||
			lineno++;
 | 
					 | 
				
			||||||
			newline();
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (lineno != LineNumber || fn != FileName) {
 | 
					 | 
				
			||||||
			fn = FileName;
 | 
					 | 
				
			||||||
			lineno = LineNumber;
 | 
					 | 
				
			||||||
			if (! options['P']) {
 | 
					 | 
				
			||||||
				register char *p = Xbuf;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				sprint(p, "%s %d \"%s\"\n",
 | 
					 | 
				
			||||||
					LINE_PREFIX,
 | 
					 | 
				
			||||||
					LineNumber,
 | 
					 | 
				
			||||||
					FileName);
 | 
					 | 
				
			||||||
				while (*p) {
 | 
					 | 
				
			||||||
					echo(*p++);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		for (;;) {
 | 
					 | 
				
			||||||
			if (c & 0200)  {
 | 
					 | 
				
			||||||
				if (c == EOI) {
 | 
					 | 
				
			||||||
					newline();
 | 
					 | 
				
			||||||
					flush(op-_obuf);
 | 
					 | 
				
			||||||
					return;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				fatal("non-ascii character read");
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if (c == '/') {
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				if (c == '*') {
 | 
					 | 
				
			||||||
					NoUnstack++;
 | 
					 | 
				
			||||||
					if (options['C']) {
 | 
					 | 
				
			||||||
						echo('/');
 | 
					 | 
				
			||||||
						echo('*');
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					for (;;) {
 | 
					 | 
				
			||||||
						LoadChar(c);
 | 
					 | 
				
			||||||
						if (c == '\n') {
 | 
					 | 
				
			||||||
							++LineNumber;
 | 
					 | 
				
			||||||
							++lineno;
 | 
					 | 
				
			||||||
							echo(c);
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else if (c == EOI) {
 | 
					 | 
				
			||||||
							newline();
 | 
					 | 
				
			||||||
							flush(op - _obuf);
 | 
					 | 
				
			||||||
							return;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else if (c == '*') {
 | 
					 | 
				
			||||||
							if (options['C']) {
 | 
					 | 
				
			||||||
								echo(c);
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							LoadChar(c);
 | 
					 | 
				
			||||||
							if (c == '/') {
 | 
					 | 
				
			||||||
							   if (options['C']) {
 | 
					 | 
				
			||||||
								echo(c);
 | 
					 | 
				
			||||||
							   }
 | 
					 | 
				
			||||||
							   break;
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
							else {
 | 
					 | 
				
			||||||
								PushBack();
 | 
					 | 
				
			||||||
							}
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else if (options['C']) {
 | 
					 | 
				
			||||||
							echo(c);
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					NoUnstack--;
 | 
					 | 
				
			||||||
					LoadChar(c);
 | 
					 | 
				
			||||||
					continue;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				echo('/');
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			switch(class(c)) {
 | 
					 | 
				
			||||||
			case STNL:
 | 
					 | 
				
			||||||
				echo(c);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			case STSTR:
 | 
					 | 
				
			||||||
			case STCHAR: {
 | 
					 | 
				
			||||||
				register int stopc = c;
 | 
					 | 
				
			||||||
				int escaped;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
				do {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
					escaped = 0;
 | 
					 | 
				
			||||||
					echo(c);
 | 
					 | 
				
			||||||
					LoadChar(c);
 | 
					 | 
				
			||||||
					if (c == '\n') {
 | 
					 | 
				
			||||||
						break;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					else if (c == EOI) {
 | 
					 | 
				
			||||||
						newline();
 | 
					 | 
				
			||||||
						flush(op-_obuf);
 | 
					 | 
				
			||||||
						return;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					if (c == '\\') {
 | 
					 | 
				
			||||||
						echo(c);
 | 
					 | 
				
			||||||
						LoadChar(c);
 | 
					 | 
				
			||||||
						if (c == '\n') {
 | 
					 | 
				
			||||||
							++LineNumber;
 | 
					 | 
				
			||||||
							lineno++;
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						else escaped = 1;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				} while (escaped || c != stopc);
 | 
					 | 
				
			||||||
				echo(c);
 | 
					 | 
				
			||||||
				if (c == '\n')
 | 
					 | 
				
			||||||
					break;	/* Don't eat # */
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			case STNUM:
 | 
					 | 
				
			||||||
#define getdec(c)	do { echo(c); LoadChar(c);} while (is_dig(c))
 | 
					 | 
				
			||||||
#define gethex(c)	do { echo(c); LoadChar(c);} while (is_hex(c))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (c != '0') {
 | 
					 | 
				
			||||||
					getdec(c);
 | 
					 | 
				
			||||||
					if (c == '.') getdec(c);
 | 
					 | 
				
			||||||
					if (c == 'e') {
 | 
					 | 
				
			||||||
						echo(c);
 | 
					 | 
				
			||||||
						LoadChar(c);
 | 
					 | 
				
			||||||
						if (c == '+' || c == '-') {
 | 
					 | 
				
			||||||
							echo(c);
 | 
					 | 
				
			||||||
							LoadChar(c);
 | 
					 | 
				
			||||||
						}
 | 
					 | 
				
			||||||
						if (is_dig(c)) getdec(c);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				else {
 | 
					 | 
				
			||||||
					echo(c);
 | 
					 | 
				
			||||||
					LoadChar(c);
 | 
					 | 
				
			||||||
					if (c == 'x' || c == 'X') gethex(c);
 | 
					 | 
				
			||||||
					else if (is_dig(c)) getdec(c);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
			    case STIDF: {
 | 
					 | 
				
			||||||
				extern int idfsize;		/* ??? */
 | 
					 | 
				
			||||||
				char buf[IDFSIZE + 1];
 | 
					 | 
				
			||||||
				register char *tg = &buf[0];
 | 
					 | 
				
			||||||
				register char *maxpos = &buf[idfsize];
 | 
					 | 
				
			||||||
				register struct idf *idef;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define tstmac(bx)	if (!(bits[c] & bx)) goto nomac
 | 
					 | 
				
			||||||
#define cpy		if (Unstacked) EnableMacros(); *tg++ = c
 | 
					 | 
				
			||||||
#define load		LoadChar(c); if (!in_idf(c)) goto endidf
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef DOBITS
 | 
					 | 
				
			||||||
				cpy; tstmac(bit0); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit1); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit2); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit3); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit4); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit5); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit6); load;
 | 
					 | 
				
			||||||
				cpy; tstmac(bit7); load;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				for(;;) {
 | 
					 | 
				
			||||||
					if (tg < maxpos) {
 | 
					 | 
				
			||||||
						cpy;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					else break;
 | 
					 | 
				
			||||||
					load;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			endidf:
 | 
					 | 
				
			||||||
				PushBack();
 | 
					 | 
				
			||||||
				*tg = '\0';	/* mark the end of the identifier */
 | 
					 | 
				
			||||||
				idef = findidf(buf);
 | 
					 | 
				
			||||||
				if (idef && idef->id_macro) {
 | 
					 | 
				
			||||||
					do {
 | 
					 | 
				
			||||||
						LoadChar(c);
 | 
					 | 
				
			||||||
					} while  (in_idf(c));
 | 
					 | 
				
			||||||
					PushBack();
 | 
					 | 
				
			||||||
					if (replace(idef)) {
 | 
					 | 
				
			||||||
						LoadChar(c);
 | 
					 | 
				
			||||||
						continue;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			nomac:
 | 
					 | 
				
			||||||
				*tg = 0;
 | 
					 | 
				
			||||||
				tg = buf;
 | 
					 | 
				
			||||||
				while (*tg) {
 | 
					 | 
				
			||||||
					echo(*tg++);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				while (in_idf(c)) {
 | 
					 | 
				
			||||||
					echo(c);
 | 
					 | 
				
			||||||
					LoadChar(c);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			    default:
 | 
					 | 
				
			||||||
			    	echo(c);
 | 
					 | 
				
			||||||
			    	LoadChar(c);
 | 
					 | 
				
			||||||
			    	continue;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	/*NOTREACHED*/
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,344 +0,0 @@
 | 
				
			||||||
# $Id$
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#PARAMS		do not remove this line!
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
SRC_DIR = $(SRC_HOME)/util/cpp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
MODULES=$(TARGET_HOME)/modules
 | 
					 | 
				
			||||||
UMODULES=$(UTIL_HOME)/modules
 | 
					 | 
				
			||||||
MODULESLIB=$(MODULES)/lib
 | 
					 | 
				
			||||||
UMODULESLIB=$(UMODULES)/lib
 | 
					 | 
				
			||||||
BIN=$(TARGET_HOME)/lib.bin
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Libraries
 | 
					 | 
				
			||||||
SYSLIB = $(MODULESLIB)/libsystem.$(LIBSUF)
 | 
					 | 
				
			||||||
STRLIB = $(MODULESLIB)/libstring.$(LIBSUF)
 | 
					 | 
				
			||||||
PRTLIB = $(MODULESLIB)/libprint.$(LIBSUF)
 | 
					 | 
				
			||||||
ALLOCLIB = $(MODULESLIB)/liballoc.$(LIBSUF)
 | 
					 | 
				
			||||||
ASSERTLIB = $(MODULESLIB)/libassert.$(LIBSUF)
 | 
					 | 
				
			||||||
MALLOC = $(MODULESLIB)/malloc.$(SUF)
 | 
					 | 
				
			||||||
LIBS = $(PRTLIB) $(STRLIB) $(ALLOCLIB) $(MALLOC) $(ASSERTLIB) $(SYSLIB)
 | 
					 | 
				
			||||||
LINTLIBS = \
 | 
					 | 
				
			||||||
	$(UMODULESLIB)/$(LINTPREF)print.$(LINTSUF) \
 | 
					 | 
				
			||||||
	$(UMODULESLIB)/$(LINTPREF)string.$(LINTSUF) \
 | 
					 | 
				
			||||||
	$(UMODULESLIB)/$(LINTPREF)alloc.$(LINTSUF) \
 | 
					 | 
				
			||||||
	$(UMODULESLIB)/$(LINTPREF)assert.$(LINTSUF) \
 | 
					 | 
				
			||||||
	$(UMODULESLIB)/$(LINTPREF)system.$(LINTSUF)
 | 
					 | 
				
			||||||
INCLUDES = -I$(MODULES)/h -I$(MODULES)/pkg -I. -I$(SRC_DIR)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
CFLAGS = $(INCLUDES) $(COPTIONS)
 | 
					 | 
				
			||||||
LDFLAGS = $(LDOPTIONS)
 | 
					 | 
				
			||||||
LINTFLAGS = $(INCLUDES) $(LINTOPTIONS)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Where to install the preprocessor
 | 
					 | 
				
			||||||
CEMPP = $(BIN)/cpp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Grammar files and their objects
 | 
					 | 
				
			||||||
LSRC =	tokenfile.g $(SRC_DIR)/expression.g
 | 
					 | 
				
			||||||
LCSRC = tokenfile.c expression.c Lpars.c
 | 
					 | 
				
			||||||
LOBJ =	tokenfile.$(SUF) expression.$(SUF) Lpars.$(SUF)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Objects of hand-written C files
 | 
					 | 
				
			||||||
CSRC =	$(SRC_DIR)/LLlex.c $(SRC_DIR)/LLmessage.c $(SRC_DIR)/ch7bin.c  \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/ch7mon.c $(SRC_DIR)/domacro.c $(SRC_DIR)/error.c \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/idf.c $(SRC_DIR)/init.c $(SRC_DIR)/input.c \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/main.c $(SRC_DIR)/options.c \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/preprocess.c $(SRC_DIR)/replace.c $(SRC_DIR)/scan.c \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/skip.c $(SRC_DIR)/tokenname.c $(SRC_DIR)/next.c \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/expr.c
 | 
					 | 
				
			||||||
COBJ =	LLlex.$(SUF) LLmessage.$(SUF) ch7bin.$(SUF) ch7mon.$(SUF) \
 | 
					 | 
				
			||||||
	domacro.$(SUF) error.$(SUF) idf.$(SUF) init.$(SUF) input.$(SUF) \
 | 
					 | 
				
			||||||
	main.$(SUF) options.$(SUF) \
 | 
					 | 
				
			||||||
	preprocess.$(SUF) replace.$(SUF) scan.$(SUF) skip.$(SUF) \
 | 
					 | 
				
			||||||
	tokenname.$(SUF) next.$(SUF) expr.$(SUF)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRFILES = $(SRC_DIR)/proto.make $(SRC_DIR)/Parameters \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/make.hfiles $(SRC_DIR)/make.tokcase $(SRC_DIR)/make.tokfile \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/LLlex.h $(SRC_DIR)/bits.h $(SRC_DIR)/file_info.h \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/idf.h $(SRC_DIR)/input.h $(SRC_DIR)/interface.h \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/macro.h \
 | 
					 | 
				
			||||||
	$(SRC_DIR)/class.h $(SRC_DIR)/char.tab $(SRC_DIR)/expression.g $(CSRC)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Objects of other generated C files
 | 
					 | 
				
			||||||
GOBJ =	char.$(SUF) symbol2str.$(SUF)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# generated source files
 | 
					 | 
				
			||||||
GSRC =	char.c symbol2str.c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# .h files generated by `make hfiles'; PLEASE KEEP THIS UP-TO-DATE!
 | 
					 | 
				
			||||||
GHSRC =	errout.h idfsize.h ifdepth.h lapbuf.h \
 | 
					 | 
				
			||||||
	nparams.h numsize.h obufsize.h \
 | 
					 | 
				
			||||||
	parbufsize.h pathlength.h strsize.h textsize.h \
 | 
					 | 
				
			||||||
	botch_free.h debug.h inputtype.h dobits.h line_prefix.h
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Other generated files, for 'make clean' only
 | 
					 | 
				
			||||||
GENERATED = tokenfile.g Lpars.h LLfiles LL.output lint.out \
 | 
					 | 
				
			||||||
	Xref hfiles cfiles
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
all:	cc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cc:	hfiles LLfiles
 | 
					 | 
				
			||||||
	make cpp
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
hfiles: Parameters char.c
 | 
					 | 
				
			||||||
	$(SRC_DIR)/make.hfiles Parameters
 | 
					 | 
				
			||||||
	@touch hfiles
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
Parameters:	$(SRC_DIR)/Parameters
 | 
					 | 
				
			||||||
	cp $(SRC_DIR)/Parameters Parameters
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char.c:	$(SRC_DIR)/char.tab
 | 
					 | 
				
			||||||
	tabgen -f$(SRC_DIR)/char.tab > char.c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
LLfiles: $(LSRC)
 | 
					 | 
				
			||||||
	LLgen $(LLGENOPTIONS) $(LSRC)
 | 
					 | 
				
			||||||
	@touch LLfiles
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
tokenfile.g:	$(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile
 | 
					 | 
				
			||||||
	<$(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokfile >tokenfile.g
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
symbol2str.c:	$(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase
 | 
					 | 
				
			||||||
	<$(SRC_DIR)/tokenname.c $(SRC_DIR)/make.tokcase >symbol2str.c
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Objects needed for 'cpp'
 | 
					 | 
				
			||||||
OBJ =	$(COBJ) $(LOBJ) $(GOBJ)
 | 
					 | 
				
			||||||
SRC =	$(CSRC) $(LCSRC) $(GSRC)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cpp:	$(OBJ)
 | 
					 | 
				
			||||||
	$(CC) $(LDFLAGS) $(OBJ) $(LIBS) -o cpp 
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cfiles: hfiles LLfiles $(GSRC)
 | 
					 | 
				
			||||||
	@touch cfiles
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
install: all
 | 
					 | 
				
			||||||
	cp cpp $(CEMPP)
 | 
					 | 
				
			||||||
	if [ $(DO_MACHINE_INDEP) = y ] ; \
 | 
					 | 
				
			||||||
	then	mk_manpage $(SRC_DIR)/cpp.6 $(TARGET_HOME) ; \
 | 
					 | 
				
			||||||
	fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cmp:	all
 | 
					 | 
				
			||||||
	-cmp cpp $(CEMPP)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pr: 
 | 
					 | 
				
			||||||
	@pr $(PRFILES)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
opr:
 | 
					 | 
				
			||||||
	make pr | opr
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
tags:	cfiles
 | 
					 | 
				
			||||||
	ctags $(SRC)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
depend:	cfiles
 | 
					 | 
				
			||||||
	rm_deps Makefile >Makefile.new
 | 
					 | 
				
			||||||
	for i in $(SRC) ; do \
 | 
					 | 
				
			||||||
		echo "`basename $$i .c`.$$(SUF):	$$i" >> Makefile.new ; \
 | 
					 | 
				
			||||||
		echo '	$$(CC) -c $$(CFLAGS)' $$i >> Makefile.new ; \
 | 
					 | 
				
			||||||
		$(UTIL_HOME)/lib.bin/cpp -d $(INCLUDES) $$i | sed "s/^/`basename $$i .c`.$$(SUF):	/" >> Makefile.new ; \
 | 
					 | 
				
			||||||
	done
 | 
					 | 
				
			||||||
	mv Makefile Makefile.old
 | 
					 | 
				
			||||||
	mv Makefile.new Makefile
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
lint:	cfiles
 | 
					 | 
				
			||||||
	$(LINT) $(LINTFLAGS) $(INCLUDES) $(SRC) $(LINTLIBS)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
clean:
 | 
					 | 
				
			||||||
	rm -f $(LCSRC) $(OBJ) $(GENERATED) $(GSRC) $(GHSRC) cpp Out
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# do not remove the next line. It is used for generating dependencies.
 | 
					 | 
				
			||||||
#DEPENDENCIES
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/LLlex.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/LLlex.c
 | 
					 | 
				
			||||||
LLlex.$(SUF):	./dobits.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/bits.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
LLlex.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	./strsize.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	./numsize.h
 | 
					 | 
				
			||||||
LLlex.$(SUF):	./idfsize.h
 | 
					 | 
				
			||||||
LLmessage.$(SUF):	$(SRC_DIR)/LLmessage.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/LLmessage.c
 | 
					 | 
				
			||||||
LLmessage.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
LLmessage.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
LLmessage.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
LLmessage.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
ch7bin.$(SUF):	$(SRC_DIR)/ch7bin.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/ch7bin.c
 | 
					 | 
				
			||||||
ch7bin.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
ch7bin.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
ch7mon.$(SUF):	$(SRC_DIR)/ch7mon.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/ch7mon.c
 | 
					 | 
				
			||||||
ch7mon.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
ch7mon.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/domacro.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/domacro.c
 | 
					 | 
				
			||||||
domacro.$(SUF):	./dobits.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/bits.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/macro.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(TARGET_HOME)/modules/h/assert.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./idfsize.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./textsize.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./parbufsize.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./nparams.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./botch_free.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./ifdepth.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
domacro.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./debug.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
domacro.$(SUF):	$(SRC_DIR)/interface.h
 | 
					 | 
				
			||||||
error.$(SUF):	$(SRC_DIR)/error.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/error.c
 | 
					 | 
				
			||||||
error.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
error.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
error.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
error.$(SUF):	./errout.h
 | 
					 | 
				
			||||||
error.$(SUF):	$(TARGET_HOME)/modules/h/system.h
 | 
					 | 
				
			||||||
idf.$(SUF):	$(SRC_DIR)/idf.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/idf.c
 | 
					 | 
				
			||||||
idf.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
idf.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.body
 | 
					 | 
				
			||||||
idf.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
idf.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
init.$(SUF):	$(SRC_DIR)/init.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/init.c
 | 
					 | 
				
			||||||
init.$(SUF):	$(SRC_DIR)/interface.h
 | 
					 | 
				
			||||||
init.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
init.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
init.$(SUF):	$(SRC_DIR)/macro.h
 | 
					 | 
				
			||||||
init.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
init.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
init.$(SUF):	$(TARGET_HOME)/modules/h/system.h
 | 
					 | 
				
			||||||
input.$(SUF):	$(SRC_DIR)/input.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/input.c
 | 
					 | 
				
			||||||
input.$(SUF):	$(TARGET_HOME)/modules/h/system.h
 | 
					 | 
				
			||||||
input.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
input.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.body
 | 
					 | 
				
			||||||
input.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
input.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
input.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
input.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(SRC_DIR)/main.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/main.c
 | 
					 | 
				
			||||||
main.$(SUF):	$(SRC_DIR)/macro.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
main.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
main.$(SUF):	./idfsize.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(TARGET_HOME)/modules/h/system.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(TARGET_HOME)/modules/h/assert.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
main.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
options.$(SUF):	$(SRC_DIR)/options.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/options.c
 | 
					 | 
				
			||||||
options.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
options.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
options.$(SUF):	$(SRC_DIR)/macro.h
 | 
					 | 
				
			||||||
options.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
options.$(SUF):	./idfsize.h
 | 
					 | 
				
			||||||
options.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/preprocess.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/preprocess.c
 | 
					 | 
				
			||||||
preprocess.$(SUF):	./line_prefix.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	./dobits.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/bits.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	./idfsize.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	./obufsize.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
preprocess.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
preprocess.$(SUF):	$(TARGET_HOME)/modules/h/system.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/replace.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/replace.c
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/interface.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/macro.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
replace.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
replace.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(TARGET_HOME)/modules/h/assert.h
 | 
					 | 
				
			||||||
replace.$(SUF):	$(TARGET_HOME)/modules/h/alloc.h
 | 
					 | 
				
			||||||
replace.$(SUF):	./textsize.h
 | 
					 | 
				
			||||||
replace.$(SUF):	./pathlength.h
 | 
					 | 
				
			||||||
replace.$(SUF):	./debug.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/scan.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/scan.c
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/interface.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/macro.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
scan.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
scan.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
scan.$(SUF):	./nparams.h
 | 
					 | 
				
			||||||
scan.$(SUF):	./lapbuf.h
 | 
					 | 
				
			||||||
skip.$(SUF):	$(SRC_DIR)/skip.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/skip.c
 | 
					 | 
				
			||||||
skip.$(SUF):	$(TARGET_HOME)/modules/pkg/inp_pkg.spec
 | 
					 | 
				
			||||||
skip.$(SUF):	./inputtype.h
 | 
					 | 
				
			||||||
skip.$(SUF):	$(SRC_DIR)/input.h
 | 
					 | 
				
			||||||
skip.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
skip.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
skip.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
skip.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
tokenname.$(SUF):	$(SRC_DIR)/tokenname.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/tokenname.c
 | 
					 | 
				
			||||||
tokenname.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
tokenname.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
tokenname.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
tokenname.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
tokenname.$(SUF):	$(TARGET_HOME)/modules/pkg/idf_pkg.spec
 | 
					 | 
				
			||||||
tokenname.$(SUF):	$(SRC_DIR)/idf.h
 | 
					 | 
				
			||||||
next.$(SUF):	$(SRC_DIR)/next.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/next.c
 | 
					 | 
				
			||||||
next.$(SUF):	./debug.h
 | 
					 | 
				
			||||||
expr.$(SUF):	$(SRC_DIR)/expr.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) $(SRC_DIR)/expr.c
 | 
					 | 
				
			||||||
expr.$(SUF):	./Lpars.h
 | 
					 | 
				
			||||||
tokenfile.$(SUF):	tokenfile.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) tokenfile.c
 | 
					 | 
				
			||||||
tokenfile.$(SUF):	Lpars.h
 | 
					 | 
				
			||||||
expression.$(SUF):	expression.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) expression.c
 | 
					 | 
				
			||||||
expression.$(SUF):	$(SRC_DIR)/file_info.h
 | 
					 | 
				
			||||||
expression.$(SUF):	$(TARGET_HOME)/modules/h/em_arith.h
 | 
					 | 
				
			||||||
expression.$(SUF):	$(SRC_DIR)/LLlex.h
 | 
					 | 
				
			||||||
expression.$(SUF):	Lpars.h
 | 
					 | 
				
			||||||
Lpars.$(SUF):	Lpars.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) Lpars.c
 | 
					 | 
				
			||||||
Lpars.$(SUF):	Lpars.h
 | 
					 | 
				
			||||||
char.$(SUF):	char.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) char.c
 | 
					 | 
				
			||||||
char.$(SUF):	$(SRC_DIR)/class.h
 | 
					 | 
				
			||||||
symbol2str.$(SUF):	symbol2str.c
 | 
					 | 
				
			||||||
	$(CC) -c $(CFLAGS) symbol2str.c
 | 
					 | 
				
			||||||
symbol2str.$(SUF):	Lpars.h
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,243 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* PREPROCESSOR: MACRO-TEXT REPLACEMENT ROUTINES */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <stdlib.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					 | 
				
			||||||
#include	"debug.h"	/* UF */
 | 
					 | 
				
			||||||
#include	"pathlength.h"	/* UF */
 | 
					 | 
				
			||||||
#include	"textsize.h"	/* UF */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	<alloc.h>
 | 
					 | 
				
			||||||
#include	<assert.h>
 | 
					 | 
				
			||||||
#include	"idf.h"
 | 
					 | 
				
			||||||
#include	"input.h"
 | 
					 | 
				
			||||||
#include	"macro.h"
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	"class.h"
 | 
					 | 
				
			||||||
#include	"interface.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char *long2str();
 | 
					 | 
				
			||||||
extern int InputLevel;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE struct mlist *ReplList;	/* list of currently active macros */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXPORT int
 | 
					 | 
				
			||||||
replace(idef)
 | 
					 | 
				
			||||||
	register struct idf *idef;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	replace() is called by the lexical analyzer to perform
 | 
					 | 
				
			||||||
		macro replacement.  "idef" is the description of the
 | 
					 | 
				
			||||||
		identifier which leads to the replacement.  If the
 | 
					 | 
				
			||||||
		optional actual parameters of the macro are OK, the text
 | 
					 | 
				
			||||||
		of the macro is prepared to serve as an input buffer,
 | 
					 | 
				
			||||||
		which is pushed onto the input stack.
 | 
					 | 
				
			||||||
		replace() returns 1 if the replacement succeeded and 0 if
 | 
					 | 
				
			||||||
		some error has occurred.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register struct macro *mac = idef->id_macro;
 | 
					 | 
				
			||||||
	register char c;
 | 
					 | 
				
			||||||
	char **actpars, **getactuals();
 | 
					 | 
				
			||||||
	char *reptext, *macro2buffer();
 | 
					 | 
				
			||||||
	register struct mlist *repl;
 | 
					 | 
				
			||||||
	int size;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (mac->mc_flag & NOREPLACE) {
 | 
					 | 
				
			||||||
		warning("macro %s is recursive", idef->id_text);
 | 
					 | 
				
			||||||
		return 0;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	if (mac->mc_nps != -1) {	/* with parameter list	*/
 | 
					 | 
				
			||||||
		if (mac->mc_flag & FUNC) {
 | 
					 | 
				
			||||||
					/* must be "defined".
 | 
					 | 
				
			||||||
					   Unfortunately, the next assertion
 | 
					 | 
				
			||||||
					   will not compile ...
 | 
					 | 
				
			||||||
			assert( ! strcmp("defined", idef->id_text));
 | 
					 | 
				
			||||||
					*/
 | 
					 | 
				
			||||||
			if (! AccDefined)
 | 
					 | 
				
			||||||
				return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (++mac->mc_count > 100) {
 | 
					 | 
				
			||||||
			/* 100 must be some number in parameters.h */
 | 
					 | 
				
			||||||
			warning("macro %s is assumed recursive",
 | 
					 | 
				
			||||||
				    idef->id_text);
 | 
					 | 
				
			||||||
			return 0;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
		c = skipspaces(c,! (mac->mc_flag & FUNC));
 | 
					 | 
				
			||||||
		if (c != '(') {		/* no replacement if no ()	*/
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			if (! (mac->mc_flag & FUNC)) {
 | 
					 | 
				
			||||||
				warning("macro %s needs arguments",
 | 
					 | 
				
			||||||
					idef->id_text);
 | 
					 | 
				
			||||||
				return 0;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (mac->mc_flag & FUNC) {
 | 
					 | 
				
			||||||
			struct idf *param;
 | 
					 | 
				
			||||||
			char *nam;
 | 
					 | 
				
			||||||
			extern char *GetIdentifier();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			UnknownIdIsZero = 0;
 | 
					 | 
				
			||||||
			nam = GetIdentifier();
 | 
					 | 
				
			||||||
			if (nam) {
 | 
					 | 
				
			||||||
				param = findidf(nam);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else	param = 0;
 | 
					 | 
				
			||||||
			UnknownIdIsZero = 1;
 | 
					 | 
				
			||||||
			if (c == '(') {
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				c = skipspaces(c, 0);
 | 
					 | 
				
			||||||
				if (c != ')') error(") missing");
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if (! nam) {
 | 
					 | 
				
			||||||
				error("identifier missing");
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			repl = new_mlist();
 | 
					 | 
				
			||||||
			if (param && param->id_macro) 
 | 
					 | 
				
			||||||
				reptext = "1 ";
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				reptext = "0 ";
 | 
					 | 
				
			||||||
			InsertText(reptext, 2);
 | 
					 | 
				
			||||||
			InputLevel++;
 | 
					 | 
				
			||||||
			repl->m_level = InputLevel;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			repl->next = ReplList;
 | 
					 | 
				
			||||||
			ReplList = repl;
 | 
					 | 
				
			||||||
			repl->m_mac = mac;
 | 
					 | 
				
			||||||
			if (nam) free(nam);
 | 
					 | 
				
			||||||
			return 1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		actpars = getactuals(idef);	/* get act.param. list	*/
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	repl = new_mlist();
 | 
					 | 
				
			||||||
	repl->m_mac = mac;
 | 
					 | 
				
			||||||
	if (mac->mc_flag & FUNC) /* this macro leads to special action	*/
 | 
					 | 
				
			||||||
		macro_func(idef);
 | 
					 | 
				
			||||||
	if (mac->mc_nps <= 0) {
 | 
					 | 
				
			||||||
		reptext = mac->mc_text;
 | 
					 | 
				
			||||||
		size = mac->mc_length;
 | 
					 | 
				
			||||||
		mac->mc_flag |= NOREPLACE;	/* a file called __FILE__ ??? */
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	else {
 | 
					 | 
				
			||||||
		reptext = macro2buffer(idef, actpars, &size); /* create input buffer */
 | 
					 | 
				
			||||||
		repl->m_repl = reptext;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	InsertText(reptext, size);
 | 
					 | 
				
			||||||
	InputLevel++;
 | 
					 | 
				
			||||||
	repl->m_level = InputLevel;
 | 
					 | 
				
			||||||
	repl->next = ReplList;
 | 
					 | 
				
			||||||
	ReplList = repl;
 | 
					 | 
				
			||||||
	return 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
char FilNamBuf[PATHLENGTH];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
macro_func(idef)
 | 
					 | 
				
			||||||
	register struct idf *idef;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	macro_func() performs the special actions needed with some
 | 
					 | 
				
			||||||
		macros.  These macros are __FILE__ and __LINE__ which
 | 
					 | 
				
			||||||
		replacement texts must be evaluated at the time they are
 | 
					 | 
				
			||||||
		used.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register struct macro *mac = idef->id_macro;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	switch (idef->id_text[2]) { /* This switch is very blunt... */
 | 
					 | 
				
			||||||
	case 'F' :			/* __FILE__	*/
 | 
					 | 
				
			||||||
		mac->mc_length = strlen(FileName) + 2;
 | 
					 | 
				
			||||||
		mac->mc_text = FilNamBuf;
 | 
					 | 
				
			||||||
		mac->mc_text[0] = '"';
 | 
					 | 
				
			||||||
		strcpy(&(mac->mc_text[1]), FileName);
 | 
					 | 
				
			||||||
		strcat(mac->mc_text, "\"");
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	case 'L' :			/* __LINE__	*/
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		mac->mc_text = long2str((long) LineNumber, 10);
 | 
					 | 
				
			||||||
		mac->mc_length = strlen(mac->mc_text);
 | 
					 | 
				
			||||||
		break;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	default :
 | 
					 | 
				
			||||||
		crash("(macro_func)");
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE char *
 | 
					 | 
				
			||||||
macro2buffer(idef, actpars, siztext)
 | 
					 | 
				
			||||||
	struct idf *idef;
 | 
					 | 
				
			||||||
	char **actpars;
 | 
					 | 
				
			||||||
	int *siztext;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	Macro2buffer() turns the macro replacement text, as it is
 | 
					 | 
				
			||||||
		stored, into an input buffer, while each occurrence of the
 | 
					 | 
				
			||||||
		non-ascii formal parameter mark is replaced by its
 | 
					 | 
				
			||||||
		corresponding actual parameter specified in the actual
 | 
					 | 
				
			||||||
		parameter list actpars.  A pointer to the beginning of the
 | 
					 | 
				
			||||||
		constructed text is returned, while *siztext is filled
 | 
					 | 
				
			||||||
		with its length.
 | 
					 | 
				
			||||||
		If there are no parameters, this function behaves
 | 
					 | 
				
			||||||
		the same as strcpy().
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register unsigned int size = idef->id_macro->mc_length + ITEXTSIZE;
 | 
					 | 
				
			||||||
	register char *text = Malloc(size);
 | 
					 | 
				
			||||||
	register int pos = 0;
 | 
					 | 
				
			||||||
	register char *ptr = idef->id_macro->mc_text;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	while (*ptr) {
 | 
					 | 
				
			||||||
		if (*ptr & FORMALP) {	/* non-asc formal param. mark	*/
 | 
					 | 
				
			||||||
			register int n = *ptr++ & 0177;
 | 
					 | 
				
			||||||
			register char *p;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			assert(n != 0);
 | 
					 | 
				
			||||||
			/*	copy the text of the actual parameter
 | 
					 | 
				
			||||||
				into the replacement text
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
			for (p = actpars[n - 1]; *p; p++) {
 | 
					 | 
				
			||||||
				text[pos++] = *p;
 | 
					 | 
				
			||||||
				if (pos == size)
 | 
					 | 
				
			||||||
					text = Realloc(text, size <<= 1);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else {
 | 
					 | 
				
			||||||
			text[pos++] = *ptr++;
 | 
					 | 
				
			||||||
			if (pos == size)
 | 
					 | 
				
			||||||
				text = Realloc(text, size <<= 1);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	text[pos] = '\0';
 | 
					 | 
				
			||||||
	*siztext = pos;
 | 
					 | 
				
			||||||
	return Realloc(text, pos+1);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXPORT
 | 
					 | 
				
			||||||
DoUnstack()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	Unstacked = 1;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
EXPORT
 | 
					 | 
				
			||||||
EnableMacros()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	register struct mlist *p = ReplList, *prev = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	assert(Unstacked > 0);
 | 
					 | 
				
			||||||
	while (p) {
 | 
					 | 
				
			||||||
		struct mlist *nxt = p->next;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (p->m_level > InputLevel) {
 | 
					 | 
				
			||||||
			p->m_mac->mc_flag &= ~NOREPLACE;
 | 
					 | 
				
			||||||
			if (p->m_mac->mc_count) p->m_mac->mc_count--;
 | 
					 | 
				
			||||||
			if (p->m_repl) free(p->m_repl);
 | 
					 | 
				
			||||||
			if (! prev) ReplList = nxt;
 | 
					 | 
				
			||||||
			else prev->next = nxt;
 | 
					 | 
				
			||||||
			free_mlist(p);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else prev = p;
 | 
					 | 
				
			||||||
		p = nxt;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	Unstacked = 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										237
									
								
								util/cpp/scan.c
									
										
									
									
									
								
							
							
						
						
									
										237
									
								
								util/cpp/scan.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,237 +0,0 @@
 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* PREPROCESSOR: SCANNER FOR THE ACTUAL PARAMETERS OF MACROS	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	This file contains the function getactuals() which scans an actual
 | 
					 | 
				
			||||||
	parameter list and splits it up into a list of strings, each one
 | 
					 | 
				
			||||||
	representing an actual parameter.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"lapbuf.h"	/* UF */
 | 
					 | 
				
			||||||
#include	"nparams.h"	/* UF */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"input.h"
 | 
					 | 
				
			||||||
#include	"class.h"
 | 
					 | 
				
			||||||
#include	"idf.h"
 | 
					 | 
				
			||||||
#include	"macro.h"
 | 
					 | 
				
			||||||
#include	"interface.h"
 | 
					 | 
				
			||||||
#include	"file_info.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	EOS		'\0'
 | 
					 | 
				
			||||||
#define	overflow()	(fatal("actual parameter buffer overflow"))
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE char apbuf[LAPBUF]; /* temporary storage for actual parameters	*/
 | 
					 | 
				
			||||||
PRIVATE char *actparams[NPARAMS]; /* pointers to the text of the actuals */
 | 
					 | 
				
			||||||
PRIVATE char *aptr;	/* pointer to last inserted character in apbuf	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#define	copy(ch)	((aptr < &apbuf[LAPBUF]) ? (*aptr++ = ch) : overflow())
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE int nr_of_params;	/* number of actuals read until now	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE char **
 | 
					 | 
				
			||||||
getactuals(idef)
 | 
					 | 
				
			||||||
	struct idf *idef;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	getactuals() collects the actual parameters and turns them
 | 
					 | 
				
			||||||
		into a list of strings, a pointer to which is returned.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register acnt = idef->id_macro->mc_nps;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	nr_of_params = 0;
 | 
					 | 
				
			||||||
	actparams[0] = aptr = &apbuf[0];
 | 
					 | 
				
			||||||
	copyact('(', ')', 0);	/* read the actual parameters	*/
 | 
					 | 
				
			||||||
	copy(EOS);		/* mark the end of it all	*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (!nr_of_params++)	{		/* 0 or 1 parameter	*/
 | 
					 | 
				
			||||||
		/* there could be a ( <spaces, comment, ...> )
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		register char *p = actparams[0];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		while ((class(*p) == STSKIP) || (*p == '\n')) {
 | 
					 | 
				
			||||||
				++p;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!*p) {	/* the case () : 0 parameters	*/
 | 
					 | 
				
			||||||
			nr_of_params--;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (nr_of_params != acnt)	{
 | 
					 | 
				
			||||||
		/*	argument mismatch: too many or too few
 | 
					 | 
				
			||||||
			actual parameters.
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		warning("argument mismatch, %s", idef->id_text);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		while (nr_of_params < acnt) {
 | 
					 | 
				
			||||||
			/*	too few paraeters: remaining actuals are ""
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
			actparams[nr_of_params] = "";
 | 
					 | 
				
			||||||
			nr_of_params++;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return actparams;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
PRIVATE
 | 
					 | 
				
			||||||
copyact(ch1, ch2, level)
 | 
					 | 
				
			||||||
	char ch1, ch2;
 | 
					 | 
				
			||||||
	int level;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	copyact() is taken from Ceriel Jacobs' LLgen, with
 | 
					 | 
				
			||||||
		permission.  Its task is to build a list of actuals
 | 
					 | 
				
			||||||
		parameters, which list is surrounded by '(' and ')' and in
 | 
					 | 
				
			||||||
		which the parameters are separated by ',' if there are
 | 
					 | 
				
			||||||
		more than 1. The balancing of '(',')' and '[',']' and
 | 
					 | 
				
			||||||
		'{','}' is taken care of by calling this function
 | 
					 | 
				
			||||||
		recursively. At each level, copyact() reads the input,
 | 
					 | 
				
			||||||
		upto the corresponding closing bracket.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		Opening bracket is ch1, closing bracket is ch2. If
 | 
					 | 
				
			||||||
		level != 0, copy opening and closing parameters too.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register int ch;		/* Current char */
 | 
					 | 
				
			||||||
	register int match;		/* used to read strings */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (level) {
 | 
					 | 
				
			||||||
		copy(ch1);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (;;)	{
 | 
					 | 
				
			||||||
		LoadChar(ch);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (ch == ch2)	{
 | 
					 | 
				
			||||||
			if (level) {
 | 
					 | 
				
			||||||
				copy(ch);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		switch(ch)	{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __MATCHING_PAR__
 | 
					 | 
				
			||||||
		case ')':
 | 
					 | 
				
			||||||
		case '}':
 | 
					 | 
				
			||||||
		case ']':
 | 
					 | 
				
			||||||
			error("unbalanced parenthesis");
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
#endif /* __MATCHING_PAR__ */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case '(':
 | 
					 | 
				
			||||||
			copyact('(', ')', level+1);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef __MATCHING_PAR__
 | 
					 | 
				
			||||||
		case '{':
 | 
					 | 
				
			||||||
			/*	example:
 | 
					 | 
				
			||||||
					#define declare(v, t)	t v
 | 
					 | 
				
			||||||
					declare(v, union{int i, j; float r;});
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
			copyact('{', '}', level+1);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case '[':
 | 
					 | 
				
			||||||
			copyact('[', ']', level+1);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
#endif /* __MATCHING_PAR__ */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case '\n':
 | 
					 | 
				
			||||||
			LineNumber++;
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
			while (ch == '#')	{
 | 
					 | 
				
			||||||
				/*	This piece of code needs some
 | 
					 | 
				
			||||||
					explanation: consider the call of
 | 
					 | 
				
			||||||
					the macro defined as:
 | 
					 | 
				
			||||||
						#define sum(b,c) (b + c)
 | 
					 | 
				
			||||||
					in the following form:
 | 
					 | 
				
			||||||
						sum(
 | 
					 | 
				
			||||||
						#include my_phone_number
 | 
					 | 
				
			||||||
						,2)
 | 
					 | 
				
			||||||
					in which case the include must be
 | 
					 | 
				
			||||||
					interpreted as such.
 | 
					 | 
				
			||||||
				*/
 | 
					 | 
				
			||||||
				domacro();	/* has read nl, vt or ff */
 | 
					 | 
				
			||||||
				LoadChar(ch);
 | 
					 | 
				
			||||||
				/* Loop, for another control line */
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			copy(' ');
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case '/':
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (ch == '*')	{	/* skip comment	*/
 | 
					 | 
				
			||||||
				skipcomment();
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			PushBack();
 | 
					 | 
				
			||||||
			copy('/');
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case ',':
 | 
					 | 
				
			||||||
			if (!level)	{
 | 
					 | 
				
			||||||
				/* next parameter encountered */
 | 
					 | 
				
			||||||
				copy(EOS);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (++nr_of_params >= NPARAMS) {
 | 
					 | 
				
			||||||
					fatal("(getact) too many actuals");
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				actparams[nr_of_params] = aptr;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else	{
 | 
					 | 
				
			||||||
				copy(ch);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case '\'':
 | 
					 | 
				
			||||||
		case '"' :
 | 
					 | 
				
			||||||
			/*	watch out for brackets in strings, they do
 | 
					 | 
				
			||||||
				not count !
 | 
					 | 
				
			||||||
			*/
 | 
					 | 
				
			||||||
			match = ch;
 | 
					 | 
				
			||||||
			copy(ch);
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
			while (ch != EOI)	{
 | 
					 | 
				
			||||||
				if (ch == match) {
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (ch == '\\')	{
 | 
					 | 
				
			||||||
					copy(ch);
 | 
					 | 
				
			||||||
					LoadChar(ch);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				else
 | 
					 | 
				
			||||||
				if (ch == '\n')	{
 | 
					 | 
				
			||||||
					LineNumber++;
 | 
					 | 
				
			||||||
					error("newline in string");
 | 
					 | 
				
			||||||
					copy(match);
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				copy(ch);
 | 
					 | 
				
			||||||
				LoadChar(ch);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (ch == match)	{
 | 
					 | 
				
			||||||
				copy(ch);
 | 
					 | 
				
			||||||
				break;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			/* Fall through */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		case EOI :
 | 
					 | 
				
			||||||
			error("unterminated macro call");
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			copy(ch);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										106
									
								
								util/cpp/skip.c
									
										
									
									
									
								
							
							
						
						
									
										106
									
								
								util/cpp/skip.c
									
										
									
									
									
								
							| 
						 | 
					@ -1,106 +0,0 @@
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/* PREPROCESSOR: INPUT SKIP FUNCTIONS */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	"class.h"
 | 
					 | 
				
			||||||
#include	"input.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int
 | 
					 | 
				
			||||||
skipspaces(ch, skipnl)
 | 
					 | 
				
			||||||
	register int ch;
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	skipspaces() skips any white space and returns the first
 | 
					 | 
				
			||||||
		non-space character.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register int nlseen = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	for (;;) {
 | 
					 | 
				
			||||||
		while (class(ch) == STSKIP) {
 | 
					 | 
				
			||||||
			nlseen = 0;
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (skipnl && class(ch) == STNL) {
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
			++LineNumber;
 | 
					 | 
				
			||||||
			nlseen++;
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		/* How about "\\\n"?????????	*/
 | 
					 | 
				
			||||||
		if (ch == '/') {
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
			if (ch == '*') {
 | 
					 | 
				
			||||||
				skipcomment();
 | 
					 | 
				
			||||||
				LoadChar(ch);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			else	{
 | 
					 | 
				
			||||||
				PushBack();
 | 
					 | 
				
			||||||
				return '/';
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		else if (nlseen && ch == '#') {
 | 
					 | 
				
			||||||
			domacro();
 | 
					 | 
				
			||||||
			LoadChar(ch);
 | 
					 | 
				
			||||||
			/* ch is the first character of a line. This means
 | 
					 | 
				
			||||||
			 * that nlseen will still be true.
 | 
					 | 
				
			||||||
			 */
 | 
					 | 
				
			||||||
		} else
 | 
					 | 
				
			||||||
			return ch;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
skipline()
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	/*	skipline() skips all characters until a newline character
 | 
					 | 
				
			||||||
		is seen, not escaped by a '\\'.
 | 
					 | 
				
			||||||
		Any comment is skipped.
 | 
					 | 
				
			||||||
	*/
 | 
					 | 
				
			||||||
	register int c;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	LoadChar(c);
 | 
					 | 
				
			||||||
	while (class(c) != STNL && c != EOI) {
 | 
					 | 
				
			||||||
		if (class(c) == STSTR || class(c) == STCHAR) {
 | 
					 | 
				
			||||||
			register int stopc = c;
 | 
					 | 
				
			||||||
			int escaped;
 | 
					 | 
				
			||||||
			do {
 | 
					 | 
				
			||||||
				escaped = 0;
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
				if (class(c) == STNL || c == EOI) {
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				if (c == '\\') {
 | 
					 | 
				
			||||||
					LoadChar(c);
 | 
					 | 
				
			||||||
					if (c == '\n') {
 | 
					 | 
				
			||||||
						++LineNumber;
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					else escaped = 1;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} while (escaped || c != stopc);
 | 
					 | 
				
			||||||
			if (class(c) != STNL && c != EOI) {
 | 
					 | 
				
			||||||
				LoadChar(c);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (c == '\\') {
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (class(c) == STNL)
 | 
					 | 
				
			||||||
				++LineNumber;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		if (c == '/') {
 | 
					 | 
				
			||||||
			LoadChar(c);
 | 
					 | 
				
			||||||
			if (c == '*')
 | 
					 | 
				
			||||||
				skipcomment();
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		LoadChar(c);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	++LineNumber;
 | 
					 | 
				
			||||||
	if (c == EOI) {		/* garbage input...		*/
 | 
					 | 
				
			||||||
		error("unexpected EOF while skipping text");
 | 
					 | 
				
			||||||
		PushBack();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,55 +0,0 @@
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
 | 
					 | 
				
			||||||
 * See the copyright notice in the ACK home directory, in the file "Copyright".
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
/* $Id$ */
 | 
					 | 
				
			||||||
/* TOKEN NAME DEFINITIONS */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include	"idf.h"
 | 
					 | 
				
			||||||
#include	"LLlex.h"
 | 
					 | 
				
			||||||
#include	"Lpars.h"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct tokenname	{	/*	Used for defining the name of a
 | 
					 | 
				
			||||||
					token as identified by its symbol
 | 
					 | 
				
			||||||
				*/
 | 
					 | 
				
			||||||
	int tn_symbol;
 | 
					 | 
				
			||||||
	char *tn_name;
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/*	To centralize the declaration of %tokens, their presence in this
 | 
					 | 
				
			||||||
	file is taken as their declaration. The Makefile will produce
 | 
					 | 
				
			||||||
	a grammar file (tokenfile.g) from this file.
 | 
					 | 
				
			||||||
	Moreover, rather than looking up a symbol in all these lists
 | 
					 | 
				
			||||||
	to find its printable name, a fast version of symbol2str() is
 | 
					 | 
				
			||||||
	generated from these tables.
 | 
					 | 
				
			||||||
	Consequenty some of these tables are not referenced explicitly
 | 
					 | 
				
			||||||
	in the C text any more.  To save space and to avoid lint confusion,
 | 
					 | 
				
			||||||
	these have been made pseudo-invisible by #ifdefs.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef	____
 | 
					 | 
				
			||||||
struct tokenname tkspec[] =	{	/* the names of the special tokens */
 | 
					 | 
				
			||||||
	{IDENTIFIER, "identifier"},
 | 
					 | 
				
			||||||
	{STRING, "string"},
 | 
					 | 
				
			||||||
	{FILESPECIFIER, "filespecifier"},
 | 
					 | 
				
			||||||
	{INTEGER, "integer"},
 | 
					 | 
				
			||||||
	{0, ""}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct tokenname tkcomp[] =	{	/* names of the composite tokens */
 | 
					 | 
				
			||||||
	{NOTEQUAL, "!="},
 | 
					 | 
				
			||||||
	{AND, "&&"},
 | 
					 | 
				
			||||||
	{LEFT, "<<"},
 | 
					 | 
				
			||||||
	{LESSEQ, "<="},
 | 
					 | 
				
			||||||
	{EQUAL, "=="},
 | 
					 | 
				
			||||||
	{GREATEREQ, ">="},
 | 
					 | 
				
			||||||
	{RIGHT, ">>"},
 | 
					 | 
				
			||||||
	{OR, "||"},
 | 
					 | 
				
			||||||
	{0, ""}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
struct tokenname tkfunny[] =	{	/* internal keywords */
 | 
					 | 
				
			||||||
	{ERRONEOUS, "erroneous"},
 | 
					 | 
				
			||||||
	{0, ""}
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
#endif	/* ____ */
 | 
					 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue