1987-03-12 08:23:08 +00:00
|
|
|
%{
|
1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1985-01-08 09:59:28 +00:00
|
|
|
#ifndef NORCSID
|
1994-06-24 11:31:16 +00:00
|
|
|
static char rcsid2[]= "$Id$";
|
1985-01-08 09:59:28 +00:00
|
|
|
#endif
|
|
|
|
|
2013-05-12 19:45:55 +00:00
|
|
|
#include "param.h"
|
|
|
|
#include "varinfo.h"
|
|
|
|
#include "lookup.h"
|
|
|
|
#include "set.h"
|
|
|
|
#include "iocc.h"
|
|
|
|
#include "instruct.h"
|
|
|
|
#include "expr.h"
|
|
|
|
#include "extern.h"
|
2019-05-10 17:17:24 +00:00
|
|
|
#include "subr.h"
|
2013-05-12 19:45:55 +00:00
|
|
|
#include <cgg_cg.h>
|
|
|
|
#include <em_reg.h>
|
|
|
|
#include "y.tab.h"
|
|
|
|
|
|
|
|
extern int emhere;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
extern int mlookup(char *name);
|
1985-01-08 09:59:28 +00:00
|
|
|
|
|
|
|
int lineno=1;
|
|
|
|
extern char *filename;
|
1991-01-11 14:28:59 +00:00
|
|
|
#undef yywrap
|
1985-01-08 09:59:28 +00:00
|
|
|
%}
|
|
|
|
|
|
|
|
%%
|
|
|
|
"/*" { char c;
|
|
|
|
c = input(); if (c=='\n') lineno++;
|
|
|
|
do {
|
|
|
|
while (c!='*') {
|
|
|
|
c = input();
|
|
|
|
if (c=='\n') lineno++;
|
|
|
|
}
|
|
|
|
c = input();
|
|
|
|
if (c=='\n') lineno++;
|
|
|
|
} while (c!='/');
|
|
|
|
}
|
1987-03-02 16:40:14 +00:00
|
|
|
^\#(line)?[ \t]*[0-9]+[ \t]+\".*\".*$ {
|
1985-01-08 09:59:28 +00:00
|
|
|
int ind,ind2;
|
1987-03-02 16:40:14 +00:00
|
|
|
for (ind=0; yytext[ind] < '0' || yytext[ind]>'9'; ind++)
|
|
|
|
;
|
|
|
|
lineno=atoi(&yytext[ind])-1;
|
|
|
|
for(;yytext[ind]!='"';ind++)
|
1985-01-08 09:59:28 +00:00
|
|
|
;
|
|
|
|
for(ind2=ind+1;yytext[ind2]!='"';ind2++)
|
|
|
|
;
|
|
|
|
yytext[ind2]=0;
|
|
|
|
if (strcmp(yytext+ind+1,filename)!=0)
|
|
|
|
filename=mystrcpy(yytext+ind+1);
|
|
|
|
}
|
|
|
|
"==" return(CMPEQ);
|
|
|
|
"!=" return(CMPNE);
|
|
|
|
"<" return(CMPLT);
|
|
|
|
"<=" return(CMPLE);
|
|
|
|
">" return(CMPGT);
|
|
|
|
">=" return(CMPGE);
|
|
|
|
"||" return(OR2);
|
|
|
|
"&&" return(AND2);
|
|
|
|
"<<" return(LSHIFT);
|
|
|
|
">>" return(RSHIFT);
|
|
|
|
"!" return(NOT);
|
|
|
|
"~" return(COMP);
|
|
|
|
":ro" { yylval.yy_int = AD_RO; return(ADORNACCESS); }
|
|
|
|
":wo" { yylval.yy_int = AD_WO; return(ADORNACCESS); }
|
|
|
|
":rw" { yylval.yy_int = AD_RW; return(ADORNACCESS); }
|
|
|
|
":cc" { yylval.yy_int = AD_CC; return(ADORNCC); }
|
|
|
|
\$[0-9]+ { yylval.yy_int = atoi(yytext+1); return(DOLLAR); }
|
|
|
|
\%[0-9]+ { yylval.yy_int = atoi(yytext+1); return(PERCENT); }
|
|
|
|
\%[a-z] { yylval.yy_int = yytext[1]-'a'; return(ALLREG); }
|
|
|
|
[0-9]+|0x[0-9A-Fa-f]+ { yylval.yy_int = myatoi(yytext); return(NUMBER); }
|
|
|
|
[_A-Za-z][_A-Za-z0-9]* { register symbol *sy_p;
|
1991-01-11 14:28:59 +00:00
|
|
|
if (yyleng==3 &&
|
|
|
|
emhere &&
|
|
|
|
(yylval.yy_int=mlookup(yytext))!=0) {
|
|
|
|
return(EMMNEM);
|
|
|
|
}
|
1985-01-08 09:59:28 +00:00
|
|
|
if ((sy_p=lookup(yytext,symkeyw,justlooking))!=0)
|
|
|
|
return(sy_p->sy_value.syv_keywno);
|
|
|
|
yylval.yy_str = mystrcpy(yytext); return(IDENT);
|
|
|
|
}
|
|
|
|
\%[_A-Za-z][_A-Za-z0-9]* { yylval.yy_str = mystrcpy(yytext+1);
|
|
|
|
return(PERC_IDENT);
|
|
|
|
}
|
|
|
|
\"[^"\n]*\" { yytext[yyleng-1]=0;
|
|
|
|
yylval.yy_str = mystrcpy(yytext+1);
|
|
|
|
return(STRING);
|
|
|
|
}
|
|
|
|
[0-9][bf] { yytext[2]=0;
|
|
|
|
yylval.yy_str = mystrcpy(yytext);
|
|
|
|
return(STRING);
|
|
|
|
}
|
|
|
|
\n { lineno++; }
|
|
|
|
[ \t]* ;
|
|
|
|
. return(yytext[0]);
|
|
|
|
%%
|
|
|
|
int skipping=0;
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
int yywrap(void) {
|
1985-01-08 09:59:28 +00:00
|
|
|
|
|
|
|
if (skipping)
|
|
|
|
fatal("EOF reached during error recovery");
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
2006-07-18 17:19:20 +00:00
|
|
|
/* unput isn't technically legal in this section, so we need the
|
|
|
|
* following definition to make it work. */
|
|
|
|
|
|
|
|
#define yytext_ptr yytext
|
|
|
|
|
2019-05-10 17:17:24 +00:00
|
|
|
void skipupto(int tok,char *str) {
|
|
|
|
register int i;
|
1985-01-08 09:59:28 +00:00
|
|
|
|
|
|
|
skipping=1;
|
|
|
|
while (yylex()!=tok)
|
|
|
|
;
|
|
|
|
for(i=strlen(str); i>0; i--)
|
|
|
|
unput(str[i-1]);
|
|
|
|
skipping=0;
|
|
|
|
}
|