|
|
1.1 root 1: int yylineno =1;
2: # define YYU(x) x
3: # define NLSTATE yyprevious=YYNEWLINE
4: char yytext[YYLMAX];
5: struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
6: char yysbuf[YYLMAX];
7: char *yysptr = yysbuf;
8: int *yyfnd;
9: extern struct yysvf *yyestate;
10: int yyprevious = YYNEWLINE;
11: yylook(){
12: register struct yysvf *yystate, **lsp;
13: register struct yywork *yyt;
14: struct yysvf *yyz;
15: int yych;
16: struct yywork *yyr;
17: # ifdef LEXDEBUG
18: int debug;
19: # endif
20: char *yylastch;
21: /* start off machines */
22: # ifdef LEXDEBUG
23: debug = 0;
24: # endif
25: if (!yymorfg)
26: yylastch = yytext;
27: else {
28: yymorfg=0;
29: yylastch = yytext+yyleng;
30: }
31: for(;;){
32: lsp = yylstate;
33: yyestate = yystate = yybgin;
34: if (yyprevious==YYNEWLINE) yystate++;
35: for (;;){
36: # ifdef LEXDEBUG
37: if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
38: # endif
39: yyt = yystate->yystoff;
40: if(yyt == yycrank){ /* may not be any transitions */
41: yyz = yystate->yyother;
42: if(yyz == 0)break;
43: if(yyz->yystoff == yycrank)break;
44: }
45: *yylastch++ = yych = input();
46: tryagain:
47: # ifdef LEXDEBUG
48: if(debug){
49: fprintf(yyout,"char ");
50: allprint(yych);
51: putchar('\n');
52: }
53: # endif
54: yyr = yyt;
55: if ( (int)yyt > (int)yycrank){
56: yyt = yyr + yych;
57: if (yyt <= yytop && yyt->verify+yysvec == yystate){
58: if(yyt->advance+yysvec == YYLERR) /* error transitions */
59: {unput(*--yylastch);break;}
60: *lsp++ = yystate = yyt->advance+yysvec;
61: goto contin;
62: }
63: }
64: # ifdef YYOPTIM
65: else if((int)yyt < (int)yycrank) { /* r < yycrank */
66: yyt = yyr = yycrank+(yycrank-yyt);
67: # ifdef LEXDEBUG
68: if(debug)fprintf(yyout,"compressed state\n");
69: # endif
70: yyt = yyt + yych;
71: if(yyt <= yytop && yyt->verify+yysvec == yystate){
72: if(yyt->advance+yysvec == YYLERR) /* error transitions */
73: {unput(*--yylastch);break;}
74: *lsp++ = yystate = yyt->advance+yysvec;
75: goto contin;
76: }
77: yyt = yyr + YYU(yymatch[yych]);
78: # ifdef LEXDEBUG
79: if(debug){
80: fprintf(yyout,"try fall back character ");
81: allprint(YYU(yymatch[yych]));
82: putchar('\n');
83: }
84: # endif
85: if(yyt <= yytop && yyt->verify+yysvec == yystate){
86: if(yyt->advance+yysvec == YYLERR) /* error transition */
87: {unput(*--yylastch);break;}
88: *lsp++ = yystate = yyt->advance+yysvec;
89: goto contin;
90: }
91: }
92: if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
93: # ifdef LEXDEBUG
94: if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
95: # endif
96: goto tryagain;
97: }
98: # endif
99: else
100: {unput(*--yylastch);break;}
101: contin:
102: # ifdef LEXDEBUG
103: if(debug){
104: fprintf(yyout,"state %d char ",yystate-yysvec-1);
105: allprint(yych);
106: putchar('\n');
107: }
108: # endif
109: ;
110: }
111: # ifdef LEXDEBUG
112: if(debug){
113: fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
114: allprint(yych);
115: putchar('\n');
116: }
117: # endif
118: while (lsp-- > yylstate){
119: *yylastch-- = 0;
120: if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
121: yyolsp = lsp;
122: if(yyextra[*yyfnd]){ /* must backup */
123: while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
124: lsp--;
125: unput(*yylastch--);
126: }
127: }
128: yyprevious = YYU(*yylastch);
129: yylsp = lsp;
130: yyleng = yylastch-yytext+1;
131: yytext[yyleng] = 0;
132: # ifdef LEXDEBUG
133: if(debug){
134: fprintf(yyout,"\nmatch ");
135: sprint(yytext);
136: fprintf(yyout," action %d\n",*yyfnd);
137: }
138: # endif
139: return(*yyfnd++);
140: }
141: unput(*yylastch);
142: }
143: if (yytext[0] == 0 /* && feof(yyin) */)
144: {
145: yysptr=yysbuf;
146: return(0);
147: }
148: yyprevious = yytext[0] = input();
149: if (yyprevious>0)
150: output(yyprevious);
151: yylastch=yytext;
152: # ifdef LEXDEBUG
153: if(debug)putchar('\n');
154: # endif
155: }
156: }
157: yyback(p, m)
158: int *p;
159: {
160: if (p==0) return(0);
161: while (*p)
162: {
163: if (*p++ == m)
164: return(1);
165: }
166: return(0);
167: }
168: /* the following are only used in the lex library */
169: yyinput(){
170: return(input());
171: }
172: yyoutput(c)
173: int c; {
174: output(c);
175: }
176: yyunput(c)
177: int c; {
178: unput(c);
179: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.