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