|
|
1.1 root 1: # include "stdio.h"
2: # define U(x) x
3: # define NLSTATE yyprevious=YYNEWLINE
4: # define BEGIN yybgin = yysvec + 1 +
5: # define INITIAL 0
6: # define YYLERR yysvec
7: # define YYSTATE (yyestate-yysvec-1)
8: # define YYOPTIM 1
9: # define YYLMAX 200
10: # define output(c) putc(c,yyout)
11: # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
12: # define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
13: # define yymore() (yymorfg=1)
14: # define ECHO fprintf(yyout, "%s",yytext)
15: # define REJECT { nstr = yyreject(); goto yyfussy;}
16: int yyleng; extern char yytext[];
17: int yymorfg;
18: extern char *yysptr, yysbuf[];
19: int yytchar;
20: FILE *yyin ={stdin}, *yyout ={stdout};
21: extern int yylineno;
22: struct yysvf {
23: struct yywork *yystoff;
24: struct yysvf *yyother;
25: int *yystops;};
26: struct yysvf *yyestate;
27: extern struct yysvf yysvec[], *yybgin;
28:
29: #ifndef lint
30: static char sccsid[] = "@(#)part.l 4.2 (Berkeley) 82/11/06";
31: #endif not lint
32:
33: #include "style.h"
34: #include "names.h"
35: #include "conp.h"
36: FILE *deb;
37: int nosave = 1;
38: int part = 0;
39: int barebones = 0;
40: int topic = 0;
41: int style = 1;
42: int pastyle = 0;
43: int pstyle = 0;
44: int lstyle = 0;
45: int rstyle = 0;
46: int estyle = 0;
47: int nstyle = 0;
48: int Nstyle = 0;
49: int lthresh;
50: int rthresh;
51: int nomin;
52: char s[SCHAR];
53: char *sptr = s;
54: struct ss sent[SLENG];
55: struct ss *sentp = sent;
56: float wperc();
57: float sperc();
58: float typersent();
59: float vperc();
60: int numsent = 0;
61: int qcount = 0;
62: int icount = 0;
63: long vowel = 0;
64: long numwds = 0;
65: long twds = 0;
66: long numnonf = 0;
67: long letnonf = 0;
68: int maxsent = 0;
69: int maxindex = 0;
70: int minsent = 30;
71: int minindex = 0;
72: int simple = 0;
73: int compound = 0;
74: int compdx = 0;
75: int prepc = 0;
76: int conjc = 0;
77: int complex = 0;
78: int tobe = 0;
79: int adj = 0;
80: int infin = 0;
81: int pron = 0;
82: int passive = 0;
83: int aux = 0;
84: int adv = 0;
85: int verbc = 0;
86: int tverbc = 0;
87: int noun = 0;
88: long numlet = 0;
89: int beg[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
90: int sleng[50];
91: int nsleng = 0;
92: int j,jj,i;
93: int comma = 0;
94: int cflg;
95: int question;
96: int quote = 0;
97: char *st;
98: int initf = 0;
99: int over = 1;
100: int nroff = 0;
101: int nrofflg = 0;
102: int leng[MAXPAR];
103: int sentno= 0;
104: # define YYNEWLINE 10
105: yylex(){
106: int nstr; extern int yyprevious;
107: while((nstr = yylook()) >= 0)
108: yyfussy: switch(nstr){
109: case 0:
110: if(yywrap()) return(0); break;
111: case 1:
112: {
113: collect:
114: sentp->cc = sentp->ic = yytext[0];
115: if(sentp->cc == NOM)
116: sentp->cc = NOUN;
117: collect1:
118: nsleng++;
119: sentp->leng = yyleng-2;
120: sentp++->sp = sptr;
121: if(sentp >= &sent[SLENG-1]){
122: if(over)fprintf(stderr,"sentence %d too many words\n",numsent+2);
123: over=0;
124: sentp--;
125: }
126: if(sptr+yyleng >= &s[SCHAR-1]){
127: if(over)fprintf(stderr,"sentence %d too many characters\n",numsent+2);
128: over=0;
129: }
130: else {
131: for(i=2;i<yyleng;i++)*sptr++=yytext[i];
132: *sptr++ = '\0';
133: }
134: }
135: break;
136: case 2:
137: {
138: sentp->cc=END;
139: sentp->ic = ';';
140: goto collect1;
141: }
142: break;
143: case 3:
144: {
145: comma++;
146: goto collect;
147: }
148: break;
149: case 4:
150: {
151: comma++;
152: goto collect;
153: }
154: break;
155: case 5:
156: ;
157: break;
158: case 6:
159: {
160: goto collect;
161: }
162: break;
163: case 7:
164: {
165: cflg = 1;
166: goto sdone;
167: }
168: break;
169: case 8:
170: {
171: cflg = 0;
172: sdone:
173: over=1;
174: sentp->cc=sentp->ic=END;
175: sentp++->sp = sptr;
176: for(i=2;i<yyleng;i++)*sptr++=yytext[i];
177: *sptr++='\0';
178: if(yytext[2]=='?')question=1;
179: else question=0;
180:
181: fragment:
182: jj=0;
183: if(quote == 1 && sent[jj].cc == ED){
184: sent[jj].cc = VERB;
185: quote = 0;
186: }
187: if(sent[jj].cc=='"')jj++;
188: if(sent[jj].cc==SUBCONJ){
189: if(sent[jj+1].cc == ','){
190: sent[jj].cc=ADV;
191: jj += 2;
192: comma--;
193: }
194: else {
195: jj=scan(1,',',0);
196: if(jj != -1)jj++;
197: comma--;
198: }
199: }
200: if(jj != -1){
201: if(sent[jj].cc==CONJ || sent[jj].cc=='"')jj++;
202: while((jj=scan(jj,END,cflg)) != -1){
203: jj++;
204: if(sent[jj].cc == SUBCONJ && sent[jj+1].cc == ','){
205: sent[jj].cc=ADV;
206: jj += 2;
207: comma--;
208: }
209: }
210: }
211: st = sent[i].sp;
212: if(*(st+1) == '"')
213: if(*st == '?' || *st == '!')quote = 1;
214: outp();
215: nsleng = 0;
216: if(nroff){
217: if(sentno > 0){
218: printf(".SL \"");
219: for(i=0;i<sentno;i++)
220: printf(" %d",leng[i]);
221: printf("\"\n");
222: sentno = 0;
223: }
224: printf("%s",&yytext[1]);
225: nroff = 0;
226: }
227: sptr=s;
228: sentp=sent;
229: comma=0;
230: }
231: break;
232: case 9:
233: {
234: if(style){
235: nomin = atoi(&yytext[1]);
236: }
237: }
238: break;
239: case 10:
240: {
241: nrofflg=1;
242: if(sentp != sent){
243: sentp->cc = sentp->ic = END;
244: sentp++->sp = sptr;
245: *sptr++ = '.';
246: *sptr++ = '\0';
247: over = 1;
248: nroff = 1;
249: goto fragment;
250: }
251: if(sentno > 0){
252: printf(".SL \"");
253: for(i=0;i<sentno;i++)
254: printf(" %d",leng[i]);
255: printf("\"\n");
256: sentno = 0;
257: }
258: printf("%s",&yytext[1]);
259: }
260: break;
261: case -1:
262: break;
263: default:
264: fprintf(yyout,"bad switch yylook %d",nstr);
265: } return(0); }
266: /* end of yylex */
267: yywrap(){
268: int ii;
269: int ml,mg,lsum,gsum;
270: float aindex, avl, avw;
271: float cindex,kindex,findex,fgrad;
272: float syl, avsy, adjs,snonf;
273: FILE *io;
274:
275: if(style){
276: if(numwds == 0 || numsent == 0)exit(0);
277: avw = (float)(numwds)/(float)(numsent);
278: avl = (float)(numlet)/(float)(numwds);
279: aindex = 4.71*avl + .5*avw -21.43;
280: syl = .9981*vowel-.3432*twds;
281: avsy = syl/twds;
282: kindex = 11.8*avsy+.39*avw-15.59;
283: findex = 206.835-84.6*avsy-1.015*avw;
284: if(findex < 30.)fgrad = 17.;
285: else if(findex > 100.) fgrad = 4.;
286: else if(findex > 70.)fgrad=(100.-findex)/10 +5.;
287: else if(findex > 60.)fgrad =(70.-findex)/10+8.;
288: else if(findex >50.)fgrad=(60.-findex)/5+10;
289: else fgrad=(50.-findex)/6.66 +13.;
290: adjs = 100 * (float)numsent/numwds;
291: cindex = 5.89*avl-.3*adjs-15.8;
292: printf("readability grades:\n (Kincaid) %4.1f (auto) %4.1f (Coleman-Liau) %4.1f (Flesch) %4.1f (%4.1f)\n",kindex,aindex,cindex,fgrad,findex);
293: printf("sentence info:\n");
294: printf(" no. sent %d no. wds %ld\n",numsent,numwds);
295: printf(" av sent leng %4.1f av word leng %4.2f\n",avw,avl);
296: printf(" no. questions %d no. imperatives %d\n",qcount,icount);
297: if(numnonf != 0){
298: snonf = (float)(letnonf)/(float)(numnonf);
299: }
300: printf(" no. nonfunc wds %ld %4.1f%% av leng %4.2f\n",numnonf,(float)(numnonf)*100/numwds,snonf);
301: mg = avw + 10.5;
302: if(mg > 49)mg = 49;
303: ml = avw - 4.5;
304: if(ml <= 0)ml = 1;
305: else if(ml > 49)ml=48;
306: gsum = lsum = 0;
307: for(ii=0;ii<50;ii++){
308: if(ii < ml)lsum += sleng[ii];
309: else if(ii > mg)gsum+= sleng[ii];
310: }
311: printf(" short sent (<%d)%3.0f%% (%d) long sent (>%d) %3.0f%% (%d)\n",ml,sperc(lsum),lsum,mg,sperc(gsum),gsum);
312: printf(" longest sent %d wds at sent %d; shortest sent %d wds at sent %d\n",maxsent,maxindex,minsent,minindex);
313: printf("sentence types:\n");
314: printf(" simple %3.0f%% (%d) complex %3.0f%% (%d)\n",sperc(simple),simple,sperc(complex),complex);
315: printf(" compound %3.0f%% (%d) compound-complex %3.0f%% (%d)\n",sperc(compound),compound,sperc(compdx),compdx);
316: printf("word usage:\n");
317: printf(" verb types as %% of total verbs\n");
318: printf(" tobe %3.0f%% (%d) aux %3.0f%% (%d) inf %3.0f%% (%d)\n",vperc(tobe),tobe,vperc(aux),aux,vperc(infin),infin);
319: if(verbc != 0)adjs = (float)(passive)*100/(float)(verbc);
320: else adjs=0;
321: printf(" passives as %% of non-inf verbs %3.0f%% (%d)\n",adjs,passive);
322: printf(" types as %% of total\n");
323: printf(" prep %3.1f%% (%d) conj %3.1f%% (%d) adv %3.1f%% (%d)\n",wperc(prepc),prepc,wperc(conjc),conjc,wperc(adv),adv);
324: printf(" noun %3.1f%% (%d) adj %3.1f%% (%d) pron %3.1f%% (%d)\n",wperc(noun),noun,
325: wperc(adj),adj,wperc(pron),pron);
326: printf(" nominalizations %3.0f %% (%d)\n",wperc(nomin),nomin);
327: printf("sentence beginnings:\n");
328: ii=beg[0]+beg[7]+beg[6]+beg[3]+beg[8];
329: printf(" subject opener: noun (%d) pron (%d) pos (%d) adj (%d) art (%d) tot %3.0f%%\n",
330: beg[0],beg[7],beg[6],beg[3],beg[8],sperc(ii));
331: printf(" prep %3.0f%% (%d) adv %3.0f%% (%d) \n",sperc(beg[9]),beg[9],sperc(beg[4]),beg[4]);
332: printf(" verb %3.0f%% (%d) ",sperc(beg[1]+beg[10]+beg[11]),beg[1]+beg[10]+beg[11]);
333: printf(" sub_conj %3.0f%% (%d) conj %3.0f%% (%d)\n",sperc(beg[13]),beg[13],sperc(beg[5]),beg[5]);
334: printf(" expletives %3.0f%% (%d)\n",sperc(beg[14]),beg[14]);
335: #ifdef SCATCH
336: if(nosave && (fopen(SCATCH,"r")) != NULL){
337: if(((io=fopen(SCATCH,"a")) != NULL)){
338: fprintf(io," read %4.1f %4.1f %4.1f %4.1f %4.1f\n",kindex, aindex, cindex, findex, fgrad);
339: fprintf(io," sentl %d %ld %4.2f %4.2f %d %d %ld %4.2f\n",numsent,numwds,avw,avl,qcount,icount,numnonf,snonf);
340: fprintf(io," l var %d %d %d %d %d\n",ml,lsum,mg,gsum,maxsent);
341: fprintf(io," t var %d %d %d %d\n",simple,complex,compound,compdx);
342: fprintf(io," verbs %d %d %d %d %d %d\n",tverbc,verbc,tobe,aux,infin,passive);
343: fprintf(io," ty %d %d %d %d %d %d %d\n",prepc,conjc,adv,noun,adj,pron,nomin);
344: fprintf(io," beg %d %d %d %d %d %d\n",beg[0],beg[7],beg[6],beg[3],beg[8],ii);
345: fprintf(io," sbeg %d %d %d %d %d %d\n",beg[9],beg[4],beg[1]+beg[10]+beg[11],beg[13],beg[5],beg[14]);
346: }
347: }
348: #endif
349: }
350: return(1);
351: }
352: float
353: wperc(a)
354: {
355: return((float)(a)*100/numwds);
356: }
357: float
358: sperc(a)
359: {
360: return((float)(a)*100/numsent);
361: }
362: float
363: typersent(a)
364: {
365: return((float)(a)/numsent);
366: }
367: float
368: vperc(a)
369: {
370: if(tverbc == 0)return(0);
371: return((float)(a)*100/tverbc);
372: }
373: main(argc,argv)
374: char **argv;
375: {
376: while(--argc > 0 && (++argv)[0][0] == '-' ){
377: switch(argv[0][1]){
378: case 'd': nosave = 0;
379: continue;
380: case 's': style=1;
381: continue;
382: case 'p': pastyle=style=1;
383: continue;
384: case 'a': pstyle=style=1;
385: continue;
386: case 'e': estyle = style = 1;
387: continue;
388: case 'n': nstyle = style = 1;
389: continue;
390: case 'N': Nstyle = style = 1;
391: continue;
392: case 'l': style=lstyle=1;
393: lthresh = atoi(*(++argv));
394: argc--;
395: continue;
396: case 'r':
397: style=rstyle=1;
398: rthresh = atoi(*(++argv));
399: argc--;
400: continue;
401: case 'P':
402: part = 1;
403: style = 0;
404: continue;
405: case 'b': /* print bare bones info rje */
406: barebones = 1;
407: style = 0;
408: continue;
409: case 'T': /*topic*/
410: style = 0;
411: topic = 1;
412: continue;
413: default:
414: fprintf(stderr,"unknown flag to part %s\n",*argv);
415: exit(1);
416: }
417: argv++;
418: }
419: #ifdef SNOM
420: if(fopen(SNOM,"r") != NULL){
421: deb = fopen(SNOM,"a"); /* SAVE NOM*/
422: }
423: #else
424: deb = NULL;
425: #endif
426: yylex();
427: if(nrofflg && sentno > 0){
428: printf(".SL \"");
429: for(i=0;i<sentno;i++)
430: printf(" %d",leng[i]);
431: printf("\"\n");
432: }
433: }
434: int yyvstop[] ={
435: 0,
436:
437: 5,
438: 0,
439:
440: 9,
441: 0,
442:
443: 9,
444: 0,
445:
446: 6,
447: 0,
448:
449: 3,
450: 0,
451:
452: 3,
453: 4,
454: 0,
455:
456: 10,
457: 0,
458:
459: 2,
460: 9,
461: 0,
462:
463: 1,
464: 0,
465:
466: 8,
467: 0,
468:
469: 8,
470: 0,
471:
472: 7,
473: 8,
474: 0,
475: 0};
476: # define YYTYPE char
477: struct yywork { YYTYPE verify, advance; } yycrank[] ={
478: 0,0, 0,0, 0,0, 4,11,
479: 0,0, 0,0, 0,0, 0,0,
480: 0,0, 0,0, 0,0, 1,3,
481: 4,0, 2,3, 11,0, 14,21,
482: 8,0, 18,0, 19,0, 20,0,
483: 22,0, 23,0, 25,0, 26,0,
484: 0,0, 0,0, 0,0, 0,0,
485: 0,0, 0,0, 0,0, 0,0,
486: 0,0, 0,0, 0,0, 0,0,
487: 0,0, 2,5, 0,0, 0,0,
488: 0,0, 0,0, 0,0, 0,0,
489: 0,0, 0,0, 4,11, 2,6,
490: 0,0, 0,0, 0,0, 0,0,
491: 19,19, 0,0, 0,0, 0,0,
492: 0,0, 0,0, 25,26, 5,12,
493: 1,4, 2,7, 2,8, 6,13,
494: 8,15, 9,16, 10,17, 4,11,
495: 2,9, 2,9, 2,9, 2,9,
496: 2,10, 2,9, 2,9, 2,9,
497: 2,9, 2,9, 2,9, 2,9,
498: 2,9, 2,9, 2,9, 2,9,
499: 2,9, 2,9, 2,9, 2,9,
500: 2,9, 2,9, 2,9, 2,9,
501: 2,9, 2,9, 0,0, 0,0,
502: 0,0, 0,0, 0,0, 0,0,
503: 2,9, 2,9, 2,9, 2,9,
504: 2,9, 2,9, 2,9, 2,9,
505: 2,9, 2,9, 2,9, 2,9,
506: 2,9, 2,9, 2,9, 2,9,
507: 2,9, 2,9, 2,9, 2,9,
508: 2,9, 2,9, 2,9, 2,9,
509: 2,9, 2,9, 7,14, 12,18,
510: 13,19, 15,22, 16,23, 17,24,
511: 24,24, 0,0, 0,0, 7,0,
512: 12,0, 13,0, 15,0, 16,0,
513: 17,0, 24,0, 0,0, 0,0,
514: 0,0, 0,0, 0,0, 0,0,
515: 0,0, 0,0, 0,0, 0,0,
516: 0,0, 0,0, 0,0, 0,0,
517: 0,0, 0,0, 0,0, 0,0,
518: 0,0, 0,0, 0,0, 0,0,
519: 0,0, 0,0, 0,0, 0,0,
520: 0,0, 7,14, 12,18, 13,20,
521: 15,22, 16,23, 17,24, 24,24,
522: 0,0, 17,25, 0,0, 0,0,
523: 0,0, 0,0, 0,0, 0,0,
524: 0,0, 0,0, 0,0, 0,0,
525: 0,0, 0,0, 7,14, 12,18,
526: 13,19, 15,22, 16,23, 17,24,
527: 24,24, 0,0, 0,0, 0,0,
528: 0,0};
529: struct yysvf yysvec[] ={
530: 0, 0, 0,
531: yycrank+1, 0, 0,
532: yycrank+3, 0, 0,
533: yycrank+0, 0, yyvstop+1,
534: yycrank+-2, 0, 0,
535: yycrank+1, 0, 0,
536: yycrank+5, 0, 0,
537: yycrank+-125, 0, 0,
538: yycrank+-6, yysvec+4, 0,
539: yycrank+7, 0, 0,
540: yycrank+8, 0, 0,
541: yycrank+-4, yysvec+4, yyvstop+3,
542: yycrank+-126, 0, 0,
543: yycrank+-127, 0, 0,
544: yycrank+-5, yysvec+7, 0,
545: yycrank+-128, 0, yyvstop+5,
546: yycrank+-129, 0, 0,
547: yycrank+-130, 0, 0,
548: yycrank+-7, yysvec+12, yyvstop+7,
549: yycrank+-8, yysvec+13, yyvstop+9,
550: yycrank+-9, yysvec+13, yyvstop+11,
551: yycrank+0, 0, yyvstop+14,
552: yycrank+-10, yysvec+15, yyvstop+16,
553: yycrank+-11, yysvec+16, yyvstop+19,
554: yycrank+-131, 0, yyvstop+21,
555: yycrank+-12, yysvec+24, yyvstop+23,
556: yycrank+-13, yysvec+24, yyvstop+25,
557: 0, 0, 0};
558: struct yywork *yytop = yycrank+196;
559: struct yysvf *yybgin = yysvec+1;
560: char yymatch[] ={
561: 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
562: 01 ,01 ,012 ,01 ,01 ,01 ,01 ,01 ,
563: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
564: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
565: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
566: 01 ,01 ,01 ,01 ,',' ,',' ,01 ,01 ,
567: 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
568: 01 ,01 ,',' ,01 ,01 ,01 ,01 ,01 ,
569: 01 ,'A' ,'A' ,'A' ,'A' ,01 ,'A' ,'A' ,
570: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
571: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
572: 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 ,
573: 01 ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
574: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
575: 'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,'A' ,
576: 'A' ,'A' ,'A' ,01 ,01 ,01 ,01 ,01 ,
577: 0};
578: char yyextra[] ={
579: 0,0,0,0,0,0,0,0,
580: 0,0,0,0,0,0,0,0,
581: 0};
582: /* ncform 4.1 83/08/11 */
583:
584: int yylineno =1;
585: # define YYU(x) x
586: # define NLSTATE yyprevious=YYNEWLINE
587: char yytext[YYLMAX];
588: struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
589: char yysbuf[YYLMAX];
590: char *yysptr = yysbuf;
591: int *yyfnd;
592: extern struct yysvf *yyestate;
593: int yyprevious = YYNEWLINE;
594: yylook(){
595: register struct yysvf *yystate, **lsp;
596: register struct yywork *yyt;
597: struct yysvf *yyz;
598: int yych;
599: struct yywork *yyr;
600: # ifdef LEXDEBUG
601: int debug;
602: # endif
603: char *yylastch;
604: /* start off machines */
605: # ifdef LEXDEBUG
606: debug = 0;
607: # endif
608: if (!yymorfg)
609: yylastch = yytext;
610: else {
611: yymorfg=0;
612: yylastch = yytext+yyleng;
613: }
614: for(;;){
615: lsp = yylstate;
616: yyestate = yystate = yybgin;
617: if (yyprevious==YYNEWLINE) yystate++;
618: for (;;){
619: # ifdef LEXDEBUG
620: if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
621: # endif
622: yyt = yystate->yystoff;
623: if(yyt == yycrank){ /* may not be any transitions */
624: yyz = yystate->yyother;
625: if(yyz == 0)break;
626: if(yyz->yystoff == yycrank)break;
627: }
628: *yylastch++ = yych = input();
629: tryagain:
630: # ifdef LEXDEBUG
631: if(debug){
632: fprintf(yyout,"char ");
633: allprint(yych);
634: putchar('\n');
635: }
636: # endif
637: yyr = yyt;
638: if ( (int)yyt > (int)yycrank){
639: yyt = yyr + yych;
640: if (yyt <= yytop && yyt->verify+yysvec == yystate){
641: if(yyt->advance+yysvec == YYLERR) /* error transitions */
642: {unput(*--yylastch);break;}
643: *lsp++ = yystate = yyt->advance+yysvec;
644: goto contin;
645: }
646: }
647: # ifdef YYOPTIM
648: else if((int)yyt < (int)yycrank) { /* r < yycrank */
649: yyt = yyr = yycrank+(yycrank-yyt);
650: # ifdef LEXDEBUG
651: if(debug)fprintf(yyout,"compressed state\n");
652: # endif
653: yyt = yyt + yych;
654: if(yyt <= yytop && yyt->verify+yysvec == yystate){
655: if(yyt->advance+yysvec == YYLERR) /* error transitions */
656: {unput(*--yylastch);break;}
657: *lsp++ = yystate = yyt->advance+yysvec;
658: goto contin;
659: }
660: yyt = yyr + YYU(yymatch[yych]);
661: # ifdef LEXDEBUG
662: if(debug){
663: fprintf(yyout,"try fall back character ");
664: allprint(YYU(yymatch[yych]));
665: putchar('\n');
666: }
667: # endif
668: if(yyt <= yytop && yyt->verify+yysvec == yystate){
669: if(yyt->advance+yysvec == YYLERR) /* error transition */
670: {unput(*--yylastch);break;}
671: *lsp++ = yystate = yyt->advance+yysvec;
672: goto contin;
673: }
674: }
675: if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){
676: # ifdef LEXDEBUG
677: if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1);
678: # endif
679: goto tryagain;
680: }
681: # endif
682: else
683: {unput(*--yylastch);break;}
684: contin:
685: # ifdef LEXDEBUG
686: if(debug){
687: fprintf(yyout,"state %d char ",yystate-yysvec-1);
688: allprint(yych);
689: putchar('\n');
690: }
691: # endif
692: ;
693: }
694: # ifdef LEXDEBUG
695: if(debug){
696: fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1);
697: allprint(yych);
698: putchar('\n');
699: }
700: # endif
701: while (lsp-- > yylstate){
702: *yylastch-- = 0;
703: if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){
704: yyolsp = lsp;
705: if(yyextra[*yyfnd]){ /* must backup */
706: while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){
707: lsp--;
708: unput(*yylastch--);
709: }
710: }
711: yyprevious = YYU(*yylastch);
712: yylsp = lsp;
713: yyleng = yylastch-yytext+1;
714: yytext[yyleng] = 0;
715: # ifdef LEXDEBUG
716: if(debug){
717: fprintf(yyout,"\nmatch ");
718: sprint(yytext);
719: fprintf(yyout," action %d\n",*yyfnd);
720: }
721: # endif
722: return(*yyfnd++);
723: }
724: unput(*yylastch);
725: }
726: if (yytext[0] == 0 /* && feof(yyin) */)
727: {
728: yysptr=yysbuf;
729: return(0);
730: }
731: yyprevious = yytext[0] = input();
732: if (yyprevious>0)
733: output(yyprevious);
734: yylastch=yytext;
735: # ifdef LEXDEBUG
736: if(debug)putchar('\n');
737: # endif
738: }
739: }
740: yyback(p, m)
741: int *p;
742: {
743: if (p==0) return(0);
744: while (*p)
745: {
746: if (*p++ == m)
747: return(1);
748: }
749: return(0);
750: }
751: /* the following are only used in the lex library */
752: yyinput(){
753: return(input());
754: }
755: yyoutput(c)
756: int c; {
757: output(c);
758: }
759: yyunput(c)
760: int c; {
761: unput(c);
762: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.