🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: net.micro.atari16
1 messages
1 total messages Started by Jwahar R. Bammi Sat, 22 Mar 1986 04:05
Proff Part 1 of 4
#297
Author: Jwahar R. Bammi
Date: Sat, 22 Mar 1986 04:05
2108 lines
45278 bytes
#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	debug.h
#	decl.h
#	defs.h
#	dostuff2.c
#	eval.c
#	lextab.d
#	lextab.h
#	lnk
#	look.c
#	lookup.c
#	lookup.h
#	ltb.c
#	make.sh
#	makefile
#	map.c
# This archive created: Fri Mar 21 22:45:00 1986
# By:	Jwahar R. Bammi ()
export PATH; PATH=/bin:$PATH
echo shar: extracting "'debug.h'" '(123 characters)'
if test -f 'debug.h'
then
	echo shar: over-writing existing file "'debug.h'"
fi
sed 's/^X//' << \SHAR_EOF > 'debug.h'
X/*
X#define DEBUG
X#define PROFILE
X*/
X
X#ifdef PROFILE
X#define dprintf(str)	printf((str));
X#else
X#define dprintf(str)
X#endif
X
SHAR_EOF
if test 123 -ne "`wc -c 'debug.h'`"
then
	echo shar: error transmitting "'debug.h'" '(should have been 123 characters)'
fi
echo shar: extracting "'decl.h'" '(3858 characters)'
if test -f 'decl.h'
then
	echo shar: over-writing existing file "'decl.h'"
fi
sed 's/^X//' << \SHAR_EOF > 'decl.h'
X/*
X * Decl.h
X *	Declarations for commonly used C functions.
X *	The way we use it is in stdio.h we put in
X *	the following lines:
X *
X *	#ifdef DECL
X *	#include <decl.h>
X *	#endif
X *
X *	and when we compile, we declare DECL, so that it
X *	decl.h gets included and we have all the functions
X *	that return types other than int, appropriately declared.
X */
X
X
X/*
Xchar *getcwd(char *, int);
X*/
X
X/*
Xchar *calloc(unsigned int, unsigned int);
X*/
Xextern	char *calloc();
X
X/*
Xchar *malloc(unsigned int);
X*/
Xextern	char *malloc();
X
X/*
Xchar *realloc(char *, unsigned int);
X*/
Xextern	char *realloc();
X
X/*
Xchar *sbrk(int);
X*/
Xextern	char *sbrk();
X
X
X#ifndef HUGE
X	/* HUGE is defined if math.h has been included */
X/*
Xdouble acos(double);
X*/
Xextern	double acos();
X
X/*
Xdouble asin(double);
X*/
Xextern	double asin();
X
X/*
Xdouble atan(double);
X*/
Xextern	double atan();
X
X/*
Xdouble atan2(double, double);
X*/
X/*
Xextern	double atan2();
X*/
X
X/*
Xdouble atof(char *);
X*/
Xextern	double atof();
X
X/*
Xdouble ceil(double);
X*/
Xextern	double ceil();
X
X/*
Xdouble cos(double);
X*/
Xextern	double cos();
X
X/*
Xdouble cosh(double);
X*/
Xextern	double cosh();
X
X/*
Xdouble exp(double);
X*/
Xextern	double exp();
X
X/*
Xdouble fabs(double);
X*/
Xextern	double fabs();
X
X/*
Xdouble floor(double);
X*/
Xextern	double floor();
X
X/*
Xdouble fmod(double, double);
X*/
Xextern	double fmod();
X
X/*
Xdouble frexp(double, int *);
X*/
X/*
Xextern	double frexp();
X*/
X
X/*
Xdouble hypot(double, double);
X*/
X/*
Xextern	double hypot();
X*/
X
X/*
Xdouble j0(double);
X*/
X/*
Xextern	double j0();
X*/
X
X/*
Xdouble j1(double);
X*/
X/*
Xextern	double j1();
X*/
X
X/*
Xdouble jn(int, double);
X*/
X/*
Xextern	double jn();
X*/
X
X/*
Xdouble ldexp(double, double);
X*/
X/*
Xextern	double ldexp();
X*/
X
X/*
Xdouble log(double);
X*/
Xextern	double log();
X
X/*
Xdouble log10(double);
X*/
Xextern	double log10();
X
X/*
Xdouble modf(double, double *);
X*/
Xextern	double modf();
X
X/*
Xdouble pow(double, double);
X*/
Xextern	double pow();
X
X/*
Xdouble sin(double);
X*/
Xextern	double sin();
X
X/*
Xdouble sinh(double);
X*/
X/*
Xextern	double sinh();
X*/
X
X/*
Xdouble sqrt(double);
X*/
Xextern	double sqrt();
X
X/*
Xdouble tan(double);
X*/
X/*
Xextern	double tan();
X*/
X
X/*
Xdouble tanh(double);
X*/
X/*
Xextern	double tanh();
X*/
X
X/*
Xdouble y0(double);
X*/
X/*
Xextern	double y0();
X*/
X
X/*
Xdouble y1(double);
X*/
X/*
Xextern	double y1();
X*/
X
X/*
Xdouble yn(int, double);
X*/
X/*
Xextern	double yn();
X*/
X
X#endif	/* HUGE */
X
X
X/*
Xint (*signal(int, int (*)()))();
X*/
Xextern	int (*signal())();
X
X/*
XFILE *fdopen(int, char *);
X*/
Xextern	FILE *fdopen();
X
X/*
Xchar *fgets(char *, int, FILE *);
X*/
Xextern	char *fgets();
X
X/*
XFILE *fopen(char *, char *);
X*/
Xextern	FILE *fopen();
X
X/*
XFILE *freopen(char *, char *, FILE *);
X*/
Xextern	FILE *freopen();
X
X/*
Xlong ftell(FILE *);
X*/
Xextern	long ftell();
X
X/*
Xchar *gets(char *);
X*/
Xextern	char *gets();
X
X/*
Xlong lseek(int, long, int);
X*/
Xextern	long lseek();
X
X/*
Xchar *mktemp(char *);
X*/
Xextern	char *mktemp();
X
X/*
Xlong tell(int);
X*/
Xextern	long tell();
X
X
X/*
Xlong atol(char *);
X*/
Xextern	long atol();
X
X/*
Xchar *ecvt(double, int, int *, int *);
X*/
Xextern	char *ecvt();
X
X/*
Xchar *fcvt(double, int, int *, int *);
X*/
Xextern	char *fcvt();
X
X/*
Xchar *gcvt(double, int, char *);
X*/
Xextern	char *gcvt();
X
X/*
Xchar *getenv(char *);
X*/
Xextern	char *getenv();
X
X/*
Xchar *itoa(int, char *, int);
X*/
Xextern	char *itoa();
X
X/*
Xlong labs(long);
X*/
Xextern	long labs();
X
X/*
Xchar *ltoa();
X*/
Xextern	char *ltoa();
X
X/*
Xchar *ultoa(unsigned long, char *, int);
X*/
Xextern	char *ultoa();
X
X
X/*
Xchar *strcat(char *, char *);
X*/
Xextern	char *strcat();
X
X/*
Xchar *strcpy(char *, char *);
X*/
Xextern	char *strcpy();
X
X/*
Xunsigned int strlen(char *);
X*/
Xextern	unsigned int strlen();
X
X/*
Xchar *strncat(char *, char *, unsigned int);
X*/
Xextern	char *strncat();
X
X/*
Xchar *strncpy(char *, char *, unsigned int);
X*/
Xextern	char *strncpy();
X
X/*
Xchar	*index(char *, char);
X*/
Xextern	char	*index();
X
X/*
Xchar	*rindex(char *, char);
X*/
Xextern	char	*rindex();
SHAR_EOF
if test 3858 -ne "`wc -c 'decl.h'`"
then
	echo shar: error transmitting "'decl.h'" '(should have been 3858 characters)'
fi
echo shar: extracting "'defs.h'" '(1855 characters)'
if test -f 'defs.h'
then
	echo shar: over-writing existing file "'defs.h'"
fi
sed 's/^X//' << \SHAR_EOF > 'defs.h'
X/*
X * defs.h
X *
X * #define rainbow	- rainbow CP/M-86 version
X * #define vms		- vms version (predefined by VAX11C compiler)
X * #define unix		- unix version
X * #define ATARIST	- Atari St series
X */
X
X/*
X *  Synonyms for ASCII control characters
X *
X */
X
X#define	BACKSPACE	8
X#define	BEL		7
X#define BELL		7
X#define	BLANK		32
X#define	CARRIAGE_RETURN	13
X#define	NEWLINE		10
X#define	RUBOUT		127
X#define	TAB		9
X
X/*
X * misc. definitions
X *
X */
X
X#define	EOS		0
X#define	HUGE		30000
X#define	NO		0
X#define	OK		0
X#define	YES		1
X#define FALSE		0
X#define TRUE		1
X#define	FILENAMESIZE	50
X#define	MAXCHARS	20
X#define MAXLINE		256
X#define MAXTOK		80
X#define ARB		MAXLINE
X
X#define	MAXCARD		MAXLINE-1
X#define	MAXNAME		FILENAMESIZE
X
X#define	NCHARS		33
X#define MAXOFILES	12
X
X#define	ARGFLAG	'$' 
X#define	INSIZE	MAXLINE 
X#define	MAXOUT	2*MAXLINE 
X#define	MAXDEF	200 
X#define	NFILES	MAXOFILES-4
X#define	PAGENUM		'#' 
X#define	CURRENTDATE	'%' 
X#define ESCAPE		'@'
X#define VESCAPE		'$'
X#define	PAGEJECT	12          /* 12 is ASCII formfeed (control-L) */
X#define	PAGEWIDTH	65 
X#define	PAGELEN		62 
X#define	BUFSIZE		512    	    /* push back buffer */
X/*
X * lexical analyser values
X *
X * include lexical analyser return constants
X * generated by ltb.
X *
X */
X#include "lextab.d"		/* expended format & roff & runoff */
X
X#define	UNKNOWN	999
X#define MACRO	0
X#define NEGATED -1
X#define	LEFT	1 
X#define	CENTER	2 
X#define	RIGHT	3
X
X/*
X * structure definition for contents linked list
X *
X */
X
Xstruct clist {		/* list struct for contents  */
X	char level;
X	char *str;
X	int  page;
X	struct clist *nextc;
X};
X
X#ifdef putchar
X#undef putchar
X#ifdef ATARIST
X#define putchar(c) st_putc((c),poutput);
X#else
X#define putchar(c) putc((c),poutput);
X#endif
X#endif
X
X/*
X * The following definitions are required
X * till they fix gemlib
X */
X
X#ifdef ATARIST
X#define printf st_printf
X#define fprintf st_fprintf
X#endif
SHAR_EOF
if test 1855 -ne "`wc -c 'defs.h'`"
then
	echo shar: error transmitting "'defs.h'" '(should have been 1855 characters)'
fi
echo shar: extracting "'dostuff2.c'" '(2935 characters)'
if test -f 'dostuff2.c'
then
	echo shar: over-writing existing file "'dostuff2.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'dostuff2.c'
X#include <stdio.h>
X#include <ctype.h>
X#include "proff.h"
X#include "debug.h"
X
X/*
X * dodef - define a command macro (".de xx" is in buf.)
X *
X */
Xdodef(buf,fd)
Xchar buf[];
XFILE *fd;
X{
X	char name[MAXNAME],defn[MAXDEF];
X	int i,junk;
X
X#ifdef DEBUG
X	printf("dodef++: Fd %ld\n",fd);
X#endif
X
X	dprintf("dodef  ");
X	i = 0;
X	junk = getwrd(buf, &i, name);
X	i = getwrd(buf, &i, name);	/* get the name */
X	if (i == 0)
X		error("missing name in command def.");
X	i = 0;
X	while (ngetln(buf,fd) != EOF) {
X		if (buf[0] == cchar && buf[1] == 'e' &&
X		    buf[2] == 'n' && !isalnum(buf[3]))
X			break;
X		junk = addstr(buf, defn, &i, MAXDEF);
X	}
X	if (addset(EOS, defn, &i, MAXDEF) == NO)
X		error("definition too long.\n");
X	if (install(name, defn, macrotab) == NULL)
X		fprintf(stderr,"no room for new definition.\n");
X#ifdef DEBUG
X	printf("dodef: %s (name) %s (defn)\n",name,defn);
X#endif
X}
X
X/*
X * doesc - expand escapes in buf
X *
X */
Xdoesc(buf, tbuf, size)
Xchar buf[];
Xchar tbuf[];
Xint size;
X{
X	int i,j;
X
X	dprintf("doesc  ");
X	j = 0;
X	for (i = 0; buf[i] != EOS && j < size-1; i++)
X		/*
X		 * clean up generic escapes along the way.
X		 */
X		if (buf[i] == genesc)
X			tbuf[j++] = buf[++i];
X
X		else if (buf[i] != ESCAPE) {
X			tbuf[j] = buf[i];
X			j++;
X		}
X		else if (buf[i+1] == 'n' &&
X		    (buf[i+2] >= 'a' && buf[i+2] <= 'z')) {
X			j += itoc(nr[buf[i+2] - 'a'],
X			&tbuf[j], size - j - 1);
X			i += 2;
X		}
X		else {
X			tbuf[j] = buf[i];
X			j++;
X		}
X	tbuf[j] = EOS;
X	strcpy(buf, tbuf);
X}
X
X/*
X * dovar - expand variables in buf
X *
X */
Xdovar(tbuf, buf)
Xchar *buf;
Xchar *tbuf;
X{
X	register char *c, *p, t;
X	struct hashlist *xp;
X
X	while (*buf != '\0') {
X		if (*buf == genesc) {
X			*tbuf++ = *buf++;
X			*tbuf++ = *buf;
X		}
X		else if (*buf != VESCAPE)
X			*tbuf++ = *buf;
X		else {
X			buf++;	 /* skip the ESCAPE */
X			if (*buf == '{')
X				buf++;
X			p = buf; /* save the beginning address of variable */
X			while (isalnum(*buf))
X				buf++;
X			t = *buf;	/* save the character*/
X			*buf = '\0';	/* hack a null there */
X			if ((xp = lookup(p,gentab)) != NULL) {
X				c = xp->def;	/* point to def */
X				while (*c != '\0')
X					*tbuf++ = *c++;
X			}
X			if (*(p-1) != '{')
X				*tbuf++ = t;
X			else if (t != '}')
X				fprintf(stderr, "missing \"}\" in %s\n",p);
X		}
X		buf++;
X	}
X	*tbuf = '\0';
X}
X
X
X/*
X * dotabs - expand tabs in buf
X *
X */
Xdotabs(buf,tbuf,size)
Xchar buf[];
Xchar tbuf[];
Xint size;
X{
X	int i,j;
X	dprintf("dotabs  ");
X
X	j = 0;
X	for (i = 0; buf[i] != EOS && j < size - 1; i++)
X		if (buf[i] == '\t')
X			while (j < size - 1) {
X				tbuf[j] = ' ';
X				j++;
X				if (tabs[j] == YES || j > INSIZE)
X					break;
X			}
X		else {
X			tbuf[j] = buf[i];
X			j++;
X		}
X	tbuf[j] = EOS;
X	strcpy(buf, tbuf);
X}
X
X/*
X * docline - produce a "contents" line.
X *
X */
Xdocline(str,width,cline,page)
Xchar *str;
Xint width;
Xchar *cline;
Xint page;
X{
X	int i;
X
X	for (i = 0; i < width - 6 && cline[i] != '\0'; i++)
X		str[i] = cline[i];
X	while (i < width - 6)
X		str[i++] = '.';
X	sprintf(str+i,"%5d\n",page);
X}
X
SHAR_EOF
if test 2935 -ne "`wc -c 'dostuff2.c'`"
then
	echo shar: error transmitting "'dostuff2.c'" '(should have been 2935 characters)'
fi
echo shar: extracting "'eval.c'" '(1296 characters)'
if test -f 'eval.c'
then
	echo shar: over-writing existing file "'eval.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'eval.c'
X#include <stdio.h>
X#include <ctype.h>
X#include "proff.h"
X#include "debug.h"
X
X
X/*
X * eval - evaluate defined command (push back definition)
X *
X */
Xeval(buf,defn)
Xchar buf[];
Xchar defn[];
X{
X	register int j,k;
X	int i;
X	int argptr[10];
X
X	for (i = 0; i < 10 ; i++)
X		argptr[i] = 0;
X 
X	buf[0] = '\0';		/* buf[0] is cchar */
X	dprintf(defn);
X	dprintf("eval  ");
X	i = 1;
X	argptr[0] = 1;		/* first parm is macro name */
X	while (buf[i] != ' ' && buf[i] != '\t' &&
X	    buf[i] != '\n' && buf[i] != '\0')
X		i++;
X	buf[i++] = '\0';		/* EOS terminate */
X	/*
X	 * start scanning remaining macro parameters.
X	 * delimiters are blanks or commas. Any string
X	 * enclosed with double quotes are accepted as
X	 * parameters as well
X	 *
X	 */
X	for (j = 1; j < 10; j++) {
X		skipbl(buf, &i);
X		if (buf[i] == '\n' || buf[i] == '\0')
X			break;
X		argptr[j] = i;
X		while (buf[i] != ' ' && buf[i] != '\t' &&
X		    buf[i] != ',' && buf[i] != '\n' && buf[i] != '\0')
X			i++;
X		buf[i] = '\0';
X		i++;
X	}
X	for (k = strlen(defn) - 1; k >= 0; k--)
X		if (defn[k-1] != ARGFLAG)
X			putbak(defn[k]);
X		else {
X			if (defn[k] < '0' || defn[k] > '9')
X				putbak(defn[k]);
X			else {
X				i = defn[k] - '0';
X				i = argptr[i];
X				pbstr(&buf[i]);
X				k--;		/* skip over $ */
X			}
X		}
X	if (k = 0)	/* do the last character */
X		putbak(defn[k]);
X}
X
SHAR_EOF
if test 1296 -ne "`wc -c 'eval.c'`"
then
	echo shar: error transmitting "'eval.c'" '(should have been 1296 characters)'
fi
echo shar: extracting "'lextab.d'" '(856 characters)'
if test -f 'lextab.d'
then
	echo shar: over-writing existing file "'lextab.d'"
fi
sed 's/^X//' << \SHAR_EOF > 'lextab.d'
X#define  DBO	5
X#define  EBO	7
X#define  NAP	101
X#define  NPA	13
X#define  GET	95
X#define  PGI	11
X#define  M1	45
X#define  M2	47
X#define  M3	49
X#define  ELT	109
X#define  M4	51
X#define  LEX	89
X#define  SAV	85
X#define  CC	19
X#define  BD	3
X#define  SET	93
X#define  EC	27
X#define  CE	21
X#define  DE	25
X#define  EF	29
X#define  HE	37
X#define  EH	31
X#define  LTR	107
X#define  CL	103
X#define  FI	33
X#define  IG	91
X#define  AP	99
X#define  BP	9
X#define  PC	105
X#define  NE	53
X#define  OE	63
X#define  NF	55
X#define  BR	15
X#define  RST	87
X#define  OF	65
X#define  FO	35
X#define  BS	17
X#define  OH	67
X#define  IN	39
X#define  NJ	57
X#define  CU	23
X#define  PL	69
X#define  TI	81
X#define  PN	97
X#define  RM	73
X#define  PO	71
X#define  LS	43
X#define  JU	41
X#define  NR	59
X#define  UL	83
X#define  SO	75
X#define  SP	77
X#define  OU	61
X#define  ST	79
X#define  WR	111
X#define  RESET	1
SHAR_EOF
if test 856 -ne "`wc -c 'lextab.d'`"
then
	echo shar: error transmitting "'lextab.d'" '(should have been 856 characters)'
fi
echo shar: extracting "'lextab.h'" '(9281 characters)'
if test -f 'lextab.h'
then
	echo shar: over-writing existing file "'lextab.h'"
fi
sed 's/^X//' << \SHAR_EOF > 'lextab.h'
X#ifndef STRUC_DEFINED
X
X/*	lextab.h	*/
X
Xstruct _lex_h { 	char 	*__s;
X		  	int 	 __v;
X		  	int  	 __f;
X		struct  _lex_h  *__l;
X};
X
X#define STRUC_DEFINED
X#endif
Xstruct
X_lex_h __ce = {  "ce",
X                  21,     0,NULL };
Xstruct
X_lex_h __ec = {  "ec",
X                  27,     0,&__ce };
Xstruct
X_lex_h __de = {  "de",
X                  25,     0,NULL };
Xstruct
X_lex_h __f = {  "f",
X                  33,     1,NULL };
Xstruct
X_lex_h __ef = {  "ef",
X                  29,     0,NULL };
Xstruct
X_lex_h __nojustify = {  "nojustify",
X                  57,     0,&__ef };
Xstruct
X_lex_h __eh = {  "eh",
X                  31,     0,NULL };
Xstruct
X_lex_h __he = {  "he",
X                  37,     0,&__eh };
Xstruct
X_lex_h __j = {  "j",
X                  41,     1,NULL };
Xstruct
X_lex_h __fi = {  "fi",
X                  33,     0,NULL };
Xstruct
X_lex_h __na = {  "na",
X                  99,     0,&__fi };
Xstruct
X_lex_h __cl = {  "cl",
X                 103,     0,&__na };
Xstruct
X_lex_h __ig = {  "ig",
X                  91,     0,NULL };
Xstruct
X_lex_h __dbo = {  "dbo",
X                   5,     1,NULL };
Xstruct
X_lex_h __pa = {  "pa",
X                  11,     1,&__dbo };
Xstruct
X_lex_h __ap = {  "ap",
X                  99,     1,&__pa };
Xstruct
X_lex_h __el = {  "el",
X                 109,     1,&__ap };
Xstruct
X_lex_h __ebo = {  "ebo",
X                   7,     1,NULL };
Xstruct
X_lex_h __bp = {  "bp",
X                   9,     0,&__ebo };
Xstruct
X_lex_h __ne = {  "ne",
X                  53,     0,NULL };
Xstruct
X_lex_h __pc = {  "pc",
X                 105,     0,&__ne };
Xstruct
X_lex_h __br = {  "br",
X                  15,     1,NULL };
Xstruct
X_lex_h __need = {  "need",
X                  53,     0,&__br };
Xstruct
X_lex_h __nf = {  "nf",
X                  55,     1,&__need };
Xstruct
X_lex_h __oe = {  "oe",
X                  63,     0,&__nf };
Xstruct
X_lex_h __noautoparagraph = {  "noautoparagraph",
X                 101,     1,&__oe };
Xstruct
X_lex_h __page = {  "page",
X                   9,     1,NULL };
Xstruct
X_lex_h __bs = {  "bs",
X                  17,     0,&__page };
Xstruct
X_lex_h __cchar = {  "cchar",
X                  19,     0,&__bs };
Xstruct
X_lex_h __fo = {  "fo",
X                  35,     0,&__cchar };
Xstruct
X_lex_h __of = {  "of",
X                  65,     0,&__fo };
Xstruct
X_lex_h __pg = {  "pg",
X                   9,     1,NULL };
Xstruct
X_lex_h __echar = {  "echar",
X                  27,     0,&__pg };
Xstruct
X_lex_h __in = {  "in",
X                  39,     0,&__echar };
Xstruct
X_lex_h __oh = {  "oh",
X                  67,     0,&__in };
Xstruct
X_lex_h __s = {  "s",
X                  77,     1,&__oh };
Xstruct
X_lex_h __cu = {  "cu",
X                  23,     0,NULL };
Xstruct
X_lex_h __nj = {  "nj",
X                  57,     1,&__cu };
Xstruct
X_lex_h __bold = {  "bold",
X                   3,     0,NULL };
Xstruct
X_lex_h __break = {  "break",
X                  15,     1,&__bold };
Xstruct
X_lex_h __header = {  "header",
X                  37,     0,&__break };
Xstruct
X_lex_h __lm = {  "lm",
X                  39,     1,&__header };
Xstruct
X_lex_h __define = {  "define",
X                  25,     0,NULL };
Xstruct
X_lex_h __nap = {  "nap",
X                 101,     1,&__define };
Xstruct
X_lex_h __pl = {  "pl",
X                  69,     0,NULL };
Xstruct
X_lex_h __get = {  "get",
X                  95,     0,&__pl };
Xstruct
X_lex_h __ti = {  "ti",
X                  81,     0,NULL };
Xstruct
X_lex_h __vg = {  "vg",
X                  95,     0,&__ti };
Xstruct
X_lex_h __np = {  "np",
X                  13,     0,NULL };
Xstruct
X_lex_h __pn = {  "pn",
X                  97,     0,&__np };
Xstruct
X_lex_h __fill = {  "fill",
X                  33,     1,NULL };
Xstruct
X_lex_h __ju = {  "ju",
X                  41,     0,&__fill };
Xstruct
X_lex_h __ls = {  "ls",
X                  43,     0,&__ju };
Xstruct
X_lex_h __po = {  "po",
X                  71,     0,&__ls };
Xstruct
X_lex_h __rm = {  "rm",
X                  73,     1,&__po };
Xstruct
X_lex_h __nr = {  "nr",
X                  59,     0,NULL };
Xstruct
X_lex_h __lt = {  "lt",
X                 107,     1,&__nr };
Xstruct
X_lex_h __ul = {  "ul",
X                  83,     0,NULL };
Xstruct
X_lex_h __spc = {  "spc",
X                  43,     1,NULL };
Xstruct
X_lex_h __so = {  "so",
X                  75,     0,&__spc };
Xstruct
X_lex_h __ps = {  "ps",
X                  69,     1,NULL };
Xstruct
X_lex_h __sp = {  "sp",
X                  77,     0,&__ps };
Xstruct
X_lex_h __left = {  "left",
X                  81,     1,&__sp };
Xstruct
X_lex_h __tp = {  "tp",
X                  53,     1,NULL };
Xstruct
X_lex_h __ou = {  "ou",
X                  61,     0,&__tp };
Xstruct
X_lex_h __req = {  "req",
X                  75,     1,&__ou };
Xstruct
X_lex_h __lx = {  "lx",
X                  89,     0,&__req };
Xstruct
X_lex_h __rs = {  "rs",
X                  87,     0,NULL };
Xstruct
X_lex_h __lex = {  "lex",
X                  89,     0,&__rs };
Xstruct
X_lex_h __paging = {  "paging",
X                  11,     1,NULL };
Xstruct
X_lex_h __st = {  "st",
X                  79,     0,NULL };
Xstruct
X_lex_h __save = {  "save",
X                  85,     0,&__st };
Xstruct
X_lex_h __set = {  "set",
X                  93,     0,NULL };
Xstruct
X_lex_h __sv = {  "sv",
X                  85,     0,NULL };
Xstruct
X_lex_h __vs = {  "vs",
X                  93,     0,&__sv };
Xstruct
X_lex_h __wr = {  "wr",
X                 111,     0,&__vs };
Xstruct
X_lex_h __skip = {  "skip",
X                  77,     1,NULL };
Xstruct
X_lex_h __include = {  "include",
X                  75,     0,NULL };
Xstruct
X_lex_h __center = {  "center",
X                  21,     0,NULL };
Xstruct
X_lex_h __spacing = {  "spacing",
X                  43,     1,&__center };
Xstruct
X_lex_h __nofill = {  "nofill",
X                  55,     0,NULL };
Xstruct
X_lex_h __ignore = {  "ignore",
X                  91,     0,&__nofill };
Xstruct
X_lex_h __reset = {  "reset",
X                   1,     0,NULL };
Xstruct
X_lex_h __offset = {  "offset",
X                  71,     0,&__reset };
Xstruct
X_lex_h __literal = {  "literal",
X                 107,     1,NULL };
Xstruct
X_lex_h __enablebolding = {  "enablebolding",
X                   7,     1,NULL };
Xstruct
X_lex_h __nopaging = {  "nopaging",
X                  13,     1,NULL };
Xstruct
X_lex_h __footer = {  "footer",
X                  35,     0,NULL };
Xstruct
X_lex_h __outend = {  "outend",
X                  63,     0,&__footer };
Xstruct
X_lex_h __write = {  "write",
X                 111,     0,&__outend };
Xstruct
X_lex_h __pagesize = {  "pagesize",
X                  69,     1,NULL };
Xstruct
X_lex_h __source = {  "source",
X                  75,     0,NULL };
Xstruct
X_lex_h __m1 = {  "m1",
X                  45,     0,NULL };
Xstruct
X_lex_h __disablebolding = {  "disablebolding",
X                   5,     1,NULL };
Xstruct
X_lex_h __m2 = {  "m2",
X                  47,     0,&__disablebolding };
Xstruct
X_lex_h __m3 = {  "m3",
X                  49,     0,NULL };
Xstruct
X_lex_h __contline = {  "contline",
X                 103,     0,&__m3 };
Xstruct
X_lex_h __endliteral = {  "endliteral",
X                 109,     1,&__contline };
Xstruct
X_lex_h __m4 = {  "m4",
X                  51,     0,NULL };
Xstruct
X_lex_h __testpage = {  "testpage",
X                  53,     1,&__m4 };
Xstruct
X_lex_h __pagenumber = {  "pagenumber",
X                  97,     0,NULL };
Xstruct
X_lex_h __leftmargin = {  "leftmargin",
X                  39,     1,NULL };
Xstruct
X_lex_h __require = {  "require",
X                  75,     1,&__leftmargin };
Xstruct
X_lex_h __skipto = {  "skipto",
X                  79,     0,NULL };
Xstruct
X_lex_h __underline = {  "underline",
X                  83,     0,&__skipto };
Xstruct
X_lex_h __restore = {  "restore",
X                  87,     0,NULL };
Xstruct
X_lex_h __rightmargin = {  "rightmargin",
X                  73,     1,NULL };
Xstruct
X_lex_h __justify = {  "justify",
X                  41,     1,NULL };
Xstruct
X_lex_h __output = {  "output",
X                  61,     0,NULL };
Xstruct
X_lex_h __autoparagraph = {  "autoparagraph",
X                  99,     1,NULL };
Xstruct
X_lex_h __printcont = {  "printcont",
X                 105,     0,NULL };
Xstruct
X_lex_h __bd = {  "bd",
X                   3,     0,NULL };
Xstruct
X_lex_h __db = {  "db",
X                   5,     0,&__bd };
Xstruct
X_lex_h __cc = {  "cc",
X                  19,     0,&__db };
Xstruct
X_lex_h __eb = {  "eb",
X                   7,     0,NULL };
X
X
X/*  Hash Table */
X
Xstruct _lex_h *lextab[100] = {
X	&__ec,	
X	&__de,	&__f,	&__nojustify,	NULL,	
X	&__he,	&__j,	&__cl,	&__ig,	
X	&__el,	&__bp,	&__pc,	&__noautoparagraph,	
X	&__of,	NULL,	&__s,	&__nj,	
X	&__lm,	NULL,	&__nap,	&__get,	
X	&__vg,	&__pn,	&__rm,	&__lt,	
X	&__ul,	&__so,	&__left,	&__lx,	
X	&__lex,	&__paging,	&__save,	&__set,	
X	&__wr,	NULL,	NULL,	NULL,	
X	NULL,	NULL,	&__skip,	&__include,	
X	&__spacing,	NULL,	NULL,	&__ignore,	
X	NULL,	NULL,	&__offset,	NULL,	
X	&__literal,	&__enablebolding,	&__nopaging,	NULL,	
X	NULL,	NULL,	&__write,	&__pagesize,	
X	&__source,	&__m1,	&__m2,	&__endliteral,	
X	&__testpage,	&__pagenumber,	NULL,	NULL,	
X	&__require,	&__underline,	NULL,	NULL,	
X	NULL,	NULL,	NULL,	&__restore,	
X	NULL,	NULL,	NULL,	NULL,	
X	NULL,	NULL,	NULL,	&__rightmargin,	
X	NULL,	&__justify,	NULL,	NULL,	
X	NULL,	NULL,	NULL,	NULL,	
X	&__output,	NULL,	&__autoparagraph,	NULL,	
X	&__printcont,	NULL,	NULL,	NULL,	
X	NULL,	&__cc,	&__eb   };
SHAR_EOF
if test 9281 -ne "`wc -c 'lextab.h'`"
then
	echo shar: error transmitting "'lextab.h'" '(should have been 9281 characters)'
fi
echo shar: extracting "'lnk'" '(110 characters)'
if test -f 'lnk'
then
	echo shar: over-writing existing file "'lnk'"
fi
sed 's/^X//' << \SHAR_EOF > 'lnk'
Xproff.68k=gems,proff,proff01,proff02,lookup,pinit,putwrd,pxlex,\
Xpxxparse,dostuff2,eval,stack,map,gemlib,libf
SHAR_EOF
if test 110 -ne "`wc -c 'lnk'`"
then
	echo shar: error transmitting "'lnk'" '(should have been 110 characters)'
fi
echo shar: extracting "'look.c'" '(3051 characters)'
if test -f 'look.c'
then
	echo shar: over-writing existing file "'look.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'look.c'
X/*
X * from K&R "The C Prograamming language"
X * Table lookup routines
X *
X */
X#define INLOOK 1
X
X#include <stdio.h>
X#include "lookup.h"
X
Xextern struct
Xlexlist	(*(*lextable))[];/* global pointer for lexical analyser hash table */
X
X/*
X * hash - for a hash value for string s
X *
X */
Xint hash(s)
Xchar *s;
X{
X	int	hashval;
X
X	for (hashval = 0; *s != '\0';)
X		hashval += *s++;
X	return (hashval % HASHMAX);
X}
X
X/*
X * lookup - lookup for a string s in the hash table
X *
X */
Xstruct hashlist
X*lookup(s, hashtab)
Xchar *s;
Xstruct hashlist *hashtab[];
X{
X	struct hashlist *np;
X
X	for (np = hashtab[hash(s)]; np != NULL; np = np->next)
X		if (strcmp(s, np->name) == 0)
X			return(np);	/* found     */
X	return(NULL);		/* not found */
X}
X
X/*
X * install - install a string name in hashtable and its value def
X * at a given hashtable.
X */
Xstruct hashlist
X*install(name,def,hashtab)
Xchar *name;
Xchar *def;
Xstruct hashlist *hashtab[];
X{
X	int hashval;
X	struct hashlist *np, *lookup();
X	char *strsave(), *malloc();
X
X	if ((np = lookup(name, hashtab)) == NULL) {	/* not found.. */
X		np = (struct hashlist *) malloc(sizeof(*np));
X				if (np == NULL)
X			return(NULL);
X		if ((np->name = strsave(name)) == NULL)
X			return(NULL);
X		hashval = hash(np->name);
X		np->next = hashtab[hashval];
X		hashtab[hashval] = np;
X	} else					/* found..     */
X		free(np->def);			/* free prev.  */
X	if ((np->def = strsave(def)) == NULL)
X		return(NULL);
X	return(np);
X}
X
X/*
X * strsave - save string s somewhere
X *
X */
Xchar
X*strsave(s)
Xchar *s;
X{
X	char *p, *malloc();
X	register int n;
X
X	n = strlen(s) + 1;
X	if ((p = malloc(n)) != NULL)
X			strcpy(p, s);
X	return(p);
X}
X
X/*
X * lexinstal - instal a string name in hashtable and its value
X *	       used by lexical analyser to quickly match a token
X *	       and return its lexical value.
X *
X */
Xstruct lexlist
X*lexinstal(name,val,flag,lextable)
Xchar *name;
Xint val;
Xint flag;
Xstruct lexlist *lextable[];
X{
X	int hashval;
X	struct lexlist *np,*lexlook();
X	char *strsave(), *malloc();
X
X	if ((np = lexlook(name,lextable)) == NULL) {	/* not found.. */
X		np = (struct lexlist *) malloc(sizeof(*np));
X		if (np == NULL)
X			return(NULL);
X		if ((np->name = strsave(name)) == NULL)
X			return(NULL);
X		hashval = hash(np->name);
X		np->link = lextable[hashval];
X		lextable[hashval] = np;
X	}
X	np->val = val;				/* replace prev */
X	np->flag = flag;
X	return(np);
X}
X
X/*
X * lexlook - lookup for a string s in the hash table
X *	     used by lexinstal only.
X *
X */
Xstruct lexlist
X*lexlook(s,table)
Xchar *s;
Xstruct lexlist *table[];
X{
X	struct lexlist *np;
X
X	for (np = table[hash(s)]; np != NULL; np = np->link)
X		if (strcmp(s, np->name) == 0)
X			return(np);	/* found     */
X	return(NULL);		/* not found */
X}
X
X/*
X * remove an item from the hash table forever
X *
X */
Xstruct lexlist
X*remove(s, table)
Xchar *s;
Xstruct lexlist *table[];
X{
X	struct lexlist *np, *xp;
X
X	np = table[hash(s)];
X	xp = np; 
X	while (np != NULL) {
X		if (strcmp(s, np->name) == 0) {
X			xp->link = np->link;	/* remoe the link */
X			return(np);		/* return the lost */
X		}
X		xp = np; 
X		np = np->link;
X	}
X	return(NULL);
X}
X
SHAR_EOF
if test 3051 -ne "`wc -c 'look.c'`"
then
	echo shar: error transmitting "'look.c'" '(should have been 3051 characters)'
fi
echo shar: extracting "'lookup.c'" '(3122 characters)'
if test -f 'lookup.c'
then
	echo shar: over-writing existing file "'lookup.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'lookup.c'
X/*
X * from K&R "The C Programming language"
X * Table lookup routines
X *
X */
X#define INLOOK 1
X
X#include <stdio.h>
X#include "proff.h"
X
Xstruct
Xlexlist	(*(*lextable))[];/* global pointer for lexical analyser hash table */
X
X/*
X * hash - for a hash valuue for string s
X *
X */
Xint hash(s)
Xchar *s;
X{
X	int	hashval;
X
X	for (hashval = 0; *s != '\0';)
X		hashval += *s++;
X	return (hashval % HASHMAX);
X}
X
X/*
X * lookup - lookup for a string s in the hash table
X *
X */
Xstruct hashlist
X*lookup(s, hashtab)
Xchar *s;
Xstruct hashlist *hashtab[];
X{
X	struct hashlist *np;
X
X	for (np = hashtab[hash(s)]; np != NULL; np = np->next)
X		if (strcmp(s, np->name) == 0)
X			return(np);	/* found     */
X	return(NULL);		/* not found */
X}
X
X/*
X * install - install a string name in hashtable and its value def
X * at a given hashtable.
X */
Xstruct hashlist
X*install(name,def,hashtab)
Xchar *name;
Xchar *def;
Xstruct hashlist *hashtab[];
X{
X	int hashval;
X	struct hashlist *np, *lookup();
X	char *strsave(), *malloc();
X
X	if ((np = lookup(name, hashtab)) == NULL) {	/* not found.. */
X		np = (struct hashlist *) malloc(sizeof(*np));
X		p_memoryus += sizeof(*np);
X		if (np == NULL)
X			return(NULL);
X		if ((np->name = strsave(name)) == NULL)
X			return(NULL);
X		hashval = hash(np->name);
X		np->next = hashtab[hashval];
X		hashtab[hashval] = np;
X	} else					/* found..     */
X		free(np->def);			/* free prev.  */
X	if ((np->def = strsave(def)) == NULL)
X		return(NULL);
X	return(np);
X}
X
X/*
X * strsave - save string s somewhere
X *
X */
Xchar
X*strsave(s)
Xchar *s;
X{
X	char *p, *malloc();
X	register int n;
X
X	n = strlen(s) + 1;
X	if ((p = malloc(n)) != NULL) {
X		p_memoryus += n;
X		strcpy(p, s);
X	}
X	return(p);
X}
X
X/*
X * lexinstal - instal a string name in hashtable and its value
X *	       used by lexical analyser to quickly match a token
X *	       and return its lexical value.
X *
X */
Xstruct lexlist
X*lexinstal(name,val,flag,lextable)
Xchar *name;
Xint val;
Xint flag;
Xstruct lexlist *lextable[];
X{
X	int hashval;
X	struct lexlist *np,*lexlook();
X	char *strsave(), *malloc();
X
X	if ((np = lexlook(name,lextable)) == NULL) {	/* not found.. */
X		np = (struct lexlist *) malloc(sizeof(*np));
X		p_memoryus += sizeof(*np);
X		if (np == NULL)
X			return(NULL);
X		if ((np->name = strsave(name)) == NULL)
X			return(NULL);
X		hashval = hash(np->name);
X		np->link = lextable[hashval];
X		lextable[hashval] = np;
X	}
X	np->val = val;				/* replace prev */
X	np->flag = flag;
X	return(np);
X}
X
X/*
X * lexlook - lookup for a string s in the hash table
X *	     used by lexinstal only.
X *
X */
Xstruct lexlist
X*lexlook(s,table)
Xchar *s;
Xstruct lexlist *table[];
X{
X	struct lexlist *np;
X
X	for (np = table[hash(s)]; np != NULL; np = np->link)
X		if (strcmp(s, np->name) == 0)
X		return(np);	/* found     */
X	return(NULL);		/* not found */
X}
X
X/*
X * remove an item from the hash table forever
X *
X */
Xstruct lexlist
X*remove(s, table)
Xchar *s;
Xstruct lexlist *table[];
X{
X	struct lexlist *np, *xp;
X
X	np = table[hash(s)];
X	xp = np; 
X	while (np != NULL) {
X		if (strcmp(s, np->name) == 0) {
X			xp->link = np->link;	/* remove the link */
X			return(np);		/* return the lost */
X		}
X		xp = np; 
X		np = np->link;
X	}
X	return(NULL);
X}
X
SHAR_EOF
if test 3122 -ne "`wc -c 'lookup.c'`"
then
	echo shar: error transmitting "'lookup.c'" '(should have been 3122 characters)'
fi
echo shar: extracting "'lookup.h'" '(463 characters)'
if test -f 'lookup.h'
then
	echo shar: over-writing existing file "'lookup.h'"
fi
sed 's/^X//' << \SHAR_EOF > 'lookup.h'
X/*
X * from K&R "The C Programming language"
X * Table lookup routines 
X * structure and definitions
X *
X */
X
X					/* basic table entry */
Xstruct hashlist {
X	char	*name;
X	char	*def;
X	struct	hashlist *next;		/* next in chain     */
X};
X					/* basic table entry */
Xstruct lexlist {
X	char	*name;
X	int	val;			/* lexical value     */
X	int	flag;			/* optional flag val */
X	struct	lexlist  *link;		/* next in chain     */
X};
X
X
X#define HASHMAX	100			/* size of hashtable */
SHAR_EOF
if test 463 -ne "`wc -c 'lookup.h'`"
then
	echo shar: error transmitting "'lookup.h'" '(should have been 463 characters)'
fi
echo shar: extracting "'ltb.c'" '(6581 characters)'
if test -f 'ltb.c'
then
	echo shar: over-writing existing file "'ltb.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'ltb.c'
X/*
X * ltb.c - Lexical Table Builder
X *
X * Functional description:
X *
X *	This program builds a file containing the data
X *	structures of a compile-time-initialised hash table. 
X *	This hash table may later be used for lexical analysis,
X *	where number of symbols to look up is sufficiently large
X *	to avoid a run-time table initialization.
X *	In order to guarantee the success of this setup, the 
X *	hash routine, the lookup and install routines should be
X *	the same between ltb and the lexical analysis.
X *
X * synopsis:
X *
X *	ltb <input file> [table name]
X *
X * input file format:
X *
X *	<token>  <value identifier> [flag value]
X *
X *	token: 		string of alphanumeric characters to be 
X *		       	matched by the lexical analyser (no blanks).
X *			these token strings are "installed" to a hash
X *			table by ltb to avoid run-time overhead.
X *	value 
X *	identifier:	A constant name to be used internally by the
X *			lexical analyser in place of the actual
X *			token value. a "#define <indentifier> <value>"
X *			is generated for each value identifier, where
X *			value is an odd and unique integer constant. If
X *			the value identifier is a `*' (star), then the
X *			previous value is repeated. Thus:
X *
X * 			      token   ident.   flag
X *
X *				sp	SP	1
X *				space	*	 	{ inherits SP  }
X *				blank	* 	 	{ inherits SP  }
X *				.	.	.
X *				.	.	.
X *
X *	flag value:	An additional integer field to pass flags etc. to
X *			the lexical analyser. If not specified, set to
X *			0. token value field must be present for this field
X *			to be obtained.
X *
X * outputs:
X *
X *	ltb generates two C include files:
X *
X *		[tablename].d:  compile time lexical constants (defines)
X *		[tablename].h:	initialised hash table.
X *
X *	where [tablename] is the name of the hash table as specified
X *	in the command line of ltb. If not specified, "lextab" is used
X *	as a default.
X *
X * routines used by LTB:
X *
X *	hash, lookup and a modified version of install routines,
X *	as defined in K&R, pp. 134 - 136.
X *
X * Application areas:
X *
X *	Lexical analysers for compilers, interpreters, spelling
X *	checkers.
X *
X * Author:
X *	Ozan S. Yigit
X *	Dept. of Computer Science
X *	York University
X *
X */
X
X#define MAXLINE		80
X#define MAXSYM		80
X
X#include <stdio.h>
X#include <ctype.h>
X#include "lookup.h"
X
Xstruct
Xlexlist	(*(*lextable))[];/* global pointer for lexical analyser hash table */
X
Xstatic struct lexlist *hashtab[HASHMAX];
Xstatic struct lexlist *defitab[HASHMAX];
X
Xchar *tabnam;		/* table name */
X
Xextern int hash();
Xextern struct hashlist *lookup();
Xextern struct hashlist *install();
Xextern char *strsave();
Xextern struct lexlist *lexinstal();
Xextern struct lexlist *lexlook();
Xextern struct lexlist *remove();
Xextern FILE *fopen(), *fclose();
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X	FILE *fp;
X	char line[MAXLINE];
X	char sym[MAXSYM],def[MAXSYM];
X	register int val;
X	register int prev, *p;
X	register char *ptr;
X	int flag;
X	struct lexlist *np, *lexlook();
X
X	if (argc <= 2) {
X		fprintf(stderr,"%s [-<base>] <symbol file> [tablename]\r\n",
X		argv[0]);
X		exit(1);
X	}
X
X	if (*argv[1] == '-') {
X		val = atoi(argv[1]+1);	/* skip "-" and convert */
X		val = (val & 1) ? val : val+1;
X		p = (int *)argv[2];
X	}
X	else {
X		val = 1;
X		p = (int *)argv[1];
X	}
X
X	if (argc < 3)
X		tabnam = "lextab";
X	else
X		tabnam = argv[argc-1];
X
X	if ((fp = fopen(p,"r")) == NULL) {
X		fprintf(stderr,"%s:cannot open.\r\n",argv[1]);
X		exit(1);
X	}
X	else {
X		prev = val;
X		while (fgets(line,MAXLINE,fp) != NULL) {
X			if (*line != '!') {
X				flag = 0; 
X				def[0] = '\0';
X				ptr = line;
X				while (isspace(*ptr))
X					ptr++;
X				if (*ptr == '\0')
X					continue;
X				sscanf(line,"%s %s %d",sym,def,&flag);
X				if (!(def[0] == '*' && def[1] == '\0')) {
X					if ((np = lexlook(def,defitab)) == NULL) {
X						/* value define  */
X						lexinstal(def,val,0,defitab);
X						prev = val;
X						val += 2;
X					}
X					else
X						prev = np->val;
X				}
X				 /* lexical token */
X				lexinstal(sym,prev,flag,hashtab);
X			}
X		}
X		defgen();
X		lexgen();
X	}
X}
X/*
X * lexgen - print out the hash table in static form
X *
X */
Xlexgen()
X{
X	register int i;
X	register struct lexlist *np;
X	char filebuf[12];
X	char *file;
X	FILE *op;
X
X	file = filebuf;
X
X	strncpy(file,tabnam,8);
X	strcat(file,".h");
X
X	if ((op = fopen(file,"w")) == NULL) {
X		fprintf(stderr,"%s: cannot create.\r\n",file);
X		exit(1);
X	}
X
X	fprintf(op,"#ifndef STRUC_DEFINED\n\n");
X	fprintf(op,"\/\*\t%s\t\*\/\n\n%s\n%s\n%s\n%s\n%s\n",file,
X	"struct _lex_h { 	char 	*__s;",
X	"		  	int 	 __v;",
X	"		  	int  	 __f;",
X	"		struct  _lex_h  *__l;",
X	"};");
X	fprintf(op,"\n#define STRUC_DEFINED\n#endif\n");
X
X	/*
X			 * generate the hash table entries.
X			 * each entry is followed by the next entry in its
X			 * chain.
X			 * In the operating systems with memory paging, this
X			 * should have the extra advantage of localized
X			 * memory referances.
X			 *
X	 */
X
X	for (i=0; i < HASHMAX; i++)
X		if ((np = hashtab[i]) != NULL)
X			prnode(np,op);
X	/*
X			 * At last, we generate the pointer array (hashtable).
X			 * this table should be assigned to lextable global
X			 * variable before using with lexlook() or lexinstal().
X			 * lextable is defined in lookup.h
X			 *
X	 */
X
X	fprintf(op,"\n\n\/\*  Hash Table \*\/\n\n");
X	fprintf(op,"struct _lex_h *%s[%d] = {\n\t",tabnam,HASHMAX);
X	for (i=0; i < HASHMAX - 1; i++) {
X		np = hashtab[i];
X		if(np == NULL)
X			fprintf(op,"NULL,\t");
X		else
X			fprintf(op,"\&__%s,\t", np->name);
X		if (i % 4 == 0)
X			fprintf(op,"\n\t");
X	}
X	np = hashtab[i];
X	if (np == NULL)
X		fprintf(op,"NULL  };\n");
X	else
X		fprintf(op,"\&__%s   };\n", np->name);
X
X	fclose(op);
X}
X
X/*
X * prnode - print the current node. This routine is 
X *	    recursive such that printing starts from
X *	    the end of the given list
X *
X */
Xprnode(np,op)
Xregister struct
Xlexlist *np;
XFILE *op;
X{
X	if (np->link != NULL)
X		prnode(np->link,op);
X	fprintf(op,"struct\n_lex_h __%s = {  ",
X	np->name);
X	fprintf(op,"\"%s\",\n              %6d,%6d,",
X	np->name,
X	np->val,
X	np->flag);
X	if (np->link != NULL)
X		fprintf(op,"\&__%s };\n",
X		(np->link)->name);
X	else
X		fprintf(op,"NULL };\n");
X}	
X
X/*
X * defgen - generate a file containing the lexical
X *	    constants to be equated to lexical symbols
X */
Xdefgen()
X{
X	register int i;
X	register struct lexlist *np;
X	char *file;
X	char filebuf[12];
X	FILE *op;
X
X	file = filebuf;
X	strncpy(file,tabnam,8);
X	strcat(file,".d");
X
X	if ((op = fopen(file,"w")) == NULL) {
X		fprintf(stderr,"%s: cannot create.\r\n",file);
X		exit(1);
X	}
X	for (i=0; i < HASHMAX; i++) {
X		for (np = defitab[i]; np != NULL; np = np->link)
X			fprintf(op,"\#define  %s\t%d\n",
X			np->name,
X			np->val);
X	}
X	fclose(op);
X}
X
SHAR_EOF
if test 6581 -ne "`wc -c 'ltb.c'`"
then
	echo shar: error transmitting "'ltb.c'" '(should have been 6581 characters)'
fi
echo shar: extracting "'make.sh'" '(426 characters)'
if test -f 'make.sh'
then
	echo shar: over-writing existing file "'make.sh'"
fi
sed 's/^X//' << \SHAR_EOF > 'make.sh'
Xcc -c -DDECL ltb.c
Xcc -c -DDECL look.c
Xlink68 ltb.68k=gems,ltb.o,look.o,gemlib,libf
Xrelmod ltb
Xltb proffsym.new lextab
Xcc -c -DDECL proff.c
Xcc -c -DDECL proff01.c
Xcc -c -DDECL proff02.c
Xcc -c -DDECL lookup.c
Xcc -c -DDECL pinit.c
Xcc -c -DDECL putwrd.c
Xcc -c -DDECL pxlex.c
Xcc -c -DDECL pxxparse.c
Xcc -c -DDECL dostuff2.c
Xcc -c -DDECL eval.c
Xcc -c -DDECL map.c
Xcc -c -DDECL stack.c
Xlink68 [u,com[lnk]]
Xrelmod proff
Xrm proff.68k
SHAR_EOF
if test 426 -ne "`wc -c 'make.sh'`"
then
	echo shar: error transmitting "'make.sh'" '(should have been 426 characters)'
fi
echo shar: extracting "'makefile'" '(376 characters)'
if test -f 'makefile'
then
	echo shar: over-writing existing file "'makefile'"
fi
sed 's/^X//' << \SHAR_EOF > 'makefile'
XCFLAGS=-O
XOBJS= 	proff.o proff01.o proff02.o lookup.o pinit.o putwrd.o\
X	pxlex.o pxxparse.o dostuff2.o eval.o stack.o map.o
Xproff: $(OBJS)
X	cc -s -o proff $(OBJS)
X
X$(OBJS): lextab.h lextab.d
X
Xlextab.h lextab.d: proffsym.new ltb
X	ltb proffsym.new lextab
X
Xltb: ltb.o look.o
X	cc -s -o ltb ltb.o look.o
Xclean:
X	rm proff *.o
Xarch:
X	./archc Makefile *.c *.h proffsym.new >proff.arc
SHAR_EOF
if test 376 -ne "`wc -c 'makefile'`"
then
	echo shar: error transmitting "'makefile'" '(should have been 376 characters)'
fi
echo shar: extracting "'map.c'" '(1222 characters)'
if test -f 'map.c'
then
	echo shar: over-writing existing file "'map.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'map.c'
X#include <stdio.h>
X/*
X * map map every character of s1 that is specified in s2
X * into s3 and replace in s. (source s1 remains untouched)
X */
X 
Xmap(s,s1,s2,s3)
Xregister char *s;
Xregister char *s1;
Xregister char *s2;
Xregister char *s3;
X{
X	char *t, *t1;
X	if (*s1 != '\0') {
X		t = s;
X		t1 = s1;
X		strcpy(t,t1);
X
X		while (*s2 != '\0' && *s3 != '\0') {
X			while (*t1 != '\0') {
X				if (*t1 == *s2)
X					*t = *s3;
X				t++; 
X				t1++;
X			}
X			t = s;
X			t1 = s1;
X			s2++;
X			s3++;
X		}
X	}
X	else
X		*s = '\0';
X}
X
X/*
X * roman - convert a numeric string into roman numerals
X *
X * icon version:
X *procedure roman(n)
X * local arabic, result
X * static equiv
X * initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"]
X * integer(n) > 0 | fail
X * result := ""
X * every arabic := !n do
X *    result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1]
X * if find("*",result) then fail else return result
X * end
X *
X */
Xint 
Xcvtroman(num,rom)
Xchar *num;
Xchar *rom;
X{
X	char tmp[20];
X
Xstatic char *equiv_U[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" };
X
X	*rom = NULL;
X	while (*num != '\0') {
X		map(tmp,rom,"IVXLCDM","XLCDM**");
X		strcpy(rom,tmp);
X		strcat(rom,equiv_U[*num - '0']);
X		num++;
X	}
X	return(strlen(rom));
X}
X
SHAR_EOF
if test 1222 -ne "`wc -c 'map.c'`"
then
	echo shar: error transmitting "'map.c'" '(should have been 1222 characters)'
fi
#	End of shell archive
exit 0

-- 
					Jwahar R. Bammi
			       Usenet:  .....!decvax!cwruecmp!bammi
			        CSnet:  bammi@case
				 Arpa:  bammi%case@csnet-relay
			   CompuServe:  71515,155
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads