This is lex.c in view mode; [Download] [Up]
# 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 BUFSIZ # 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 "co_parse.h" static char buf[1000]; static char *save; /* * This is the magic that allows us to force yyparse() to return after * each form. If _p_co_parse_done_flag is true, we force YY_INPUT to return * EOF. */ #undef YY_INPUT #define YY_INPUT(buf,result,max_size) \ \ if (_p_co_push_token) { buf[0] = _p_co_push_token; result = 1; _p_co_push_token = 0;} \ else if (_p_co_parse_done_flag) \ { \ _p_co_parse_done_flag = 0; \ result = 0; \ } \ else \ { \ int c = getc(yyin); \ result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \ } # 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: { save = buf; save[0] = 0; BEGIN(CHAR_CONST); } break; case 2: { return IMPLY; } break; case 3: { return MATCH; } break; case 4: { return LEQ; } break; case 5: { return GEQ; } break; case 6: { return NEQ; } break; case 7: { return COLONEQ; } break; case 8: { return COLONCOLON; } break; case 9: { return EQ; } break; case 10: { return BARBAR; } break; case 11: { return OVER; } break; case 12: { return DOTS; } break; case 13: { return DEFAULT; } break; case 14: { return IN; } break; case 15: { strcat(save, yytext); } break; case 16: { yylval = _p_co_new_string(save); BEGIN(INITIAL); return(CHARACTERconstant); } break; case 17: { printf("Invalid escape sequence in char const: %s\n", yytext); } break; case 18: { printf("Invalid: newline in char const\n"); } break; case 19: { strcat(save, yytext); } break; case 20: { yylval = _p_co_new_string_len(yytext+1, strlen(yytext) - 2); return STRING;} break; case 21: { yylval = _p_co_new_string(yytext); return ID; } break; case 22: { yylval = _p_co_new_string(yytext); return(INTEGERconstant); } break; case 23: { yylval = _p_co_new_string(yytext); return OCTALconstant;} break; case 24: { yylval = _p_co_new_string(yytext); return(HEXconstant);} break; case 25: { yylval = _p_co_new_string(yytext); return(FLOATINGconstant);} break; case 26: { _p_co_parse_cpp_directive(yytext); } break; case 28: { _p_co_lineno++; } break; case 29: { return *yytext; } break; case -1: break; default: fprintf(yyout,"bad switch yylook %d",nstr); } return(0); } /* end of yylex */ int yyvstop[] = { 0, 29, 0, 27, 29, 0, 28, 0, 29, 0, 29, 0, 1, 29, 0, 29, 0, 29, 0, 23, 29, 0, 22, 29, 0, 29, 0, 29, 0, 29, 0, 29, 0, 29, 0, 21, 29, 0, 21, 29, 0, 29, 0, 21, 29, 0, 21, 29, 0, 21, 29, 0, 29, 0, 29, 0, 6, 0, 20, 0, 2, 0, 12, 0, -25, 0, 23, 0, 23, 0, 23, 0, 22, 0, 22, 0, 22, 0, 8, 0, 7, 0, 4, 0, 9, 0, 5, 0, 3, 0, 21, 0, 21, 22, 23, 24, 0, 20, 0, 21, 0, 14, 21, 0, 21, 0, 10, 0, 26, 0, 25, 0, 25, -25, 0, -25, 0, -25, 0, 24, 0, 21, 0, 21, 0, 25, -25, 0, 25, -25, 0, 24, 0, 24, 0, 21, 0, 11, 21, 0, 21, 0, 21, 0, 13, 21, 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, 1,6, 1,7, 0,0, 0,0, 0,0, 0,0, 1,8, 0,0, 0,0, 0,0, 1,3, 0,0, 1,9, 1,10, 60,0, 1,11, 1,12, 0,0, 0,0, 0,0, 0,0, 0,0, 2,6, 1,12, 2,25, 1,13, 0,0, 1,14, 1,15, 1,16, 1,17, 6,26, 1,18, 9,28, 2,9, 14,43, 1,18, 7,27, 1,18, 13,41, 15,44, 16,45, 13,42, 1,19, 17,46, 7,27, 7,0, 2,13, 0,0, 2,14, 2,15, 2,16, 1,18, 0,0, 19,48, 1,18, 36,35, 0,0, 40,39, 1,20, 0,0, 0,0, 0,0, 72,71, 1,18, 67,74, 0,0, 1,21, 0,0, 21,53, 7,0, 53,67, 1,22, 55,68, 0,0, 7,27, 0,0, 1,18, 1,23, 7,27, 22,54, 77,78, 7,27, 68,75, 7,27, 7,27, 19,48, 23,55, 36,35, 2,21, 40,39, 1,24, 7,27, 24,56, 2,22, 72,71, 74,77, 78,79, 0,0, 7,27, 2,23, 7,27, 0,0, 61,69, 0,0, 7,27, 61,0, 7,27, 61,69, 61,69, 0,0, 0,0, 7,27, 2,24, 0,0, 63,0, 61,69, 63,70, 63,70, 0,0, 69,0, 7,27, 69,69, 69,69, 7,27, 63,70, 0,0, 0,0, 7,0, 0,0, 69,69, 0,0, 10,29, 7,27, 10,30, 10,30, 10,30, 10,30, 10,30, 10,30, 10,30, 10,30, 10,30, 10,30, 0,0, 11,31, 7,27, 11,32, 11,32, 11,32, 11,32, 11,32, 11,32, 11,32, 11,32, 11,33, 11,33, 31,30, 31,30, 31,30, 31,30, 31,30, 31,30, 31,30, 31,30, 31,30, 31,30, 70,0, 11,34, 70,70, 70,70, 64,71, 0,0, 0,0, 0,0, 11,35, 0,0, 70,70, 31,61, 0,0, 64,72, 0,0, 0,0, 0,0, 11,36, 0,0, 0,0, 11,37, 12,31, 0,0, 12,38, 12,38, 12,38, 12,38, 12,38, 12,38, 12,38, 12,38, 12,38, 12,38, 11,34, 0,0, 0,0, 64,71, 0,0, 0,0, 0,0, 11,35, 0,0, 0,0, 31,61, 12,34, 64,72, 0,0, 0,0, 0,0, 11,36, 0,0, 12,39, 11,37, 0,0, 0,0, 0,0, 34,62, 0,0, 34,62, 0,0, 12,40, 34,63, 34,63, 34,63, 34,63, 34,63, 34,63, 34,63, 34,63, 34,63, 34,63, 0,0, 0,0, 0,0, 0,0, 0,0, 12,34, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 12,39, 51,65, 51,65, 51,65, 51,65, 51,65, 51,65, 51,65, 51,65, 12,40, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 0,0, 0,0, 0,0, 0,0, 18,47, 0,0, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 18,47, 20,49, 0,0, 0,0, 0,0, 0,0, 20,50, 65,65, 65,65, 65,65, 65,65, 65,65, 65,65, 65,65, 65,65, 20,51, 20,51, 20,51, 20,51, 20,51, 20,51, 20,51, 20,51, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 20,50, 0,0, 0,0, 0,0, 33,31, 0,0, 33,33, 33,33, 33,33, 33,33, 33,33, 33,33, 33,33, 33,33, 33,33, 33,33, 25,57, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 25,57, 25,58, 0,0, 33,34, 0,0, 20,50, 0,0, 0,0, 0,0, 0,0, 20,50, 20,50, 0,0, 0,0, 0,0, 20,50, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 20,50, 0,0, 25,57, 0,0, 20,50, 0,0, 20,50, 25,57, 20,50, 0,0, 20,52, 25,57, 33,34, 0,0, 25,57, 0,0, 25,57, 25,57, 0,0, 30,59, 0,0, 0,0, 0,0, 0,0, 25,57, 0,0, 0,0, 30,59, 30,59, 0,0, 0,0, 25,57, 0,0, 25,57, 0,0, 0,0, 0,0, 25,57, 0,0, 25,57, 0,0, 0,0, 0,0, 0,0, 25,57, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 30,59, 25,57, 0,0, 0,0, 25,57, 30,59, 0,0, 0,0, 25,57, 30,59, 0,0, 0,0, 30,0, 25,57, 30,60, 30,60, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 30,60, 0,0, 0,0, 0,0, 25,57, 0,0, 0,0, 30,59, 0,0, 30,59, 0,0, 0,0, 0,0, 30,59, 0,0, 30,59, 0,0, 0,0, 0,0, 0,0, 30,59, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 30,59, 0,0, 0,0, 30,59, 0,0, 0,0, 0,0, 30,59, 0,0, 0,0, 0,0, 0,0, 30,59, 32,32, 32,32, 32,32, 32,32, 32,32, 32,32, 32,32, 32,32, 32,33, 32,33, 0,0, 0,0, 30,59, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 0,0, 0,0, 0,0, 0,0, 0,0, 32,35, 0,0, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 0,0, 32,36, 62,63, 62,63, 62,63, 62,63, 62,63, 62,63, 62,63, 62,63, 62,63, 62,63, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 32,35, 0,0, 37,64, 37,64, 37,64, 37,64, 37,64, 37,64, 0,0, 32,36, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 66,49, 0,0, 0,0, 0,0, 0,0, 66,50, 0,0, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 0,0, 66,73, 66,73, 66,73, 66,73, 66,73, 66,73, 66,73, 66,73, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 66,50, 0,0, 73,49, 0,0, 0,0, 0,0, 0,0, 73,50, 0,0, 0,0, 52,66, 52,66, 52,66, 52,66, 52,66, 52,66, 73,76, 73,76, 73,76, 73,76, 73,76, 73,76, 73,76, 73,76, 0,0, 76,49, 0,0, 0,0, 0,0, 66,50, 76,50, 73,50, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 76,76, 76,76, 76,76, 76,76, 76,76, 76,76, 76,76, 76,76, 66,50, 0,0, 0,0, 0,0, 66,50, 0,0, 66,50, 76,50, 66,50, 0,0, 66,52, 0,0, 0,0, 73,50, 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, 73,50, 0,0, 0,0, 0,0, 73,50, 76,50, 73,50, 0,0, 73,50, 0,0, 73,52, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0, 76,50, 0,0, 0,0, 0,0, 76,50, 0,0, 76,50, 0,0, 76,50, 0,0, 76,52, 0,0, 0,0, 0,0}; struct yysvf yysvec[] = { 0, 0, 0, yycrank+-1, 0, 0, yycrank+-23, yysvec+1, 0, yycrank+0, 0, yyvstop+1, yycrank+0, 0, yyvstop+3, yycrank+0, 0, yyvstop+6, yycrank+4, 0, yyvstop+8, yycrank+-70, 0, yyvstop+10, yycrank+0, 0, yyvstop+12, yycrank+5, 0, yyvstop+15, yycrank+120, 0, yyvstop+17, yycrank+133, 0, yyvstop+19, yycrank+176, 0, yyvstop+22, yycrank+15, 0, yyvstop+25, yycrank+8, 0, yyvstop+27, yycrank+13, 0, yyvstop+29, yycrank+14, 0, yyvstop+31, yycrank+17, 0, yyvstop+33, yycrank+246, 0, yyvstop+35, yycrank+3, yysvec+18, yyvstop+38, yycrank+335, 0, yyvstop+41, yycrank+2, yysvec+18, yyvstop+43, yycrank+4, yysvec+18, yyvstop+46, yycrank+3, yysvec+18, yyvstop+49, yycrank+3, 0, yyvstop+52, yycrank+-413, 0, yyvstop+54, yycrank+0, 0, yyvstop+56, yycrank+0, 0, yyvstop+58, yycrank+0, 0, yyvstop+60, yycrank+0, 0, yyvstop+62, yycrank+-463, 0, yyvstop+64, yycrank+143, 0, 0, yycrank+513, yysvec+12, yyvstop+66, yycrank+356, 0, 0, yycrank+214, 0, 0, yycrank+0, 0, yyvstop+68, yycrank+14, 0, yyvstop+70, yycrank+526, 0, 0, yycrank+0, yysvec+12, yyvstop+72, yycrank+0, 0, yyvstop+74, yycrank+16, 0, yyvstop+76, yycrank+0, 0, yyvstop+78, yycrank+0, 0, yyvstop+80, yycrank+0, 0, yyvstop+82, yycrank+0, 0, yyvstop+84, yycrank+0, 0, yyvstop+86, yycrank+0, 0, yyvstop+88, yycrank+0, yysvec+18, yyvstop+90, yycrank+0, yysvec+18, yyvstop+92, yycrank+0, yysvec+20, yyvstop+97, yycrank+0, yysvec+20, 0, yycrank+237, yysvec+20, 0, yycrank+583, 0, 0, yycrank+3, yysvec+18, yyvstop+99, yycrank+0, yysvec+18, yyvstop+101, yycrank+6, yysvec+18, yyvstop+104, yycrank+0, 0, yyvstop+106, yycrank+0, yysvec+25, 0, yycrank+0, 0, yyvstop+108, yycrank+0, 0, yyvstop+110, yycrank+-2, yysvec+30, yyvstop+112, yycrank+-94, yysvec+30, yyvstop+115, yycrank+551, 0, 0, yycrank+-103, yysvec+30, yyvstop+117, yycrank+129, yysvec+37, yyvstop+119, yycrank+327, yysvec+20, 0, yycrank+607, yysvec+52, 0, yycrank+2, yysvec+18, yyvstop+121, yycrank+3, yysvec+18, yyvstop+123, yycrank+-108, yysvec+30, yyvstop+125, yycrank+-155, yysvec+30, yyvstop+128, yycrank+0, 0, yyvstop+131, yycrank+21, 0, yyvstop+133, yycrank+638, yysvec+52, 0, yycrank+13, yysvec+18, yyvstop+135, yycrank+0, yysvec+18, yyvstop+137, yycrank+661, yysvec+52, 0, yycrank+7, yysvec+18, yyvstop+140, yycrank+15, yysvec+18, yyvstop+142, yycrank+0, yysvec+18, yyvstop+144, 0, 0, 0}; struct yywork *yytop = yycrank+781; 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 ,047 , 01 ,01 ,01 ,'+' ,01 ,'+' ,'.' ,01 , '0' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' ,'1' , '8' ,'8' ,01 ,01 ,01 ,01 ,01 ,'?' , 01 ,'A' ,'A' ,'A' ,'A' ,'E' ,'A' ,'G' , 'G' ,'G' ,'G' ,'G' ,'L' ,'G' ,'G' ,'G' , 'G' ,'G' ,'G' ,'G' ,'G' ,'U' ,'G' ,'G' , 'X' ,'G' ,'G' ,01 ,0134,01 ,01 ,'G' , 01 ,'a' ,'a' ,'A' ,'A' ,'E' ,'a' ,'G' , 'G' ,'G' ,'G' ,'G' ,'L' ,'G' ,'n' ,'G' , 'G' ,'G' ,'n' ,'G' ,'n' ,'U' ,'n' ,'G' , 'X' ,'G' ,'G' ,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,1,0,0,0,0,0,0, 0}; #ifndef lint static char ncform_sccsid[] = "@(#)ncform 1.6 88/02/08 SMI"; /* from S5R2 1.2 */ #endif 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); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.