1 %{ 2 /*- 3 * %sccs.include.proprietary.c% 4 */ 5 6 #ifndef lint 7 static char sccsid[] = "@(#)style2.l 4.4 (Berkeley) 04/17/91"; 8 #endif /* not lint */ 9 10 #include <stdio.h> 11 #include <ctype.h> 12 #include "names.h" 13 #include "ehash.c" 14 #include "edict.c" 15 16 #undef yywrap 17 18 #define OUT1(c) putchar(c); putchar(':'); for(i=yyleng-1;i>=0;)putchar(yytext[i--]) 19 #define POUT1(c) putchar(c); putchar(':'); for(i=yyleng-1;i>0;)putchar(yytext[i--]) 20 int i; 21 int nomin = 0; 22 int NOCAPS = 0; /*if set, all caps mapped to lower, plurals stripped*/ 23 %} 24 25 C [A-Z0-9a-z",;] 26 L [a-zA-Z-] 27 28 %% 29 ^{C}:.+ { 30 ECHO; 31 } 32 ^ci.+ { 33 look(ic,2,ADJ); 34 } 35 ^de.+ { 36 look(ed,2,ED); 37 } 38 ^draw.+ { 39 if(yytext[5] == 'E'){ 40 OUT1(NOUN_ADJ); 41 } 42 OUT1(ADJ_ADV); 43 } 44 ^eca.+ { 45 look(ace,3,NOUN_VERB); 46 } 47 ^eci.+ { 48 look(ice,3,NOUN_VERB); 49 } 50 ^ecne.+ { 51 if(look(ence,4,NOM))nomin++; 52 } 53 ^ecna.+ { 54 if(look(ance,4,NOM))nomin++; 55 } 56 ^ee.+ { 57 look(ee,2,NOUN); 58 } 59 ^ega.+ { 60 look(age,3,NOUN); 61 } 62 ^elba.+ { 63 look(able,4,ADJ); 64 } 65 ^elbi.+ { 66 look(ible,4,ADJ); 67 } 68 ^elc.+ { 69 look(cle,3,NOUN); 70 } 71 ^eru.+ { 72 look(ure,3,NOUN); 73 } 74 ^eti.+ { 75 look(ite,3,NOUN); 76 } 77 ^evi.+ { 78 look(ive,3,ADJ); 79 } 80 ^ezi.+ { 81 look(ize,3,VERB); 82 } 83 ^gni.+ { 84 look(ing,3,ING); 85 } 86 ^hsi.+ { 87 look(ish,3,ADJ); 88 } 89 ^lac.+ { 90 look(cal,3,ADJ); 91 } 92 ^lanoi.+ { 93 look(ional,5,ADJ); 94 } 95 ^luf.+ { 96 look(ful,3,ADJ); 97 } 98 ^msi.+ { 99 OUT1(NOUN); 100 } 101 ^nam.* { 102 look(man,3,NOUN); 103 } 104 ^nem.* { 105 OUT1(NV_PL); 106 } 107 ^noi.+ { 108 if(look(ion,3,NOM))nomin++; 109 } 110 ^pihs.+ { 111 look(ship,4,NOUN); 112 } 113 ^ral.+ { 114 look(lar,3,ADJ); 115 } 116 ^ronoh { 117 OUT1(NOUN_VERB); 118 } 119 ^ro.+ { 120 OUT1(NOUN); 121 } 122 ^si.+ { 123 look(is,2,NOUN); 124 } 125 ^ssel.+ { 126 look(less,4,ADJ); 127 } 128 ^ssen.+ { 129 look(ness,4,NOUN); 130 } 131 ^sse.+ { 132 look(ess,3,NOUN); 133 } 134 ^ss.+ { 135 look(ss,2,NOUN); 136 } 137 ^suo.+ { 138 look(ous,3,ADJ); 139 } 140 ^su.+ { 141 look(us,2,NOUN); 142 } 143 ^snoi.+ { 144 if(look(ion,4,PNOUN))nomin++; 145 } 146 ^stnem.+ { 147 if(look(ment,5,PNOUN))nomin++; 148 } 149 ^secne.+ { 150 if(look(ence,5,PNOUN))nomin++; 151 } 152 ^secna.+ { 153 if(look(ance,5,PNOUN))nomin++; 154 } 155 ^s.+ { 156 if(isupper(yytext[yyleng-1])){ 157 if(NOCAPS){ 158 yytext[yyleng-1] = tolower(yytext[yyleng-1]); 159 POUT1(PNOUN); 160 } 161 else { OUT1(PNOUN); } 162 } 163 else { 164 if(NOCAPS){POUT1(NV_PL);} 165 else{ OUT1(NV_PL); } 166 } 167 } 168 ^tna.+ { 169 look(ant,3,NOUN_ADJ); 170 } 171 ^tnem.+ { 172 if(look(ment,4,NOM))nomin++; 173 } 174 ^tse.+ { 175 look(est,3,ADJ); 176 } 177 ^tsi.+ { 178 look(ist,3,NOUN); 179 } 180 [,\n] { 181 putchar(yytext[0]); 182 } 183 {L}+ { 184 if(isupper(yytext[yyleng-1])){ 185 if(NOCAPS) 186 yytext[yyleng-1] = tolower(yytext[yyleng-1]); 187 if((yytext[0] == 'n' || yytext[0] == 'l') && yytext[1] == 'a'){ 188 OUT1(NOUN_ADJ); 189 } 190 else { 191 OUT1(NOUN); 192 } 193 } 194 else { 195 OUT1(UNK); 196 } 197 } 198 ^:[\n] { 199 egetd(); 200 } 201 ^:.+[\n] { 202 printf("%s",yytext); 203 } 204 %% 205 look(f,n,nc) 206 char (*f)(); 207 int n; 208 char nc; 209 { 210 int in,nn,ret; 211 char sch; 212 in=0; 213 sch=yytext[yyleng-1]; 214 if(isupper(sch)){ 215 yytext[yyleng-1] = tolower(sch); 216 in=1; 217 } 218 if((*f)(&yytext[n],1,0) != 0){ 219 nn = (*f)(&yytext[n],1,0); 220 if(nc == PNOUN) 221 if(nn == NOUN_VERB){ 222 if(in == 1)nn=PNOUN; 223 else nn=NV_PL; 224 } 225 ret = 0; 226 } 227 else { 228 nn = nc; 229 ret = 1; 230 } 231 if(in==1){ 232 if(nn == NOUN_VERB)nn=NOUN; 233 if(!NOCAPS)yytext[yyleng-1]=sch; 234 } 235 if(nn==PNOUN && yytext[0] == 's' && NOCAPS){ 236 POUT1(nn); 237 } 238 else { 239 OUT1(nn); 240 } 241 return(ret); 242 } 243 yywrap(){ 244 printf(";%d\n",nomin); 245 return(1); 246 } 247