X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/2958d0fea855a19268cd8f2a0d1a14487b8793ad..280efb104c03e7c87181e2538243f033cbf616d2:/usr/src/usr.bin/diction/style1/style1.l?ds=inline diff --git a/usr/src/usr.bin/diction/style1/style1.l b/usr/src/usr.bin/diction/style1/style1.l index a994cebe1a..9fbc6deeae 100644 --- a/usr/src/usr.bin/diction/style1/style1.l +++ b/usr/src/usr.bin/diction/style1/style1.l @@ -2,10 +2,11 @@ /* break out words, output cap + word(inverted) */ #ifndef lint -static char sccsid[] = "@(#)style1.l 4.1 (Berkeley) 82/11/06"; +static char sccsid[] = "@(#)style1.l 4.2 (Berkeley) 82/11/06"; #endif not lint #include +#include #define OUT() for(i=yyleng-1;i>=0; i--)putchar(yytext[i]); putchar('\n') #define OUT1(nam) printf("%c:%s\n",nam,yytext) #define OUTN(string) printf("%s\n",string) @@ -13,9 +14,11 @@ static char sccsid[] = "@(#)style1.l 4.1 (Berkeley) 82/11/06"; #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; @@ -23,39 +26,75 @@ int qflg,nflg; int cap = 0; %} %p 3000 -%a 2500 +%a 3300 +%o 4500 L [a-z] N [0-9] C [A-Z] +A [a-zA-Z] +P [a-zA-Z0-9] %% -(St|Dr|Drs|Mr|Mrs|Ms)"." { +^[.!].+[\n] { + if(dot){ + OUTN(fin); + dot = 0; + first = 1; + } + printf(":%s",yytext); + } +May { + if(first == 0){ + OUT1(NOUN); + } + else { + first = 0; + yytext[0] = tolower(yytext[0]); + cap = 1; + goto wd; + } + } +"U.S." { OUT1(NOUN); } {C}{L}*'[s] { pos(1); if(first==1)first=0; } -{C}+['][s]* { +{C}+['][s] { + if(NOCAPS) + for(i=0;i1) { if(freopen(argv[1],"r",stdin)==NULL) { @@ -430,9 +477,24 @@ char *argv[]; }else{ filename=argv[1]; yylex(); + OUTN(fin); } argc--; argv++; } } return(rc); } +ahead(){ + register int c; + if(isalnum((c=input()))){ + yytext[yyleng++] = '.'; + while(!isspace((c=input() ))) + yytext[yyleng++] = c; + yytext[yyleng] = '\0'; + unput(c); + return(1); + } + unput(c); + unput('.'); + return(0); +}