home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
100-199
/
ff114.lzh
/
CDecl
/
cdlex.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-11-22
|
14KB
|
903 lines
#ifdef unix
# include "stdio.h"
#endif
# define U(x) x
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
# define YYLMAX 200
# define output(c) putc(c,yyout)
# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
# define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
int yyleng; extern char yytext[];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
FILE *yyin = {stdin}, *yyout = {stdout};
extern int yylineno;
struct yysvf {
struct yywork *yystoff;
struct yysvf *yyother;
int *yystops;};
struct yysvf *yyestate;
extern struct yysvf yysvec[], *yybgin;
#include <ctype.h>
char *visible();
# define YYNEWLINE 10
yylex(){
int nstr; extern int yyprevious;
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
return ARRAY;
break;
case 2:
return AS;
break;
case 3:
return CAST;
break;
case 4:
return DECLARE;
break;
case 5:
return EXPLAIN;
break;
case 6:
return FUNCTION;
break;
case 7:
return HELP;
break;
case 8:
return INTO;
break;
case 9:
return OF;
break;
case 10:
return POINTER;
break;
case 11:
return RETURNING;
break;
case 12:
return TO;
break;
case 13:
{ yylval.dynstr = ds(yytext); return CHAR; }
break;
case 14:
{ yylval.dynstr = ds(yytext); return DOUBLE; }
break;
case 15:
{ yylval.dynstr = ds(yytext); return STRUCTUNION; }
break;
case 16:
{ yylval.dynstr = ds(yytext); return FLOAT; }
break;
case 17:
{ yylval.dynstr = ds(yytext); return INT; }
break;
case 18:
{ yylval.dynstr = ds(yytext); return LONG; }
break;
case 19:
{ yylval.dynstr = ds(yytext); return SHORT; }
break;
case 20:
{ yylval.dynstr = ds(yytext); return STRUCTUNION; }
break;
case 21:
{ yylval.dynstr = ds(yytext); return STRUCTUNION; }
break;
case 22:
{ yylval.dynstr = ds(yytext); return UNSIGNED; }
break;
case 23:
{ yylval.dynstr = ds(yytext); return NAME; }
break;
case 24:
{ yylval.dynstr = ds(yytext); return NUMBER; }
break;
case 25:
;
break;
case 26:
return *yytext;
break;
case 27:
{
printf("bad character '%s'\n",visible(*yytext));
return *yytext;
}
break;
case -1:
break;
default:
fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
char *
visible(c)
{
static char buf[5];
c &= 0377;
if (isprint(c)) {
buf[0] = c;
buf[1] = '\0';
} else
sprintf(buf,"\\%02o",c);
return buf;
}
int yyvstop[] = {
0,
27,
0,
25,
27,
0,
26,
0,
26,
27,
0,
24,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
23,
27,
0,
24,
0,
23,
0,
23,
0,
2,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
9,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
12,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
17,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
3,
23,
0,
13,
23,
0,
23,
0,
23,
0,
15,
23,
0,
23,
0,
23,
0,
23,
0,
7,
23,
0,
8,
23,
0,
18,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
1,
23,
0,
23,
0,
23,
0,
23,
0,
16,
23,
0,
23,
0,
23,
0,
23,
0,
19,
23,
0,
23,
0,
21,
23,
0,
23,
0,
23,
0,
14,
23,
0,
23,
0,
23,
0,
23,
0,
23,
0,
20,
23,
0,
23,
0,
4,
23,
0,
5,
23,
0,
23,
0,
10,
23,
0,
23,
0,
23,
0,
6,
23,
0,
23,
0,
22,
23,
0,
11,
23,
0,
0};
# define YYTYPE char
struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0, 0,0, 1,3, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,4, 1,5,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 1,6, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 1,7, 7,23, 7,23,
7,23, 7,23, 7,23, 7,23,
7,23, 7,23, 7,23, 7,23,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,8, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,9, 0,0,
1,10, 1,11, 1,12, 1,13,
10,27, 1,14, 1,15, 14,35,
17,38, 1,16, 11,29, 10,28,
1,17, 1,18, 15,36, 1,19,
1,20, 1,21, 1,22, 2,9,
11,30, 2,10, 2,11, 2,12,
2,13, 12,31, 2,14, 2,15,
9,25, 9,26, 2,16, 16,37,
18,39, 2,17, 2,18, 12,32,
2,19, 2,20, 2,21, 2,22,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 19,40, 21,43,
22,44, 25,45, 27,46, 28,47,
29,48, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 30,49,
31,50, 32,51, 33,52, 8,24,
34,53, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 8,24,
8,24, 8,24, 8,24, 13,33,
20,41, 35,54, 36,55, 37,56,
39,57, 40,58, 41,59, 42,60,
13,34, 44,61, 45,63, 46,64,
20,42, 47,65, 48,66, 49,67,
50,68, 51,69, 52,70, 44,62,
53,71, 54,72, 55,73, 56,74,
57,75, 58,76, 59,77, 60,78,
61,79, 62,80, 63,81, 66,82,
67,83, 69,84, 70,85, 71,86,
75,87, 76,88, 77,89, 78,90,
79,91, 80,92, 82,93, 83,94,
84,95, 86,96, 87,97, 88,98,
90,99, 92,100, 93,101, 95,102,
96,103, 97,104, 98,105, 100,106,
103,107, 105,108, 106,109, 108,110,
0,0};
struct yysvf yysvec[] = {
0, 0, 0,
yycrank+-1, 0, 0,
yycrank+-22, yysvec+1, 0,
yycrank+0, 0, yyvstop+1,
yycrank+0, 0, yyvstop+3,
yycrank+0, 0, yyvstop+6,
yycrank+0, 0, yyvstop+8,
yycrank+2, 0, yyvstop+11,
yycrank+92, 0, yyvstop+14,
yycrank+14, yysvec+8, yyvstop+17,
yycrank+7, yysvec+8, yyvstop+20,
yycrank+9, yysvec+8, yyvstop+23,
yycrank+15, yysvec+8, yyvstop+26,
yycrank+107, yysvec+8, yyvstop+29,
yycrank+6, yysvec+8, yyvstop+32,
yycrank+4, yysvec+8, yyvstop+35,
yycrank+20, yysvec+8, yyvstop+38,
yycrank+6, yysvec+8, yyvstop+41,
yycrank+21, yysvec+8, yyvstop+44,
yycrank+49, yysvec+8, yyvstop+47,
yycrank+112, yysvec+8, yyvstop+50,
yycrank+40, yysvec+8, yyvstop+53,
yycrank+42, yysvec+8, yyvstop+56,
yycrank+0, yysvec+7, yyvstop+59,
yycrank+0, yysvec+8, yyvstop+61,
yycrank+39, yysvec+8, yyvstop+63,
yycrank+0, yysvec+8, yyvstop+65,
yycrank+39, yysvec+8, yyvstop+68,
yycrank+58, yysvec+8, yyvstop+70,
yycrank+57, yysvec+8, yyvstop+72,
yycrank+66, yysvec+8, yyvstop+74,
yycrank+67, yysvec+8, yyvstop+76,
yycrank+73, yysvec+8, yyvstop+78,
yycrank+75, yysvec+8, yyvstop+80,
yycrank+78, yysvec+8, yyvstop+82,
yycrank+109, yysvec+8, yyvstop+84,
yycrank+102, yysvec+8, yyvstop+86,
yycrank+109, yysvec+8, yyvstop+88,
yycrank+0, yysvec+8, yyvstop+90,
yycrank+115, yysvec+8, yyvstop+93,
yycrank+105, yysvec+8, yyvstop+95,
yycrank+111, yysvec+8, yyvstop+97,
yycrank+109, yysvec+8, yyvstop+99,
yycrank+0, yysvec+8, yyvstop+101,
yycrank+120, yysvec+8, yyvstop+104,
yycrank+129, yysvec+8, yyvstop+106,
yycrank+111, yysvec+8, yyvstop+108,
yycrank+115, yysvec+8, yyvstop+110,
yycrank+122, yysvec+8, yyvstop+112,
yycrank+133, yysvec+8, yyvstop+114,
yycrank+123, yysvec+8, yyvstop+116,
yycrank+125, yysvec+8, yyvstop+118,
yycrank+137, yysvec+8, yyvstop+120,
yycrank+137, yysvec+8, yyvstop+122,
yycrank+125, yysvec+8, yyvstop+124,
yycrank+127, yysvec+8, yyvstop+126,
yycrank+136, yysvec+8, yyvstop+129,
yycrank+130, yysvec+8, yyvstop+131,
yycrank+124, yysvec+8, yyvstop+133,
yycrank+128, yysvec+8, yyvstop+135,
yycrank+126, yysvec+8, yyvstop+137,
yycrank+133, yysvec+8, yyvstop+139,
yycrank+140, yysvec+8, yyvstop+141,
yycrank+125, yysvec+8, yyvstop+143,
yycrank+0, yysvec+8, yyvstop+145,
yycrank+0, yysvec+8, yyvstop+148,
yycrank+150, yysvec+8, yyvstop+151,
yycrank+140, yysvec+8, yyvstop+153,
yycrank+0, yysvec+8, yyvstop+155,
yycrank+152, yysvec+8, yyvstop+158,
yycrank+134, yysvec+8, yyvstop+160,
yycrank+135, yysvec+8, yyvstop+162,
yycrank+0, yysvec+8, yyvstop+164,
yycrank+0, yysvec+8, yyvstop+167,
yycrank+0, yysvec+8, yyvstop+170,
yycrank+136, yysvec+8, yyvstop+173,
yycrank+139, yysvec+8, yyvstop+175,
yycrank+138, yysvec+8, yyvstop+177,
yycrank+156, yysvec+8, yyvstop+179,
yycrank+146, yysvec+8, yyvstop+181,
yycrank+154, yysvec+8, yyvstop+183,
yycrank+0, yysvec+8, yyvstop+185,
yycrank+144, yysvec+8, yyvstop+188,
yycrank+158, yysvec+8, yyvstop+190,
yycrank+155, yysvec+8, yyvstop+192,
yycrank+0, yysvec+8, yyvstop+194,
yycrank+156, yysvec+8, yyvstop+197,
yycrank+161, yysvec+8, yyvstop+199,
yycrank+153, yysvec+8, yyvstop+201,
yycrank+0, yysvec+8, yyvstop+203,
yycrank+148, yysvec+8, yyvstop+206,
yycrank+0, yysvec+8, yyvstop+208,
yycrank+155, yysvec+8, yyvstop+211,
yycrank+165, yysvec+8, yyvstop+213,
yycrank+0, yysvec+8, yyvstop+215,
yycrank+157, yysvec+8, yyvstop+218,
yycrank+157, yysvec+8, yyvstop+220,
yycrank+155, yysvec+8, yyvstop+222,
yycrank+165, yysvec+8, yyvstop+224,
yycrank+0, yysvec+8, yyvstop+226,
yycrank+170, yysvec+8, yyvstop+229,
yycrank+0, yysvec+8, yyvstop+231,
yycrank+0, yysvec+8, yyvstop+234,
yycrank+162, yysvec+8, yyvstop+237,
yycrank+0, yysvec+8, yyvstop+239,
yycrank+163, yysvec+8, yyvstop+242,
yycrank+174, yysvec+8, yyvstop+244,
yycrank+0, yysvec+8, yyvstop+246,
yycrank+172, yysvec+8, yyvstop+249,
yycrank+0, yysvec+8, yyvstop+251,
yycrank+0, yysvec+8, yyvstop+254,
0, 0, 0};
struct yywork *yytop = yycrank+275;
struct yysvf *yybgin = yysvec+1;
char yymatch[] = {
00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
01 ,011 ,012 ,01 ,01 ,01 ,01 ,01 ,
01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
011 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
'(' ,'(' ,'(' ,01 ,01 ,01 ,01 ,01 ,
'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
'0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 ,
01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'(' ,01 ,'(' ,01 ,'A' ,
01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 ,
0};
char yyextra[] = {
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0};
/* #ident "@(#)libl:lib/ncform 1.3" */
int yylineno =1;
# define YYU(x) x
# define NLSTATE yyprevious=YYNEWLINE
char yytext[YYLMAX];
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
char yysbuf[YYLMAX];
char *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
yylook(){
register struct yysvf *yystate, **lsp;
register struct yywork *yyt;
struct yysvf *yyz;
int yych, yyfirst;
struct yywork *yyr;
# ifdef LEXDEBUG
int debug;
# endif
char *yylastch;
/* start off machines */
# ifdef LEXDEBUG
debug = 0;
# endif
yyfirst=1;
if (!yymorfg)
yylastch = yytext;
else {
yymorfg=0;
yylastch = yytext+yyleng;
}
for(;;){
lsp = yylstate;
yyestate = yystate = yybgin;
if (yyprevious==YYNEWLINE) yystate++;
for (;;){
# ifdef LEXDEBUG
if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
# endif
yyt = yystate->yystoff;
if(yyt == yycrank && !yyfirst){ /* may not be any transitions */
yyz = yystate->yyother;
if(yyz == 0)break;
if(yyz->yystoff == yycrank)break;
}
*yylastch++ = yych = input();
yyfirst=0;
tryagain:
# ifdef LEXDEBUG
if(debug){
fprintf(yyout,"char ");
allprint(yych);
putchar('\n');
}
# endif
yyr = yyt;
if ( (int)yyt > (int)yycrank){
yyt = yyr + yych;
if (yyt <= yytop && yyt->verify+yysvec == yystate){
if(yyt->advance+yysvec == YYLERR) /* error transitions */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
goto contin;
}
}
# ifdef YYOPTIM
else if((int)yyt < (int)yycrank) { /* r < yycrank */
yyt = yyr = yycrank+(yycrank-yyt);
# ifdef LEXDEBUG
if(debug)fprintf(yyout,"compressed state\n");
# endif
yyt = yyt + yych;
if(yyt <= yytop && yyt->verify+yysvec == yystate){
if(yyt->advance+yysvec == YYLERR) /* error transitions */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
goto contin;
}
yyt = yyr + YYU(yymatch[yych]);
# ifdef LEXDEBUG
if(debug){
fprintf(yyout,"try fall back character ");
allprint(YYU(yymatch[yych]));
putchar('\n');
}
# endif
if(yyt <= yytop && yyt->verify+yysvec == yystate){
if(yyt->advance+yysvec == YYLERR) /* error transition */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
goto contin;
}
}
if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
# ifdef LEXDEBUG
if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
# endif
goto tryagain;
}
# endif
else
{unput(*--yylastch);break;}
contin:
# ifdef LEXDEBUG
if(debug){
fprintf(yyout,"state %d char ",yystate-yysvec-1);
allprint(yych);
putchar('\n');
}
# endif
;
}
# ifdef LEXDEBUG
if(debug){
fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
allprint(yych);
putchar('\n');
}
# endif
while (lsp-- > yylstate){
*yylastch-- = 0;
if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
yyolsp = lsp;
if(yyextra[*yyfnd]){ /* must backup */
while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
lsp--;
unput(*yylastch--);
}
}
yyprevious = YYU(*yylastch);
yylsp = lsp;
yyleng = yylastch-yytext+1;
yytext[yyleng] = 0;
# ifdef LEXDEBUG
if(debug){
fprintf(yyout,"\nmatch ");
sprint(yytext);
fprintf(yyout," action %d\n",*yyfnd);
}
# endif
return(*yyfnd++);
}
unput(*yylastch);
}
if (yytext[0] == 0 /* && feof(yyin) */)
{
yysptr=yysbuf;
return(0);
}
yyprevious = yytext[0] = input();
if (yyprevious>0)
output(yyprevious);
yylastch=yytext;
# ifdef LEXDEBUG
if(debug)putchar('\n');
# endif
}
}
yyback(p, m)
int *p;
{
if (p==0) return(0);
while (*p)
{
if (*p++ == m)
return(1);
}
return(0);
}
/* the following are only used in the lex library */
yyinput(){
return(input());
}
yyoutput(c)
int c; {
output(c);
}
yyunput(c)
int c; {
unput(c);
}