%{ /*- * %sccs.include.proprietary.c% */ #ifndef lint static char sccsid[] = "@(#)style1.l 8.2 (Berkeley) 01/28/94"; #endif /* not lint */ /* break out words, output cap + word(inverted) */ #include #include #define OUT() for(i=yyleng-1;i>=0; i--)putchar(my_yytext[i]); putchar('\n') #define OUT1(nam) printf("%c:%s\n",nam,my_yytext) #define OUTN(string) printf("%s\n",string) #include "names.h" #include "nhash.c" #include "dict.c" #include "ydict.c" #include "abbrev.c" char nt[] = "D:n't"; char qs[] = "c:'s"; char fin[] = "E:."; int NOCAPS = 0; /* if set all caps are turned to lower case */ int i,j; int dot = 0; int first = 1; int qflg,nflg; int cap = 0; static char my_yytext[YY_BUF_SIZE]; #define YY_USER_ACTION strcpy(my_yytext, yytext); %} L [a-z] N [0-9] C [A-Z] A [a-zA-Z] P [a-zA-Z0-9] %% ^[.!].+[\n] { if(dot){ OUTN(fin); dot = 0; first = 1; } printf(":%s",my_yytext); } May { if(first == 0){ OUT1(NOUN); } else { first = 0; my_yytext[0] = tolower(my_yytext[0]); cap = 1; goto wd; } } "U.S." { OUT1(NOUN); } {C}{L}*'[s] { pos(1); if(first==1)first=0; } {C}+['][s] { if(NOCAPS) for(i=0;i0;i--) if(my_yytext[i] == '.')break; unput(my_yytext[yyleng-1]); my_yytext[i] = '\0'; OUT1(NOUN_ADJ); OUTN(fin); first = 1; } ([hH]e"/"[sS]he)|([sS]he"/"[hH]e) { if(NOCAPS) if(isupper(my_yytext[0]))my_yytext[0] = tolower(my_yytext[0]); OUT1(PRONS); } ([hH]is"/"[hH]er)|([hH]er"/"[hH]is) { if(NOCAPS) if(isupper(my_yytext[0]))my_yytext[0] = tolower(my_yytext[0]); OUT1(POS); } [ \t`]*[a-zA-Z0-9.]*("\/"[a-zA-Z0-9.]+)+[']* { if(my_yytext[yyleng-1] == '.'){ if(ahead() == 0)dot=1; } if(NOCAPS) for(i=0;i1) { if(freopen(argv[1],"r",stdin)==NULL) { fprintf(stderr,"%s: cannot open\n", argv[1]); rc++; }else{ filename=argv[1]; yylex(); OUTN(fin); } argc--; argv++; } } return(rc); } ahead(){ register int c; if(isalnum((c=input()))){ my_yytext[yyleng++] = '.'; while(!isspace((c=input() ))) my_yytext[yyleng++] = c; my_yytext[yyleng] = '\0'; unput(c); return(1); } unput(c); unput('.'); return(0); }