xref: /original-bsd/usr.bin/f77/pass1.vax/lex.c (revision 5be0f76f)
1*5be0f76fSbostic /*-
2*5be0f76fSbostic  * Copyright (c) 1980 The Regents of the University of California.
3*5be0f76fSbostic  * All rights reserved.
4*5be0f76fSbostic  *
5*5be0f76fSbostic  * %sccs.include.proprietary.c%
66491bb18Smckusick  */
76491bb18Smckusick 
86491bb18Smckusick #ifndef lint
9*5be0f76fSbostic static char sccsid[] = "@(#)lex.c	5.5 (Berkeley) 04/12/91";
10*5be0f76fSbostic #endif /* not lint */
116491bb18Smckusick 
126491bb18Smckusick /*
136491bb18Smckusick  * lex.c
146491bb18Smckusick  *
156491bb18Smckusick  * Lexical scanner routines for the f77 compiler, pass 1, 4.2 BSD.
166491bb18Smckusick  *
176491bb18Smckusick  * University of Utah CS Dept modification history:
186491bb18Smckusick  *
196491bb18Smckusick  * $Log:	lex.c,v $
205d0597d8Sdonn  * Revision 5.4  86/01/07  14:01:13  donn
215d0597d8Sdonn  * Fix the scanning for character constants in gettok() so that it handles
225d0597d8Sdonn  * the case when an error has occurred and there is no closing quote.
235d0597d8Sdonn  *
245d0597d8Sdonn  * Revision 5.3  85/11/25  00:24:06  donn
255d0597d8Sdonn  * 4.3 beta
265d0597d8Sdonn  *
27c3917a82Sdonn  * Revision 5.2  85/08/10  04:45:41  donn
28c3917a82Sdonn  * Jerry Berkman's changes to ifdef 66 code and handle -r8/double flag.
29c3917a82Sdonn  *
30c3917a82Sdonn  * Revision 5.1  85/08/10  03:48:20  donn
31c3917a82Sdonn  * 4.3 alpha
32c3917a82Sdonn  *
336491bb18Smckusick  * Revision 1.2  84/10/27  02:20:09  donn
346491bb18Smckusick  * Fixed bug where the input file and the name field of the include file
356491bb18Smckusick  * structure shared -- when the input file name was freed, the include file
366491bb18Smckusick  * name got stomped on, leading to peculiar error messages.
376491bb18Smckusick  *
386491bb18Smckusick  */
396491bb18Smckusick 
406491bb18Smckusick #include "defs.h"
416491bb18Smckusick #include "tokdefs.h"
4278adcfb2Sbostic #include "pathnames.h"
436491bb18Smckusick 
446491bb18Smckusick # define BLANK	' '
456491bb18Smckusick # define MYQUOTE (2)
466491bb18Smckusick # define SEOF 0
476491bb18Smckusick 
486491bb18Smckusick /* card types */
496491bb18Smckusick 
506491bb18Smckusick # define STEOF 1
516491bb18Smckusick # define STINITIAL 2
526491bb18Smckusick # define STCONTINUE 3
536491bb18Smckusick 
546491bb18Smckusick /* lex states */
556491bb18Smckusick 
566491bb18Smckusick #define NEWSTMT	1
576491bb18Smckusick #define FIRSTTOKEN	2
586491bb18Smckusick #define OTHERTOKEN	3
596491bb18Smckusick #define RETEOS	4
606491bb18Smckusick 
616491bb18Smckusick 
626491bb18Smckusick LOCAL int stkey;
636491bb18Smckusick LOCAL int lastend = 1;
646491bb18Smckusick ftnint yystno;
656491bb18Smckusick flag intonly;
666491bb18Smckusick LOCAL long int stno;
676491bb18Smckusick LOCAL long int nxtstno;
686491bb18Smckusick LOCAL int parlev;
696491bb18Smckusick LOCAL int expcom;
706491bb18Smckusick LOCAL int expeql;
716491bb18Smckusick LOCAL char *nextch;
726491bb18Smckusick LOCAL char *lastch;
736491bb18Smckusick LOCAL char *nextcd 	= NULL;
746491bb18Smckusick LOCAL char *endcd;
756491bb18Smckusick LOCAL int prevlin;
766491bb18Smckusick LOCAL int thislin;
776491bb18Smckusick LOCAL int code;
786491bb18Smckusick LOCAL int lexstate	= NEWSTMT;
796491bb18Smckusick LOCAL char s[1390];
806491bb18Smckusick LOCAL char *send	= s+20*66;
816491bb18Smckusick LOCAL int nincl	= 0;
826491bb18Smckusick LOCAL char *newname = NULL;
836491bb18Smckusick 
846491bb18Smckusick struct Inclfile
856491bb18Smckusick 	{
866491bb18Smckusick 	struct Inclfile *inclnext;
876491bb18Smckusick 	FILEP inclfp;
886491bb18Smckusick 	char *inclname;
896491bb18Smckusick 	int incllno;
906491bb18Smckusick 	char *incllinp;
916491bb18Smckusick 	int incllen;
926491bb18Smckusick 	int inclcode;
936491bb18Smckusick 	ftnint inclstno;
946491bb18Smckusick 	} ;
956491bb18Smckusick 
966491bb18Smckusick LOCAL struct Inclfile *inclp	=  NULL;
976491bb18Smckusick LOCAL struct Keylist { char *keyname; int keyval; char notinf66; } ;
986491bb18Smckusick LOCAL struct Punctlist { char punchar; int punval; };
996491bb18Smckusick LOCAL struct Fmtlist { char fmtchar; int fmtval; };
1006491bb18Smckusick LOCAL struct Dotlist { char *dotname; int dotval; };
1016491bb18Smckusick LOCAL struct Keylist *keystart[26], *keyend[26];
1026491bb18Smckusick 
1036491bb18Smckusick 
1046491bb18Smckusick 
1056491bb18Smckusick 
inilex(name)1066491bb18Smckusick inilex(name)
1076491bb18Smckusick char *name;
1086491bb18Smckusick {
1096491bb18Smckusick nincl = 0;
1106491bb18Smckusick inclp = NULL;
1116491bb18Smckusick doinclude(name);
1126491bb18Smckusick lexstate = NEWSTMT;
1136491bb18Smckusick return(NO);
1146491bb18Smckusick }
1156491bb18Smckusick 
1166491bb18Smckusick 
1176491bb18Smckusick 
1186491bb18Smckusick /* throw away the rest of the current line */
flline()1196491bb18Smckusick flline()
1206491bb18Smckusick {
1216491bb18Smckusick lexstate = RETEOS;
1226491bb18Smckusick }
1236491bb18Smckusick 
1246491bb18Smckusick 
1256491bb18Smckusick 
lexline(n)1266491bb18Smckusick char *lexline(n)
1276491bb18Smckusick int *n;
1286491bb18Smckusick {
1296491bb18Smckusick *n = (lastch - nextch) + 1;
1306491bb18Smckusick return(nextch);
1316491bb18Smckusick }
1326491bb18Smckusick 
1336491bb18Smckusick 
1346491bb18Smckusick 
1356491bb18Smckusick 
1366491bb18Smckusick 
doinclude(name)1376491bb18Smckusick doinclude(name)
1386491bb18Smckusick char *name;
1396491bb18Smckusick {
1406491bb18Smckusick FILEP fp;
1416491bb18Smckusick struct Inclfile *t;
1426491bb18Smckusick char temp[100];
1436491bb18Smckusick register char *lastslash, *s;
1446491bb18Smckusick 
1456491bb18Smckusick if(inclp)
1466491bb18Smckusick 	{
1476491bb18Smckusick 	inclp->incllno = thislin;
1486491bb18Smckusick 	inclp->inclcode = code;
1496491bb18Smckusick 	inclp->inclstno = nxtstno;
1506491bb18Smckusick 	if(nextcd)
1516491bb18Smckusick 		inclp->incllinp = copyn(inclp->incllen = endcd-nextcd , nextcd);
1526491bb18Smckusick 	else
1536491bb18Smckusick 		inclp->incllinp = 0;
1546491bb18Smckusick 	}
1556491bb18Smckusick nextcd = NULL;
1566491bb18Smckusick 
1576491bb18Smckusick if(++nincl >= MAXINCLUDES)
1586491bb18Smckusick 	fatal("includes nested too deep");
1596491bb18Smckusick if(name[0] == '\0')
1606491bb18Smckusick 	fp = stdin;
1616491bb18Smckusick else if(name[0]=='/' || inclp==NULL)
1626491bb18Smckusick 	fp = fopen(name, "r");
1636491bb18Smckusick else	{
1646491bb18Smckusick 	lastslash = NULL;
1656491bb18Smckusick 	for(s = inclp->inclname ; *s ; ++s)
1666491bb18Smckusick 		if(*s == '/')
1676491bb18Smckusick 			lastslash = s;
1686491bb18Smckusick 	if(lastslash)
1696491bb18Smckusick 		{
1706491bb18Smckusick 		*lastslash = '\0';
1716491bb18Smckusick 		sprintf(temp, "%s/%s", inclp->inclname, name);
1726491bb18Smckusick 		*lastslash = '/';
1736491bb18Smckusick 		}
1746491bb18Smckusick 	else
1756491bb18Smckusick 		strcpy(temp, name);
1766491bb18Smckusick 
1776491bb18Smckusick 	if( (fp = fopen(temp, "r")) == NULL )
1786491bb18Smckusick 		{
17978adcfb2Sbostic 		sprintf(temp, "%s/%s", _PATH_INCLUDES, name);
1806491bb18Smckusick 		fp = fopen(temp, "r");
1816491bb18Smckusick 		}
1826491bb18Smckusick 	if(fp)
1836491bb18Smckusick 		name = copys(temp);
1846491bb18Smckusick 	}
1856491bb18Smckusick 
1866491bb18Smckusick if( fp )
1876491bb18Smckusick 	{
1886491bb18Smckusick 	t = inclp;
1896491bb18Smckusick 	inclp = ALLOC(Inclfile);
1906491bb18Smckusick 	inclp->inclnext = t;
1916491bb18Smckusick 	prevlin = thislin = 0;
1926491bb18Smckusick 	inclp->inclname = name;
1936491bb18Smckusick 	infname = copys(name);
1946491bb18Smckusick 	infile = inclp->inclfp = fp;
1956491bb18Smckusick 	}
1966491bb18Smckusick else
1976491bb18Smckusick 	{
1986491bb18Smckusick 	fprintf(diagfile, "Cannot open file %s", name);
1996491bb18Smckusick 	done(1);
2006491bb18Smckusick 	}
2016491bb18Smckusick }
2026491bb18Smckusick 
2036491bb18Smckusick 
2046491bb18Smckusick 
2056491bb18Smckusick 
popinclude()2066491bb18Smckusick LOCAL popinclude()
2076491bb18Smckusick {
2086491bb18Smckusick struct Inclfile *t;
2096491bb18Smckusick register char *p;
2106491bb18Smckusick register int k;
2116491bb18Smckusick 
2126491bb18Smckusick if(infile != stdin)
2136491bb18Smckusick 	clf(&infile);
2146491bb18Smckusick free(infname);
2156491bb18Smckusick 
2166491bb18Smckusick --nincl;
2176491bb18Smckusick t = inclp->inclnext;
2186491bb18Smckusick free(inclp->inclname);
2196491bb18Smckusick free( (charptr) inclp);
2206491bb18Smckusick inclp = t;
2216491bb18Smckusick if(inclp == NULL)
2226491bb18Smckusick 	return(NO);
2236491bb18Smckusick 
2246491bb18Smckusick infile = inclp->inclfp;
2256491bb18Smckusick infname = copys(inclp->inclname);
2266491bb18Smckusick prevlin = thislin = inclp->incllno;
2276491bb18Smckusick code = inclp->inclcode;
2286491bb18Smckusick stno = nxtstno = inclp->inclstno;
2296491bb18Smckusick if(inclp->incllinp)
2306491bb18Smckusick 	{
2316491bb18Smckusick 	endcd = nextcd = s;
2326491bb18Smckusick 	k = inclp->incllen;
2336491bb18Smckusick 	p = inclp->incllinp;
2346491bb18Smckusick 	while(--k >= 0)
2356491bb18Smckusick 		*endcd++ = *p++;
2366491bb18Smckusick 	free( (charptr) (inclp->incllinp) );
2376491bb18Smckusick 	}
2386491bb18Smckusick else
2396491bb18Smckusick 	nextcd = NULL;
2406491bb18Smckusick return(YES);
2416491bb18Smckusick }
2426491bb18Smckusick 
2436491bb18Smckusick 
2446491bb18Smckusick 
2456491bb18Smckusick 
yylex()2466491bb18Smckusick yylex()
2476491bb18Smckusick {
2486491bb18Smckusick static int  tokno;
2496491bb18Smckusick 
2506491bb18Smckusick 	switch(lexstate)
2516491bb18Smckusick 	{
2526491bb18Smckusick case NEWSTMT :	/* need a new statement */
2536491bb18Smckusick 	if(getcds() == STEOF)
2546491bb18Smckusick 		return(SEOF);
2556491bb18Smckusick 	lastend =  stkey == SEND;
2566491bb18Smckusick 	crunch();
2576491bb18Smckusick 	tokno = 0;
2586491bb18Smckusick 	lexstate = FIRSTTOKEN;
2596491bb18Smckusick 	yystno = stno;
2606491bb18Smckusick 	stno = nxtstno;
2616491bb18Smckusick 	toklen = 0;
2626491bb18Smckusick 	return(SLABEL);
2636491bb18Smckusick 
2646491bb18Smckusick first:
2656491bb18Smckusick case FIRSTTOKEN :	/* first step on a statement */
2666491bb18Smckusick 	analyz();
2676491bb18Smckusick 	lexstate = OTHERTOKEN;
2686491bb18Smckusick 	tokno = 1;
2696491bb18Smckusick 	return(stkey);
2706491bb18Smckusick 
2716491bb18Smckusick case OTHERTOKEN :	/* return next token */
2726491bb18Smckusick 	if(nextch > lastch)
2736491bb18Smckusick 		goto reteos;
2746491bb18Smckusick 	++tokno;
2756491bb18Smckusick 	if( (stkey==SLOGIF || stkey==SELSEIF) && parlev==0 && tokno>3)
2766491bb18Smckusick 		goto first;
2776491bb18Smckusick 
2786491bb18Smckusick 	if(stkey==SASSIGN && tokno==3 && nextch<lastch &&
2796491bb18Smckusick 		nextch[0]=='t' && nextch[1]=='o')
2806491bb18Smckusick 			{
2816491bb18Smckusick 			nextch+=2;
2826491bb18Smckusick 			return(STO);
2836491bb18Smckusick 			}
2846491bb18Smckusick 	return(gettok());
2856491bb18Smckusick 
2866491bb18Smckusick reteos:
2876491bb18Smckusick case RETEOS:
2886491bb18Smckusick 	lexstate = NEWSTMT;
2896491bb18Smckusick 	return(SEOS);
2906491bb18Smckusick 	}
2916491bb18Smckusick fatali("impossible lexstate %d", lexstate);
2926491bb18Smckusick /* NOTREACHED */
2936491bb18Smckusick }
2946491bb18Smckusick 
getcds()2956491bb18Smckusick LOCAL getcds()
2966491bb18Smckusick {
2976491bb18Smckusick register char *p, *q;
2986491bb18Smckusick 
2996491bb18Smckusick 	if (newname)
3006491bb18Smckusick 		{
3016491bb18Smckusick 		free(infname);
3026491bb18Smckusick 		infname = newname;
3036491bb18Smckusick 		newname = NULL;
3046491bb18Smckusick 		}
3056491bb18Smckusick 
3066491bb18Smckusick top:
3076491bb18Smckusick 	if(nextcd == NULL)
3086491bb18Smckusick 		{
3096491bb18Smckusick 		code = getcd( nextcd = s );
3106491bb18Smckusick 		stno = nxtstno;
3116491bb18Smckusick 		if (newname)
3126491bb18Smckusick 			{
3136491bb18Smckusick 			free(infname);
3146491bb18Smckusick 			infname = newname;
3156491bb18Smckusick 			newname = NULL;
3166491bb18Smckusick 			}
3176491bb18Smckusick 		prevlin = thislin;
3186491bb18Smckusick 		}
3196491bb18Smckusick 	if(code == STEOF)
3206491bb18Smckusick 		if( popinclude() )
3216491bb18Smckusick 			goto top;
3226491bb18Smckusick 		else
3236491bb18Smckusick 			return(STEOF);
3246491bb18Smckusick 
3256491bb18Smckusick 	if(code == STCONTINUE)
3266491bb18Smckusick 		{
3276491bb18Smckusick 		if (newname)
3286491bb18Smckusick 			{
3296491bb18Smckusick 			free(infname);
3306491bb18Smckusick 			infname = newname;
3316491bb18Smckusick 			newname = NULL;
3326491bb18Smckusick 			}
3336491bb18Smckusick 		lineno = thislin;
3346491bb18Smckusick 		err("illegal continuation card ignored");
3356491bb18Smckusick 		nextcd = NULL;
3366491bb18Smckusick 		goto top;
3376491bb18Smckusick 		}
3386491bb18Smckusick 
3396491bb18Smckusick 	if(nextcd > s)
3406491bb18Smckusick 		{
3416491bb18Smckusick 		q = nextcd;
3426491bb18Smckusick 		p = s;
3436491bb18Smckusick 		while(q < endcd)
3446491bb18Smckusick 			*p++ = *q++;
3456491bb18Smckusick 		endcd = p;
3466491bb18Smckusick 		}
3476491bb18Smckusick 	for(nextcd = endcd ;
3486491bb18Smckusick 		nextcd+66<=send && (code = getcd(nextcd))==STCONTINUE ;
3496491bb18Smckusick 		nextcd = endcd )
3506491bb18Smckusick 			;
3516491bb18Smckusick 	nextch = s;
3526491bb18Smckusick 	lastch = nextcd - 1;
3536491bb18Smckusick 	if(nextcd >= send)
3546491bb18Smckusick 		nextcd = NULL;
3556491bb18Smckusick 	lineno = prevlin;
3566491bb18Smckusick 	prevlin = thislin;
3576491bb18Smckusick 	return(STINITIAL);
3586491bb18Smckusick }
3596491bb18Smckusick 
getcd(b)3606491bb18Smckusick LOCAL getcd(b)
3616491bb18Smckusick register char *b;
3626491bb18Smckusick {
3636491bb18Smckusick register int c;
3646491bb18Smckusick register char *p, *bend;
3656491bb18Smckusick int speclin;
3666491bb18Smckusick static char a[6];
3676491bb18Smckusick static char *aend	= a+6;
3686491bb18Smckusick int num;
3696491bb18Smckusick 
3706491bb18Smckusick top:
3716491bb18Smckusick 	endcd = b;
3726491bb18Smckusick 	bend = b+66;
3736491bb18Smckusick 	speclin = NO;
3746491bb18Smckusick 
3756491bb18Smckusick 	if( (c = getc(infile)) == '&')
3766491bb18Smckusick 		{
3776491bb18Smckusick 		a[0] = BLANK;
3786491bb18Smckusick 		a[5] = 'x';
3796491bb18Smckusick 		speclin = YES;
3806491bb18Smckusick 		bend = send;
3816491bb18Smckusick 		}
3826491bb18Smckusick 	else if(c=='c' || c=='C' || c=='*')
3836491bb18Smckusick 		{
3846491bb18Smckusick 		while( (c = getc(infile)) != '\n')
3856491bb18Smckusick 			if(c == EOF)
3866491bb18Smckusick 				return(STEOF);
3876491bb18Smckusick 		++thislin;
3886491bb18Smckusick 		goto top;
3896491bb18Smckusick 		}
3906491bb18Smckusick 	else if(c == '#')
3916491bb18Smckusick 		{
3926491bb18Smckusick 		c = getc(infile);
3936491bb18Smckusick 		while (c == BLANK || c == '\t')
3946491bb18Smckusick 			c = getc(infile);
3956491bb18Smckusick 
3966491bb18Smckusick 		num = 0;
3976491bb18Smckusick 		while (isdigit(c))
3986491bb18Smckusick 			{
3996491bb18Smckusick 			num = 10*num + c - '0';
4006491bb18Smckusick 			c = getc(infile);
4016491bb18Smckusick 			}
4026491bb18Smckusick 		thislin = num - 1;
4036491bb18Smckusick 
4046491bb18Smckusick 		while (c == BLANK || c == '\t')
4056491bb18Smckusick 			c = getc(infile);
4066491bb18Smckusick 
4076491bb18Smckusick 		if (c == '"')
4086491bb18Smckusick 			{
4096491bb18Smckusick 			char fname[1024];
4106491bb18Smckusick 			int len = 0;
4116491bb18Smckusick 
4126491bb18Smckusick 			c = getc(infile);
4136491bb18Smckusick 			while (c != '"' && c != '\n')
4146491bb18Smckusick 				{
4156491bb18Smckusick 				fname[len++] = c;
4166491bb18Smckusick 				c = getc(infile);
4176491bb18Smckusick 				}
4186491bb18Smckusick 			fname[len++] = '\0';
4196491bb18Smckusick 
4206491bb18Smckusick 			if (newname)
4216491bb18Smckusick 				free(newname);
4226491bb18Smckusick 			newname = (char *) ckalloc(len);
4236491bb18Smckusick 			strcpy(newname, fname);
4246491bb18Smckusick 			}
4256491bb18Smckusick 
4266491bb18Smckusick 		while (c != '\n')
4276491bb18Smckusick 			if (c == EOF)
4286491bb18Smckusick 				return (STEOF);
4296491bb18Smckusick 			else
4306491bb18Smckusick 				c = getc(infile);
4316491bb18Smckusick 		goto top;
4326491bb18Smckusick 		}
4336491bb18Smckusick 
4346491bb18Smckusick 	else if(c != EOF)
4356491bb18Smckusick 		{
4366491bb18Smckusick 		/* a tab in columns 1-6 skips to column 7 */
4376491bb18Smckusick 		ungetc(c, infile);
4386491bb18Smckusick 		for(p=a; p<aend && (c=getc(infile)) != '\n' && c!=EOF; )
4396491bb18Smckusick 			if(c == '\t')
4406491bb18Smckusick 				{
4416491bb18Smckusick 				while(p < aend)
4426491bb18Smckusick 					*p++ = BLANK;
4436491bb18Smckusick 				speclin = YES;
4446491bb18Smckusick 				bend = send;
4456491bb18Smckusick 				}
4466491bb18Smckusick 			else
4476491bb18Smckusick 				*p++ = c;
4486491bb18Smckusick 		}
4496491bb18Smckusick 	if(c == EOF)
4506491bb18Smckusick 		return(STEOF);
4516491bb18Smckusick 	if(c == '\n')
4526491bb18Smckusick 		{
4536491bb18Smckusick 		while(p < aend)
4546491bb18Smckusick 			*p++ = BLANK;
4556491bb18Smckusick 		if( ! speclin )
4566491bb18Smckusick 			while(endcd < bend)
4576491bb18Smckusick 				*endcd++ = BLANK;
4586491bb18Smckusick 		}
4596491bb18Smckusick 	else	{	/* read body of line */
4606491bb18Smckusick 		while( endcd<bend && (c=getc(infile)) != '\n' && c!=EOF )
4616491bb18Smckusick 			*endcd++ = c;
4626491bb18Smckusick 		if(c == EOF)
4636491bb18Smckusick 			return(STEOF);
4646491bb18Smckusick 		if(c != '\n')
4656491bb18Smckusick 			{
4666491bb18Smckusick 			while( (c=getc(infile)) != '\n')
4676491bb18Smckusick 				if(c == EOF)
4686491bb18Smckusick 					return(STEOF);
4696491bb18Smckusick 			}
4706491bb18Smckusick 
4716491bb18Smckusick 		if( ! speclin )
4726491bb18Smckusick 			while(endcd < bend)
4736491bb18Smckusick 				*endcd++ = BLANK;
4746491bb18Smckusick 		}
4756491bb18Smckusick 	++thislin;
4766491bb18Smckusick 	if( !isspace(a[5]) && a[5]!='0')
4776491bb18Smckusick 		return(STCONTINUE);
4786491bb18Smckusick 	for(p=a; p<aend; ++p)
4796491bb18Smckusick 		if( !isspace(*p) ) goto initline;
4806491bb18Smckusick 	for(p = b ; p<endcd ; ++p)
4816491bb18Smckusick 		if( !isspace(*p) ) goto initline;
4826491bb18Smckusick 	goto top;
4836491bb18Smckusick 
4846491bb18Smckusick initline:
4856491bb18Smckusick 	nxtstno = 0;
4866491bb18Smckusick 	for(p = a ; p<a+5 ; ++p)
4876491bb18Smckusick 		if( !isspace(*p) )
4886491bb18Smckusick 			if(isdigit(*p))
4896491bb18Smckusick 				nxtstno = 10*nxtstno + (*p - '0');
4906491bb18Smckusick 			else	{
4916491bb18Smckusick 				if (newname)
4926491bb18Smckusick 					{
4936491bb18Smckusick 					free(infname);
4946491bb18Smckusick 					infname = newname;
4956491bb18Smckusick 					newname = NULL;
4966491bb18Smckusick 					}
4976491bb18Smckusick 				lineno = thislin;
4986491bb18Smckusick 				err("nondigit in statement number field");
4996491bb18Smckusick 				nxtstno = 0;
5006491bb18Smckusick 				break;
5016491bb18Smckusick 				}
5026491bb18Smckusick 	return(STINITIAL);
5036491bb18Smckusick }
5046491bb18Smckusick 
crunch()5056491bb18Smckusick LOCAL crunch()
5066491bb18Smckusick {
5076491bb18Smckusick register char *i, *j, *j0, *j1, *prvstr;
5086491bb18Smckusick int ten, nh, quote;
5096491bb18Smckusick 
5106491bb18Smckusick /* i is the next input character to be looked at
5116491bb18Smckusick j is the next output character */
5126491bb18Smckusick parlev = 0;
5136491bb18Smckusick expcom = 0;	/* exposed ','s */
5146491bb18Smckusick expeql = 0;	/* exposed equal signs */
5156491bb18Smckusick j = s;
5166491bb18Smckusick prvstr = s;
5176491bb18Smckusick for(i=s ; i<=lastch ; ++i)
5186491bb18Smckusick 	{
5196491bb18Smckusick 	if(isspace(*i) )
5206491bb18Smckusick 		continue;
5216491bb18Smckusick 	if(*i=='\'' ||  *i=='"')
5226491bb18Smckusick 		{
5236491bb18Smckusick 		quote = *i;
5246491bb18Smckusick 		*j = MYQUOTE; /* special marker */
5256491bb18Smckusick 		for(;;)
5266491bb18Smckusick 			{
5276491bb18Smckusick 			if(++i > lastch)
5286491bb18Smckusick 				{
5296491bb18Smckusick 				err("unbalanced quotes; closing quote supplied");
5306491bb18Smckusick 				break;
5316491bb18Smckusick 				}
5326491bb18Smckusick 			if(*i == quote)
5336491bb18Smckusick 				if(i<lastch && i[1]==quote) ++i;
5346491bb18Smckusick 				else break;
5356491bb18Smckusick 			else if(*i=='\\' && i<lastch)
5366491bb18Smckusick 				switch(*++i)
5376491bb18Smckusick 					{
5386491bb18Smckusick 					case 't':
5396491bb18Smckusick 						*i = '\t'; break;
5406491bb18Smckusick 					case 'b':
5416491bb18Smckusick 						*i = '\b'; break;
5426491bb18Smckusick 					case 'n':
5436491bb18Smckusick 						*i = '\n'; break;
5446491bb18Smckusick 					case 'f':
5456491bb18Smckusick 						*i = '\f'; break;
5466491bb18Smckusick 					case 'v':
5476491bb18Smckusick 						*i = '\v'; break;
5486491bb18Smckusick 					case '0':
5496491bb18Smckusick 						*i = '\0'; break;
5506491bb18Smckusick 					default:
5516491bb18Smckusick 						break;
5526491bb18Smckusick 					}
5536491bb18Smckusick 			*++j = *i;
5546491bb18Smckusick 			}
5556491bb18Smckusick 		j[1] = MYQUOTE;
5566491bb18Smckusick 		j += 2;
5576491bb18Smckusick 		prvstr = j;
5586491bb18Smckusick 		}
5596491bb18Smckusick 	else if( (*i=='h' || *i=='H')  && j>prvstr)	/* test for Hollerith strings */
5606491bb18Smckusick 		{
5616491bb18Smckusick 		if( ! isdigit(j[-1])) goto copychar;
5626491bb18Smckusick 		nh = j[-1] - '0';
5636491bb18Smckusick 		ten = 10;
5646491bb18Smckusick 		j1 = prvstr - 1;
5656491bb18Smckusick 		if (j1<j-5) j1=j-5;
5666491bb18Smckusick 		for(j0=j-2 ; j0>j1; -- j0)
5676491bb18Smckusick 			{
5686491bb18Smckusick 			if( ! isdigit(*j0 ) ) break;
5696491bb18Smckusick 			nh += ten * (*j0-'0');
5706491bb18Smckusick 			ten*=10;
5716491bb18Smckusick 			}
5726491bb18Smckusick 		if(j0 <= j1) goto copychar;
5736491bb18Smckusick /* a hollerith must be preceded by a punctuation mark.
5746491bb18Smckusick    '*' is possible only as repetition factor in a data statement
5756491bb18Smckusick    not, in particular, in character*2h
5766491bb18Smckusick */
5776491bb18Smckusick 
5786491bb18Smckusick 		if( !(*j0=='*'&&s[0]=='d') && *j0!='/' && *j0!='(' &&
5796491bb18Smckusick 			*j0!=',' && *j0!='=' && *j0!='.')
5806491bb18Smckusick 				goto copychar;
5816491bb18Smckusick 		if(i+nh > lastch)
5826491bb18Smckusick 			{
5836491bb18Smckusick 			erri("%dH too big", nh);
5846491bb18Smckusick 			nh = lastch - i;
5856491bb18Smckusick 			}
5866491bb18Smckusick 		j0[1] = MYQUOTE; /* special marker */
5876491bb18Smckusick 		j = j0 + 1;
5886491bb18Smckusick 		while(nh-- > 0)
5896491bb18Smckusick 			{
5906491bb18Smckusick 			if(*++i == '\\')
5916491bb18Smckusick 				switch(*++i)
5926491bb18Smckusick 					{
5936491bb18Smckusick 					case 't':
5946491bb18Smckusick 						*i = '\t'; break;
5956491bb18Smckusick 					case 'b':
5966491bb18Smckusick 						*i = '\b'; break;
5976491bb18Smckusick 					case 'n':
5986491bb18Smckusick 						*i = '\n'; break;
5996491bb18Smckusick 					case 'f':
6006491bb18Smckusick 						*i = '\f'; break;
6016491bb18Smckusick 					case '0':
6026491bb18Smckusick 						*i = '\0'; break;
6036491bb18Smckusick 					default:
6046491bb18Smckusick 						break;
6056491bb18Smckusick 					}
6066491bb18Smckusick 			*++j = *i;
6076491bb18Smckusick 			}
6086491bb18Smckusick 		j[1] = MYQUOTE;
6096491bb18Smckusick 		j+=2;
6106491bb18Smckusick 		prvstr = j;
6116491bb18Smckusick 		}
6126491bb18Smckusick 	else	{
6136491bb18Smckusick 		if(*i == '(') ++parlev;
6146491bb18Smckusick 		else if(*i == ')') --parlev;
6156491bb18Smckusick 		else if(parlev == 0)
6166491bb18Smckusick 			if(*i == '=') expeql = 1;
6176491bb18Smckusick 			else if(*i == ',') expcom = 1;
6186491bb18Smckusick copychar:		/*not a string or space -- copy, shifting case if necessary */
6196491bb18Smckusick 		if(shiftcase && isupper(*i))
6206491bb18Smckusick 			*j++ = tolower(*i);
6216491bb18Smckusick 		else	*j++ = *i;
6226491bb18Smckusick 		}
6236491bb18Smckusick 	}
6246491bb18Smckusick lastch = j - 1;
6256491bb18Smckusick nextch = s;
6266491bb18Smckusick }
6276491bb18Smckusick 
analyz()6286491bb18Smckusick LOCAL analyz()
6296491bb18Smckusick {
6306491bb18Smckusick register char *i;
6316491bb18Smckusick 
6326491bb18Smckusick 	if(parlev != 0)
6336491bb18Smckusick 		{
6346491bb18Smckusick 		err("unbalanced parentheses, statement skipped");
6356491bb18Smckusick 		stkey = SUNKNOWN;
6366491bb18Smckusick 		return;
6376491bb18Smckusick 		}
6386491bb18Smckusick 	if(nextch+2<=lastch && nextch[0]=='i' && nextch[1]=='f' && nextch[2]=='(')
6396491bb18Smckusick 		{
6406491bb18Smckusick /* assignment or if statement -- look at character after balancing paren */
6416491bb18Smckusick 		parlev = 1;
6426491bb18Smckusick 		for(i=nextch+3 ; i<=lastch; ++i)
6436491bb18Smckusick 			if(*i == (MYQUOTE))
6446491bb18Smckusick 				{
6456491bb18Smckusick 				while(*++i != MYQUOTE)
6466491bb18Smckusick 					;
6476491bb18Smckusick 				}
6486491bb18Smckusick 			else if(*i == '(')
6496491bb18Smckusick 				++parlev;
6506491bb18Smckusick 			else if(*i == ')')
6516491bb18Smckusick 				{
6526491bb18Smckusick 				if(--parlev == 0)
6536491bb18Smckusick 					break;
6546491bb18Smckusick 				}
6556491bb18Smckusick 		if(i >= lastch)
6566491bb18Smckusick 			stkey = SLOGIF;
6576491bb18Smckusick 		else if(i[1] == '=')
6586491bb18Smckusick 			stkey = SLET;
6596491bb18Smckusick 		else if( isdigit(i[1]) )
6606491bb18Smckusick 			stkey = SARITHIF;
6616491bb18Smckusick 		else	stkey = SLOGIF;
6626491bb18Smckusick 		if(stkey != SLET)
6636491bb18Smckusick 			nextch += 2;
6646491bb18Smckusick 		}
6656491bb18Smckusick 	else if(expeql) /* may be an assignment */
6666491bb18Smckusick 		{
6676491bb18Smckusick 		if(expcom && nextch<lastch &&
6686491bb18Smckusick 			nextch[0]=='d' && nextch[1]=='o')
6696491bb18Smckusick 				{
6706491bb18Smckusick 				stkey = SDO;
6716491bb18Smckusick 				nextch += 2;
6726491bb18Smckusick 				}
6736491bb18Smckusick 		else	stkey = SLET;
6746491bb18Smckusick 		}
6756491bb18Smckusick /* otherwise search for keyword */
6766491bb18Smckusick 	else	{
6776491bb18Smckusick 		stkey = getkwd();
6786491bb18Smckusick 		if(stkey==SGOTO && lastch>=nextch)
6796491bb18Smckusick 			if(nextch[0]=='(')
6806491bb18Smckusick 				stkey = SCOMPGOTO;
6816491bb18Smckusick 			else if(isalpha(nextch[0]))
6826491bb18Smckusick 				stkey = SASGOTO;
6836491bb18Smckusick 		}
6846491bb18Smckusick 	parlev = 0;
6856491bb18Smckusick }
6866491bb18Smckusick 
6876491bb18Smckusick 
6886491bb18Smckusick 
getkwd()6896491bb18Smckusick LOCAL getkwd()
6906491bb18Smckusick {
6916491bb18Smckusick register char *i, *j;
6926491bb18Smckusick register struct Keylist *pk, *pend;
6936491bb18Smckusick int k;
6946491bb18Smckusick 
6956491bb18Smckusick if(! isalpha(nextch[0]) )
6966491bb18Smckusick 	return(SUNKNOWN);
6976491bb18Smckusick k = nextch[0] - 'a';
6986491bb18Smckusick if(pk = keystart[k])
6996491bb18Smckusick 	for(pend = keyend[k] ; pk<=pend ; ++pk )
7006491bb18Smckusick 		{
7016491bb18Smckusick 		i = pk->keyname;
7026491bb18Smckusick 		j = nextch;
7036491bb18Smckusick 		while(*++i==*++j && *i!='\0')
7046491bb18Smckusick 			;
7056491bb18Smckusick 		if(*i=='\0' && j<=lastch+1)
7066491bb18Smckusick 			{
7076491bb18Smckusick 			nextch = j;
708c3917a82Sdonn #ifdef ONLY66
7096491bb18Smckusick 			if(no66flag && pk->notinf66)
7106491bb18Smckusick 				errstr("Not a Fortran 66 keyword: %s",
7116491bb18Smckusick 					pk->keyname);
712c3917a82Sdonn #endif
7136491bb18Smckusick 			return(pk->keyval);
7146491bb18Smckusick 			}
7156491bb18Smckusick 		}
7166491bb18Smckusick return(SUNKNOWN);
7176491bb18Smckusick }
7186491bb18Smckusick 
7196491bb18Smckusick 
7206491bb18Smckusick 
initkey()7216491bb18Smckusick initkey()
7226491bb18Smckusick {
7236491bb18Smckusick extern struct Keylist keys[];
7246491bb18Smckusick register struct Keylist *p;
7256491bb18Smckusick register int i,j;
7266491bb18Smckusick 
7276491bb18Smckusick for(i = 0 ; i<26 ; ++i)
7286491bb18Smckusick 	keystart[i] = NULL;
7296491bb18Smckusick 
7306491bb18Smckusick for(p = keys ; p->keyname ; ++p)
7316491bb18Smckusick 	{
7326491bb18Smckusick 	j = p->keyname[0] - 'a';
7336491bb18Smckusick 	if(keystart[j] == NULL)
7346491bb18Smckusick 		keystart[j] = p;
7356491bb18Smckusick 	keyend[j] = p;
7366491bb18Smckusick 	}
7376491bb18Smckusick }
7386491bb18Smckusick 
gettok()7396491bb18Smckusick LOCAL gettok()
7406491bb18Smckusick {
7416491bb18Smckusick int havdot, havexp, havdbl;
7426491bb18Smckusick int radix, val;
7436491bb18Smckusick extern struct Punctlist puncts[];
7446491bb18Smckusick struct Punctlist *pp;
7456491bb18Smckusick extern struct Fmtlist fmts[];
7466491bb18Smckusick extern struct Dotlist dots[];
7476491bb18Smckusick struct Dotlist *pd;
7486491bb18Smckusick 
7496491bb18Smckusick char *i, *j, *n1, *p;
7506491bb18Smckusick 
7516491bb18Smckusick 	if(*nextch == (MYQUOTE))
7526491bb18Smckusick 		{
7536491bb18Smckusick 		++nextch;
7546491bb18Smckusick 		p = token;
7555d0597d8Sdonn 		while(nextch <= lastch && *nextch != MYQUOTE)
7566491bb18Smckusick 			*p++ = *nextch++;
7576491bb18Smckusick 		++nextch;
7586491bb18Smckusick 		toklen = p - token;
7596491bb18Smckusick 		*p = '\0';
7606491bb18Smckusick 		return (SHOLLERITH);
7616491bb18Smckusick 		}
7626491bb18Smckusick /*
7636491bb18Smckusick 	if(stkey == SFORMAT)
7646491bb18Smckusick 		{
7656491bb18Smckusick 		for(pf = fmts; pf->fmtchar; ++pf)
7666491bb18Smckusick 			{
7676491bb18Smckusick 			if(*nextch == pf->fmtchar)
7686491bb18Smckusick 				{
7696491bb18Smckusick 				++nextch;
7706491bb18Smckusick 				if(pf->fmtval == SLPAR)
7716491bb18Smckusick 					++parlev;
7726491bb18Smckusick 				else if(pf->fmtval == SRPAR)
7736491bb18Smckusick 					--parlev;
7746491bb18Smckusick 				return(pf->fmtval);
7756491bb18Smckusick 				}
7766491bb18Smckusick 			}
7776491bb18Smckusick 		if( isdigit(*nextch) )
7786491bb18Smckusick 			{
7796491bb18Smckusick 			p = token;
7806491bb18Smckusick 			*p++ = *nextch++;
7816491bb18Smckusick 			while(nextch<=lastch && isdigit(*nextch) )
7826491bb18Smckusick 				*p++ = *nextch++;
7836491bb18Smckusick 			toklen = p - token;
7846491bb18Smckusick 			*p = '\0';
7856491bb18Smckusick 			if(nextch<=lastch && *nextch=='p')
7866491bb18Smckusick 				{
7876491bb18Smckusick 				++nextch;
7886491bb18Smckusick 				return(SSCALE);
7896491bb18Smckusick 				}
7906491bb18Smckusick 			else	return(SICON);
7916491bb18Smckusick 			}
7926491bb18Smckusick 		if( isalpha(*nextch) )
7936491bb18Smckusick 			{
7946491bb18Smckusick 			p = token;
7956491bb18Smckusick 			*p++ = *nextch++;
7966491bb18Smckusick 			while(nextch<=lastch &&
7976491bb18Smckusick 				(*nextch=='.' || isdigit(*nextch) || isalpha(*nextch) ))
7986491bb18Smckusick 					*p++ = *nextch++;
7996491bb18Smckusick 			toklen = p - token;
8006491bb18Smckusick 			*p = '\0';
8016491bb18Smckusick 			return(SFIELD);
8026491bb18Smckusick 			}
8036491bb18Smckusick 		goto badchar;
8046491bb18Smckusick 		}
8056491bb18Smckusick /* Not a format statement */
8066491bb18Smckusick 
8076491bb18Smckusick if(needkwd)
8086491bb18Smckusick 	{
8096491bb18Smckusick 	needkwd = 0;
8106491bb18Smckusick 	return( getkwd() );
8116491bb18Smckusick 	}
8126491bb18Smckusick 
8136491bb18Smckusick 	for(pp=puncts; pp->punchar; ++pp)
8146491bb18Smckusick 		if(*nextch == pp->punchar)
8156491bb18Smckusick 			{
8166491bb18Smckusick 			if( (*nextch=='*' || *nextch=='/') &&
8176491bb18Smckusick 				nextch<lastch && nextch[1]==nextch[0])
8186491bb18Smckusick 					{
8196491bb18Smckusick 					if(*nextch == '*')
8206491bb18Smckusick 						val = SPOWER;
8216491bb18Smckusick 					else	val = SCONCAT;
8226491bb18Smckusick 					nextch+=2;
8236491bb18Smckusick 					}
8246491bb18Smckusick 			else	{
8256491bb18Smckusick 				val = pp->punval;
8266491bb18Smckusick 				if(val==SLPAR)
8276491bb18Smckusick 					++parlev;
8286491bb18Smckusick 				else if(val==SRPAR)
8296491bb18Smckusick 					--parlev;
8306491bb18Smckusick 				++nextch;
8316491bb18Smckusick 				}
8326491bb18Smckusick 			return(val);
8336491bb18Smckusick 			}
8346491bb18Smckusick 	if(*nextch == '.')
8356491bb18Smckusick 		if(nextch >= lastch) goto badchar;
8366491bb18Smckusick 		else if(isdigit(nextch[1])) goto numconst;
8376491bb18Smckusick 		else	{
8386491bb18Smckusick 			for(pd=dots ; (j=pd->dotname) ; ++pd)
8396491bb18Smckusick 				{
8406491bb18Smckusick 				for(i=nextch+1 ; i<=lastch ; ++i)
8416491bb18Smckusick 					if(*i != *j) break;
8426491bb18Smckusick 					else if(*i != '.') ++j;
8436491bb18Smckusick 					else	{
8446491bb18Smckusick 						nextch = i+1;
8456491bb18Smckusick 						return(pd->dotval);
8466491bb18Smckusick 						}
8476491bb18Smckusick 				}
8486491bb18Smckusick 			goto badchar;
8496491bb18Smckusick 			}
8506491bb18Smckusick 	if( isalpha(*nextch) )
8516491bb18Smckusick 		{
8526491bb18Smckusick 		p = token;
8536491bb18Smckusick 		*p++ = *nextch++;
8546491bb18Smckusick 		while(nextch<=lastch)
8556491bb18Smckusick 			if( isalpha(*nextch) || isdigit(*nextch) )
8566491bb18Smckusick 				*p++ = *nextch++;
8576491bb18Smckusick 			else break;
8586491bb18Smckusick 		toklen = p - token;
8596491bb18Smckusick 		*p = '\0';
8606491bb18Smckusick 		if(inioctl && nextch<=lastch && *nextch=='=')
8616491bb18Smckusick 			{
8626491bb18Smckusick 			++nextch;
8636491bb18Smckusick 			return(SNAMEEQ);
8646491bb18Smckusick 			}
8656491bb18Smckusick 		if(toklen>8 && eqn(8,token,"function") && isalpha(token[8]) &&
8666491bb18Smckusick 			nextch<lastch && nextch[0]=='(' &&
8676491bb18Smckusick 			(nextch[1]==')' | isalpha(nextch[1])) )
8686491bb18Smckusick 				{
8696491bb18Smckusick 				nextch -= (toklen - 8);
8706491bb18Smckusick 				return(SFUNCTION);
8716491bb18Smckusick 				}
8726491bb18Smckusick 		if(toklen > VL)
8736491bb18Smckusick 			{
8746491bb18Smckusick 			char buff[30];
8756491bb18Smckusick 			sprintf(buff, "name %s too long, truncated to %d",
8766491bb18Smckusick 				token, VL);
8776491bb18Smckusick 			err(buff);
8786491bb18Smckusick 			toklen = VL;
8796491bb18Smckusick 			token[VL] = '\0';
8806491bb18Smckusick 			}
8816491bb18Smckusick 		if(toklen==1 && *nextch==MYQUOTE)
8826491bb18Smckusick 			{
8836491bb18Smckusick 			switch(token[0])
8846491bb18Smckusick 				{
8856491bb18Smckusick 				case 'z':  case 'Z':
8866491bb18Smckusick 				case 'x':  case 'X':
8876491bb18Smckusick 					radix = 16; break;
8886491bb18Smckusick 				case 'o':  case 'O':
8896491bb18Smckusick 					radix = 8; break;
8906491bb18Smckusick 				case 'b':  case 'B':
8916491bb18Smckusick 					radix = 2; break;
8926491bb18Smckusick 				default:
8936491bb18Smckusick 					err("bad bit identifier");
8946491bb18Smckusick 					return(SNAME);
8956491bb18Smckusick 				}
8966491bb18Smckusick 			++nextch;
8976491bb18Smckusick 			for(p = token ; *nextch!=MYQUOTE ; )
8986491bb18Smckusick 				if ( *nextch == BLANK || *nextch == '\t')
8996491bb18Smckusick 					nextch++;
9006491bb18Smckusick 				else
9016491bb18Smckusick 					{
9026491bb18Smckusick 					if (isupper(*nextch))
9036491bb18Smckusick 						*nextch = tolower(*nextch);
9046491bb18Smckusick 					if (hextoi(*p++ = *nextch++) >= radix)
9056491bb18Smckusick 						{
9066491bb18Smckusick 						err("invalid binary character");
9076491bb18Smckusick 						break;
9086491bb18Smckusick 						}
9096491bb18Smckusick 					}
9106491bb18Smckusick 			++nextch;
9116491bb18Smckusick 			toklen = p - token;
9126491bb18Smckusick 			return( radix==16 ? SHEXCON :
9136491bb18Smckusick 				(radix==8 ? SOCTCON : SBITCON) );
9146491bb18Smckusick 			}
9156491bb18Smckusick 		return(SNAME);
9166491bb18Smckusick 		}
9176491bb18Smckusick 	if( ! isdigit(*nextch) ) goto badchar;
9186491bb18Smckusick numconst:
9196491bb18Smckusick 	havdot = NO;
9206491bb18Smckusick 	havexp = NO;
9216491bb18Smckusick 	havdbl = NO;
9226491bb18Smckusick 	for(n1 = nextch ; nextch<=lastch ; ++nextch)
9236491bb18Smckusick 		{
9246491bb18Smckusick 		if(*nextch == '.')
9256491bb18Smckusick 			if(havdot) break;
9266491bb18Smckusick 			else if(nextch+2<=lastch && isalpha(nextch[1])
9276491bb18Smckusick 				&& isalpha(nextch[2]))
9286491bb18Smckusick 					break;
9296491bb18Smckusick 			else	havdot = YES;
9306491bb18Smckusick 		else if( !intonly && (*nextch=='d' || *nextch=='e') )
9316491bb18Smckusick 			{
9326491bb18Smckusick 			p = nextch;
9336491bb18Smckusick 			havexp = YES;
9346491bb18Smckusick 			if(*nextch == 'd')
9356491bb18Smckusick 				havdbl = YES;
9366491bb18Smckusick 			if(nextch<lastch)
9376491bb18Smckusick 				if(nextch[1]=='+' || nextch[1]=='-')
9386491bb18Smckusick 					++nextch;
9396491bb18Smckusick 			if( (nextch >= lastch) || ! isdigit(*++nextch) )
9406491bb18Smckusick 				{
9416491bb18Smckusick 				nextch = p;
9426491bb18Smckusick 				havdbl = havexp = NO;
9436491bb18Smckusick 				break;
9446491bb18Smckusick 				}
9456491bb18Smckusick 			for(++nextch ;
9466491bb18Smckusick 				nextch<=lastch && isdigit(*nextch);
9476491bb18Smckusick 				++nextch);
9486491bb18Smckusick 			break;
9496491bb18Smckusick 			}
9506491bb18Smckusick 		else if( ! isdigit(*nextch) )
9516491bb18Smckusick 			break;
9526491bb18Smckusick 		}
9536491bb18Smckusick 	p = token;
9546491bb18Smckusick 	i = n1;
9556491bb18Smckusick 	while(i < nextch)
9566491bb18Smckusick 		*p++ = *i++;
9576491bb18Smckusick 	toklen = p - token;
9586491bb18Smckusick 	*p = '\0';
9596491bb18Smckusick 	if(havdbl) return(SDCON);
960c3917a82Sdonn 	if(havdot || havexp) return( dblflag ? SDCON : SRCON);
9616491bb18Smckusick 	return(SICON);
9626491bb18Smckusick badchar:
9636491bb18Smckusick 	s[0] = *nextch++;
9646491bb18Smckusick 	return(SUNKNOWN);
9656491bb18Smckusick }
9666491bb18Smckusick 
9676491bb18Smckusick /* KEYWORD AND SPECIAL CHARACTER TABLES
9686491bb18Smckusick */
9696491bb18Smckusick 
9706491bb18Smckusick struct Punctlist puncts[ ] =
9716491bb18Smckusick 	{
9726491bb18Smckusick 	'(', SLPAR,
9736491bb18Smckusick 	')', SRPAR,
9746491bb18Smckusick 	'=', SEQUALS,
9756491bb18Smckusick 	',', SCOMMA,
9766491bb18Smckusick 	'+', SPLUS,
9776491bb18Smckusick 	'-', SMINUS,
9786491bb18Smckusick 	'*', SSTAR,
9796491bb18Smckusick 	'/', SSLASH,
9806491bb18Smckusick 	'$', SCURRENCY,
9816491bb18Smckusick 	':', SCOLON,
9826491bb18Smckusick 	0, 0 } ;
9836491bb18Smckusick 
9846491bb18Smckusick /*
9856491bb18Smckusick LOCAL struct Fmtlist  fmts[ ] =
9866491bb18Smckusick 	{
9876491bb18Smckusick 	'(', SLPAR,
9886491bb18Smckusick 	')', SRPAR,
9896491bb18Smckusick 	'/', SSLASH,
9906491bb18Smckusick 	',', SCOMMA,
9916491bb18Smckusick 	'-', SMINUS,
9926491bb18Smckusick 	':', SCOLON,
9936491bb18Smckusick 	0, 0 } ;
9946491bb18Smckusick */
9956491bb18Smckusick 
9966491bb18Smckusick LOCAL struct Dotlist  dots[ ] =
9976491bb18Smckusick 	{
9986491bb18Smckusick 	"and.", SAND,
9996491bb18Smckusick 	"or.", SOR,
10006491bb18Smckusick 	"not.", SNOT,
10016491bb18Smckusick 	"true.", STRUE,
10026491bb18Smckusick 	"false.", SFALSE,
10036491bb18Smckusick 	"eq.", SEQ,
10046491bb18Smckusick 	"ne.", SNE,
10056491bb18Smckusick 	"lt.", SLT,
10066491bb18Smckusick 	"le.", SLE,
10076491bb18Smckusick 	"gt.", SGT,
10086491bb18Smckusick 	"ge.", SGE,
10096491bb18Smckusick 	"neqv.", SNEQV,
10106491bb18Smckusick 	"eqv.", SEQV,
10116491bb18Smckusick 	0, 0 } ;
10126491bb18Smckusick 
10136491bb18Smckusick LOCAL struct Keylist  keys[ ] =
10146491bb18Smckusick 	{
10156491bb18Smckusick 	 	{ "assign",  SASSIGN  },
10166491bb18Smckusick 	 	{ "automatic",  SAUTOMATIC, YES  },
10176491bb18Smckusick 	 	{ "backspace",  SBACKSPACE  },
10186491bb18Smckusick 	 	{ "blockdata",  SBLOCK  },
10196491bb18Smckusick 	 	{ "call",  SCALL  },
10206491bb18Smckusick 	 	{ "character",  SCHARACTER, YES  },
10216491bb18Smckusick 	 	{ "close",  SCLOSE, YES  },
10226491bb18Smckusick 	 	{ "common",  SCOMMON  },
10236491bb18Smckusick 	 	{ "complex",  SCOMPLEX  },
10246491bb18Smckusick 	 	{ "continue",  SCONTINUE  },
10256491bb18Smckusick 	 	{ "data",  SDATA  },
10266491bb18Smckusick 	 	{ "dimension",  SDIMENSION  },
10276491bb18Smckusick 	 	{ "doubleprecision",  SDOUBLE  },
10286491bb18Smckusick 	 	{ "doublecomplex", SDCOMPLEX, YES  },
10296491bb18Smckusick 	 	{ "elseif",  SELSEIF, YES  },
10306491bb18Smckusick 	 	{ "else",  SELSE, YES  },
10316491bb18Smckusick 	 	{ "endfile",  SENDFILE  },
10326491bb18Smckusick 	 	{ "endif",  SENDIF, YES  },
10336491bb18Smckusick 	 	{ "end",  SEND  },
10346491bb18Smckusick 	 	{ "entry",  SENTRY, YES  },
10356491bb18Smckusick 	 	{ "equivalence",  SEQUIV  },
10366491bb18Smckusick 	 	{ "external",  SEXTERNAL  },
10376491bb18Smckusick 	 	{ "format",  SFORMAT  },
10386491bb18Smckusick 	 	{ "function",  SFUNCTION  },
10396491bb18Smckusick 	 	{ "goto",  SGOTO  },
10406491bb18Smckusick 	 	{ "implicit",  SIMPLICIT, YES  },
10416491bb18Smckusick 	 	{ "include",  SINCLUDE, YES  },
10426491bb18Smckusick 	 	{ "inquire",  SINQUIRE, YES  },
10436491bb18Smckusick 	 	{ "intrinsic",  SINTRINSIC, YES  },
10446491bb18Smckusick 	 	{ "integer",  SINTEGER  },
10456491bb18Smckusick 	 	{ "logical",  SLOGICAL  },
10466491bb18Smckusick #ifdef NAMELIST
10476491bb18Smckusick 		{ "namelist", SNAMELIST, YES },
10486491bb18Smckusick #endif
10496491bb18Smckusick 		{ "none", SUNDEFINED, YES },
10506491bb18Smckusick 	 	{ "open",  SOPEN, YES  },
10516491bb18Smckusick 	 	{ "parameter",  SPARAM, YES  },
10526491bb18Smckusick 	 	{ "pause",  SPAUSE  },
10536491bb18Smckusick 	 	{ "print",  SPRINT  },
10546491bb18Smckusick 	 	{ "program",  SPROGRAM, YES  },
10556491bb18Smckusick 	 	{ "punch",  SPUNCH, YES  },
10566491bb18Smckusick 	 	{ "read",  SREAD  },
10576491bb18Smckusick 	 	{ "real",  SREAL  },
10586491bb18Smckusick 	 	{ "return",  SRETURN  },
10596491bb18Smckusick 	 	{ "rewind",  SREWIND  },
10606491bb18Smckusick 	 	{ "save",  SSAVE, YES  },
10616491bb18Smckusick 	 	{ "static",  SSTATIC, YES  },
10626491bb18Smckusick 	 	{ "stop",  SSTOP  },
10636491bb18Smckusick 	 	{ "subroutine",  SSUBROUTINE  },
10646491bb18Smckusick 	 	{ "then",  STHEN, YES  },
10656491bb18Smckusick 	 	{ "undefined", SUNDEFINED, YES  },
10666491bb18Smckusick 	 	{ "write",  SWRITE  },
10676491bb18Smckusick 			{ 0, 0 }
10686491bb18Smckusick 	};
1069