# include "stdio.h" # 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; #ifndef lint static char RCSid[] = "$Header: /var/lib/cvsd/repos/CSRG/43BSDTahoe/new/xns/compiler/lex.yy.c.bw,v 1.1.1.1 2018/04/24 16:12:58 root Exp $"; #endif /* * scanner.l -- scanner for the XNS courier compiler */ /* $Log: lex.yy.c.bw,v $ /* Revision 1.1.1.1 2018/04/24 16:12:58 root /* BSD 4.3tahoe /* * Revision 2.0 85/11/21 07:21:45 jqj * 4.3BSD standard release * * Revision 1.1 85/11/20 12:56:17 jqj * Initial revision * * Revision 1.3 85/03/11 16:40:08 jqj * Public alpha-test version, released 11 March 1985 * * Revision 1.2 85/02/21 11:05:51 jqj * alpha test version * * Revision 1.1 85/02/15 13:55:58 jqj * Initial revision * */ #include "compiler.h" #include "y.tab.h" # 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: case 2: case 3: case 4: /* whitespace */; break; case 5: { return (ARRAY); } break; case 6: { return (_BEGIN); } break; case 7: { return (BOOLEAN); } break; case 8: { return (CARDINAL); } break; case 9: { return (CHOICE); } break; case 10: { return (DEPENDS); } break; case 11: { return (END); } break; case 12: { return (ERROR); } break; case 13: { return (INTEGER); } break; case 14: { return (LONG); } break; case 15: { return (OF); } break; case 16: { return (PROCEDURE); } break; case 17: { return (PROGRAM); } break; case 18: { return (RECORD); } break; case 19: { return (REPORTS); } break; case 20: { return (RETURNS); } break; case 21: { return (SEQUENCE); } break; case 22: { return (STRING); } break; case 23: { return (TYPE); } break; case 24: { return (UNSPECIFIED); } break; case 25: { return (UPON); } break; case 26: { return (VERSION); } break; case 27: { return (TRUE); } break; case 28: { return (FALSE); } break; case 29: { return (_CHOOSES); } break; case 30: { /* * decimal constant. */ yylval.stringvalue = copy(yytext); return (number); } break; case 31: { /* * decimal constant. */ yytext[yyleng-1] = '\0'; yylval.stringvalue = copy(yytext); return (number); } break; case 32: { char buf[BUFSIZ]; /* * octal constant. * change to C representation */ yytext[yyleng-1] = '\0'; if (*yytext != '-') sprintf(buf,"0%s", yytext); else sprintf(buf,"-0%s", yytext+1); yylval.stringvalue = copy(buf); return (number); } break; case 33: { char buf[BUFSIZ]; /* * hex constant. * change to C representation */ yytext[yyleng-1] = '\0'; if (*yytext != '-') sprintf(buf,"0x%s", yytext); else sprintf(buf,"-0x%s", yytext+1); yylval.stringvalue = copy(buf); return (number); } break; case 34: { /* * string constant */ yylval.stringvalue = copy(yytext); return (string); } break; case 35: { register char *p; /* * string constant with embedded "" */ for (p=yytext+1; pyystoff; if(yyt == yycrank){ /* may not be any transitions */ yyz = yystate->yyother; if(yyz == 0)break; if(yyz->yystoff == yycrank)break; } *yylastch++ = yych = input(); 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); }