⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lex.yy.c

📁 一个FREE编译器原码
💻 C
📖 第 1 页 / 共 2 页
字号:
# include "stdio.h"
# define U(x) ((x)&0377)
# 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;}
int yyleng; extern unsigned char yytext[];
int yymorfg;
extern unsigned 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 <string.h>
#include "util.h"
#include "y.tab.h"
#include "errormsg.h"

static int q3=0;
char q1[1024+1];int q2=0;
static void q4(char c) { if (q2<1024) q1[q2++]= c; else
{EM_error(EM_tokPos,"string too long."); q2=0;} }
static string q5(void) {q1[q2]=0; q2=0; return String(q1); }

int charPos=1;

int yywrap(void)
{
 if (q3) 
	EM_error(EM_tokPos,"unclosed comment");
 charPos=1;
 return 1;
}


void adjust(void)
{
 EM_tokPos=charPos;
 charPos+=yyleng;
}

yylex(){
int nstr; extern int yyprevious;
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
 {adjust(); continue;}
break;
case 2:
 {adjust(); EM_newline(); continue;}
break;
case 3:
 {adjust(); return COMMA;}
break;
case 4:
 {adjust(); return LBRACE;}
break;
case 5:
 {adjust(); return RBRACE;}
break;
case 6:
 {adjust(); return LBRACK;}
break;
case 7:
 {adjust(); return RBRACK;}
break;
case 8:
 {adjust(); return COLON;}
break;
case 9:
 {adjust(); return SEMICOLON;}
break;
case 10:
 {adjust(); return LPAREN;}
break;
case 11:
 {adjust(); return RPAREN;}
break;
case 12:
 {adjust(); return DOT;}
break;
case 13:
 {adjust(); return PLUS;}
break;
case 14:
 {adjust(); return MINUS;}
break;
case 15:
 {adjust(); return TIMES;}
break;
case 16:
 {adjust(); return DIVIDE;}
break;
case 17:
 {adjust(); return AND;}
break;
case 18:
 {adjust(); return OR;}
break;
case 19:
 {adjust(); return ASSIGN;}
break;
case 20:
 {adjust(); return EQ;}
break;
case 21:
 {adjust(); return NEQ;}
break;
case 22:
 {adjust(); return GT;}
break;
case 23:
 {adjust(); return LT;}
break;
case 24:
 {adjust(); return GE;}
break;
case 25:
 {adjust(); return LE;}
break;
case 26:
 	 {adjust(); return FOR;}
break;
case 27:
 {adjust(); return WHILE;}
break;
case 28:
 {adjust(); return BREAK;}
break;
case 29:
	 {adjust(); return LET;}
break;
case 30:
 	 {adjust(); return IN;}
break;
case 31:
 	 {adjust(); return NIL;}
break;
case 32:
 	 {adjust(); return TO;}
break;
case 33:
 	 {adjust(); return END;}
break;
case 34:
{adjust(); return FUNCTION;}
break;
case 35:
 	 {adjust(); return VAR;}
break;
case 36:
 	 {adjust(); return TYPE;}
break;
case 37:
	 {adjust(); return ARRAY;}
break;
case 38:
	 {adjust(); return IF;}
break;
case 39:
 	 {adjust(); return THEN;}
break;
case 40:
 	 {adjust(); return ELSE;}
break;
case 41:
 	 {adjust(); return DO;}
break;
case 42:
 	 {adjust(); return OF;}
break;
case 43:
 {adjust(); yylval.sval = String((char*)yytext); return ID;}
break;
case 44:
 {adjust(); yylval.ival=atoi(yytext); return INT;}
break;
case 45:
 {adjust(); yybgin = yysvec + 1 + 4; continue;}
break;
case 46:
 {adjust(); yybgin = yysvec + 1 + 2; q3 = 1; continue;}
break;
case 47:
 {adjust(); EM_error(EM_tokPos,"unmatched close comment");
		    continue;}
break;
case 48:
 {adjust(); EM_error(EM_tokPos,"non-Ascii character");
		    continue;}
break;
case 49:
 {adjust(); EM_error(EM_tokPos,"illegal token");
		    continue;}
break;
case 50:
	 {adjust(); q3++; continue;}
break;
case 51:
	 {adjust(); EM_newline(); continue;}
break;
case 52:
	 {adjust(); q3--; 
		    if (q3==0) {yybgin = yysvec + 1 + 0;}
	                continue;}
break;
case 53:
	{adjust(); continue;}
break;
case 54:
	{adjust(); yybgin = yysvec + 1 + 0; 
	            yylval.sval=q5();
	            return STRING;}
break;
case 55:
	 {adjust(); EM_error (EM_tokPos,"unclosed string");
                  EM_newline();
		    yybgin = yysvec + 1 + 0; 
	            yylval.sval=q5();
		    return STRING;}
break;
case 56:
       	 {adjust(); EM_newline(); yybgin = yysvec + 1 + 6; continue;}
break;
case 57:
  	 {adjust(); yybgin = yysvec + 1 + 6; continue;}
break;
case 58:
	 {adjust(); q4(*yytext); continue;}
break;
case 59:
	 {adjust(); EM_newline(); continue;}
break;
case 60:
	 {adjust(); continue;}
break;
case 61:
	 {adjust(); yybgin = yysvec + 1 + 4; continue;}
break;
case 62:
	 {adjust(); EM_error(EM_tokPos, "unclosed string"); 
		    yybgin = yysvec + 1 + 0; 
	           yylval.sval=q5();
	          return STRING;}
break;
case 63:
	 {adjust(); q4('\t'); continue;}
break;
case 64:
	 {adjust(); q4('\n'); continue;}
break;
case 65:
	 {adjust(); q4('\\'); continue;}
break;
case 66:
 {adjust(); q4(yytext[1]); continue;}
break;
case 67:
 {adjust(); q4(yytext[2]-'@');
	            continue;}
break;
case 68:
 {int x = yytext[1]*100 + yytext[2]*10 + yytext[3] - 
	                     ('0' * 111);
	          adjust();
                    if (x>255)
                         EM_error(EM_tokPos, "illegal ascii escape");
	            else q4(x);
	            continue;
	           }
break;
case 69:
	 {adjust(); EM_error(EM_tokPos, "illegal string escape"); 
		    continue;}
break;
case -1:
break;
default:
fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
int yyvstop[] = {
0,

1,
60,
0,

1,
60,
0,

1,
60,
0,

1,
60,
0,

1,
60,
0,

1,
60,
0,

1,
60,
0,

1,
60,
0,

49,
0,

1,
49,
0,

1,
2,
0,

45,
49,
0,

17,
49,
0,

10,
49,
0,

11,
49,
0,

15,
49,
0,

13,
49,
0,

3,
49,
0,

14,
49,
0,

12,
49,
0,

16,
49,
0,

44,
49,
0,

8,
49,
0,

9,
49,
0,

23,
49,
0,

20,
49,
0,

22,
49,
0,

43,
49,
0,

6,
49,
0,

7,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
48,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

43,
49,
0,

4,
49,
0,

18,
49,
0,

5,
49,
0,

53,
0,

51,
0,

53,
0,

53,
0,

58,
0,

55,
0,

54,
58,
0,

58,
69,
0,

62,
0,

60,
62,
0,

59,
60,
0,

61,
62,
0,

1,
0,

46,
0,

47,
0,

44,
0,

19,
0,

25,
0,

21,
0,

24,
0,

43,
0,

43,
0,

43,
0,

41,
43,
0,

43,
0,

43,
0,

43,
0,

43,
0,

38,
43,
0,

30,
43,
0,

43,
0,

43,
0,

42,
43,
0,

43,
0,

32,
43,
0,

43,
0,

43,
0,

43,
0,

50,
0,

52,
0,

57,
0,

56,
0,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -