typedef union { int ival; ptr pval; } YYSTYPE;
ptr mkdef(), mkcomm(), mkname(), mkimcon();
#define RET(x) { RETI(x,x); }
#define RETL(yv,yl) {yylval=prevl=yl;igeol=comneed=0;return(prevv=yv); }
#define RETP(yv,yl) {yylval.pval=prevl.pval=yl;igeol=comneed=0;return(prevv=yv); }
#define RETI(yv,yl) {yylval.ival=prevl.ival=yl;igeol=comneed=0;return(prevv=yv); }
#define REL(n) { RETI(RELOP, OPREL+n);}
#define AS(n) { RETI(ASGNOP, OPASGN+n); }
#define RETC(x) { RETP(CONST, mkconst(x,yytext) ); }
#define RETZ(x) { yytext[yyleng-1] = '\0'; RETP(CONST, mkimcon(x,yytext) ); }
if(lettneed && yyleng==1)
{ RETI(LETTER, yytext[0]); }
for(q2=q1=yytext+yyleng+1 ; (*q1 = efgetc)!='\n' ; ++q1)
{ RETP(OPTNAME, copys(yytext)); }
else if(comneed && ( (q=name(yytext,1))==NULL || q->tag!=TDEFINE) )
{ RETP(COMNAME, mkcomm(yytext) ); }
else if(q = name(yytext,1)) switch(q->tag)
filelines[filedepth] = yylineno;
filemacs[filedepth] = efmacp;
pushchars[filedepth] = (yysptr>yysbuf?
if(++filedepth >= MAXINCLUDEDEPTH)
fatal("macro or include too deep");
filelines[filedepth] = yylineno = 1;
filenames[filedepth] = NULL;
break; /*now process new input */
while((c=input())!=';'&&c!='\n'&&c!=EOF)
fatal1("lex: impossible type code %d", q->tag);
else RETP(NAME, mkname(yytext) );
"}" { if(iobrlevel>0) RET(RBRACK); rket = 1; RET(EOS); }
<DOTSON>"."[cC][oO][rR]"." |
<DOTSON>"."[aA][nN][dD]"." |
<DOTSON>"."[cC][aA][nN][dD]"." |
<DOTSON>"."[nN][oO][tT]"." |
"-" RETI(ADDOP, OPMINUS);
"*" RETI(MULTOP, OPSTAR);
"/" RETI(MULTOP, OPSLASH);
"^" RETI(POWER, OPPOWER);
"++" RETI(DOUBLEADDOP, OPPLUS);
"--" RETI(DOUBLEADDOP, OPMINUS);
\"[^\n"]*\" { yytext[yyleng-1] = '\0'; p = mkconst(TYCHAR,yytext+1);
{D}+[hH] { /* nh construct */
yytext[yyleng-1] = '\0'; n = convci(yytext);
if( (c=yytext[i]=input()) == '\n' || c=='\0') break;
p = mkconst(TYCHAR,yytext);
{D}*"."{D}+ RETC(TYREAL);
{D}*"."{D}+{e} RETC(TYREAL);
{D}*"."{D}+{d} RETC(TYLREAL);
{D}+{i} { yytext[yyleng-1] = '.';
RETP(CONST,mkimcon(TYCOMPLEX,yytext)); }
{D}*"."{D}+{i} RETZ(TYCOMPLEX);
{D}*"."{D}+{e}{i} RETZ(TYCOMPLEX);
{D}*"."{D}+{d}{i} RETZ(TYLCOMPLEX);
"#".* { if(! nocommentflag) goto litline; }
^"%".* { if(thisexec) thisexec->nftnst += 2;
RETP(ESCAPE, copys(yytext));
litline: p = mkchain( copys(yytext), CHNULL);
if(inproc==0 && yytext[0]=='%')
prevcomments = hookup(prevcomments, p);
comments = hookup(comments,p);
\n { if(igeol) { igeol=0; prevv = NEWLINE; }
else if(prevv>=NAME || prevv==RPAR || prevv==RBRACK
|| prevv== -1 || prevv==QUALOP)
fprintf(diagfile, "Bad input character %c %s\n", yytext[0], linerr());
^[ \t]*[iI][nN][cC][lL][uU][dD][eE].*\n { /* Include statement */
for(q1=yytext ; *q1==' ' || *q1=='\t' ; ++q1) ;
for(q1 += 7 ; *q1==' ' || *q1=='\t' ||
*q1=='\'' || *q1=='"' || *q1=='(' ; ++q1 )
if(*q1=='"' || *q1=='\'')
for(q2=q1 ; *q2!='\0' && *q2!=' ' && *q2!='\n' &&
*q2!='\'' && *q2!='"' && *q2!=')' ; ++q2 )
for(k=0; (q = name(q1,1)) && q->tag==TDEFINE ; ++k)
fatal1("Macros too deep for %s", yytext);
if( (fd = opincl(&q1)) == NULL)
fprintf(diagfile, "Cannot open file %s. Stop.\n", q1);
filelines[filedepth] = yylineno;
pushchars[filedepth] = '\n';
if(++filedepth >= MAXINCLUDEDEPTH)
fatal("macro or include too deep");
fileptrs[filedepth] = yyin = fd;
filenames[filedepth] = copys(q1);
filelines[filedepth] = yylineno = 1;
filemacs[filedepth] = NULL;
cfree(filenames[filedepth]);
if( filemacs[filedepth] )
efmacp = filemacs[filedepth];
yyin = fileptrs[filedepth];
yylineno = filelines[filedepth];
if(pushchars[filedepth] != -1)
unput( pushchars[filedepth] );
lower(s) /* replace upper with lower case letters */
return( fopen(*namep, "r") );
/* On Unix, follow the C include conventions */
register char *s, *lastslash;
char *dir, *name, temp[100];
return( fopen(name, "r") );
for(i = filedepth ; i>=0 ; --i)
sprintf(temp, "%s/%s", dir, name);
if( fp = fopen(temp, "r") )
sprintf(temp, "/usr/include/%s", name);