9edc0e61 |
1 | %{ -*- Mode:Fundamental -*- |
2 | /* |
3 | * newspeak.l, version 1.1. |
4 | * Lex filter to transform plain English into NewSpeak. |
5 | * Copyright (c) 1991 Jamie Zawinski <jwz@jwz.org>. |
6 | * |
7 | * Permission to use, copy, modify, distribute, and sell this |
8 | * software and its documentation for any purpose is hereby granted |
9 | * without fee, provided that the above copyright notice appear in |
10 | * all copies and that both that copyright notice and this |
11 | * permission notice appear in supporting documentation. No |
12 | * representations are made about the suitability of this software |
13 | * for any purpose. It is provided "as is" without express or |
14 | * implied warranty. |
15 | * |
9edc0e61 |
16 | * To compile: |
17 | * |
18 | * flex newspeak.l |
19 | * cc -O -o newspeak lex.yy.c |
20 | * rm lex.yy.c |
21 | * |
22 | * This must be compiled with "flex", not normal "lex". Lex has |
23 | * some builtin, unchangable limits which this program exceeds. |
24 | * This has been verified to work with flex version 2.3.7, and |
25 | * may not work with flex version 2.3.6. |
26 | * |
27 | * You can get 'flex' by anonymous FTP to prep.ai.mit.edu, or |
28 | * anywhere else you get GNU software. |
29 | * |
30 | * Run this like so: "newspeak < some-text-file | more" |
31 | * |
32 | * There are some design notes near the end. Suggestions and |
33 | * improvements to this code are more than welcome. |
34 | * Hail Big Brother! |
35 | *--------------------------------------------------------------------------- |
36 | */ |
37 | #include <stdio.h> |
38 | |
39 | unsigned int fcounter = 0; |
40 | |
41 | #define Y0 yytext[0] |
42 | #define Y1 yytext[1] |
43 | #define Y2 yytext[2] |
44 | #define Y3 yytext[3] |
45 | #define C caseify |
46 | #define C1 caseify1 |
47 | |
48 | #define CAP(string) capstring(0, (string),0) |
49 | #define WCAP(string) capstring(Y0,(string),1) |
50 | |
51 | #define COMP(string1,string2) compstring(0, (string1),(string2),0) |
52 | #define WCOMP(string1,string2) compstring(Y0,(string1),(string2),1) |
53 | |
54 | #define DUMP() printf("%s",yytext) |
55 | %} |
56 | |
57 | %e 8000 |
58 | %p 9000 |
59 | %n 2000 |
60 | %k 3000 |
61 | %a 5000 |
62 | %o 4000 |
63 | |
64 | W (([ ]?\n[ ]*)|[ ]|[\"'`]) |
65 | ES [.,;:!?/] |
66 | EW ({W}|{ES}|"'") |
67 | |
68 | YOUNG (([Yy]oung|[Ss]mall|[Ll]ittle){W}) |
69 | DEAD (([Dd]ead|[Dd]eceased){W}) |
70 | THE ([Tt]he{W}?) |
71 | ANDOR ({W}(([Aa]nd)|([Oo]r)){W}?) |
72 | COLOR (red|green|blue|yellow|cyan|magenta|purple|orange|mauve|pink|turquoise|brown|gr[ae]y) |
73 | |
74 | %% |
75 | |
76 | %{ |
77 | /****************************** |
78 | * PLUSwords * |
79 | ******************************/ |
80 | %} |
81 | |
82 | [Qq]uite{EW}/[A-Za-z][A-Za-z] CAP("plus"); |
83 | [Rr]ather{EW}/[A-Za-z][A-Za-z][A-Za-z] CAP("plus"); |
84 | [Kk]ind{EW}of{EW}/[A-Za-z][A-Za-z][A-Za-z] CAP("plus"); |
85 | [Kk]inda{EW}/[A-Za-z][A-Za-z][A-Za-z] CAP("plus"); |
86 | [Mm]ore{W}than{W}a{W}(little|bit){W} CAP("plus"); |
87 | [Pp]ro- CAP("plus"); |
88 | |
89 | [Hh]undreds{W}of{W}[Tt]housands | |
90 | [Hh]undreds{ANDOR}[Tt]housands | |
91 | [Hh]undreds{W}if{W}not{W}[Tt]housands | |
92 | [Tt]housands | |
93 | [Mm]illions CAP("doubleplusmany"); |
94 | |
95 | [Dd]ozens CAP("many"); |
96 | [Hh]undreds CAP("plusmany"); |
97 | |
98 | ([Bb]right|[Ll]ight|[Ii]ntense){W}/{COLOR} CAP("plus"); |
99 | ([Dd]im|[Ff]aded|[Dd]ark|[Pp]ale){W}/{COLOR} CAP("plusun"); |
100 | ([Dd]im|[Ff]aded|[Dd]ark|[Pp]ale) CAP("unlight"); |
101 | |
102 | [Ee]very DUMP(); |
103 | [Vv]ery{W} | |
104 | [Rr]eally{W} | |
105 | [Tt]erribly{W} | |
106 | [Aa]wesome({W})? | |
107 | [Aa]wfully{W} CAP("doubleplus"); |
108 | |
109 | [Ww]hopping{EW} CAP("plusbig"); |
110 | |
111 | "O.K." | |
112 | [Aa]ll({W})?[Rr]ight | |
113 | [Oo][Kk][Aa][Yy] CAP("plusgood"); |
114 | {W}OK/{W} WCAP("plusgood"); |
115 | |
116 | ([Tt]oo|[Oo]verly|[Tt]hat){W}[Mm]uch CAP("plusmuch"); |
117 | |
118 | {W}[Bb]ad/{EW} WCAP("ungood"); |
119 | {W}[Pp]oor/{EW} WCAP("ungood"); |
120 | {W}[Ll]ame/{EW} WCAP("ungood"); |
121 | {W}[Pp]itiful/{EW} WCAP("ungood"); |
122 | {W}[Nn]asty/{EW} WCAP("plusungood"); |
123 | {W}[Hh]orrid/{EW} WCAP("doubleplus ungood"); |
124 | {W}[Hh]orrible/{EW} WCAP("doubleplus ungood"); |
125 | {W}[Aa]wful/{W} WCAP("doubleplus ungood"); |
126 | {W}[Ee]vil/{W} WCAP("doubleplus ungood"); |
127 | |
128 | %{ |
129 | /****************************** |
130 | * Titles * |
131 | ******************************/ |
132 | %} |
133 | |
134 | {W}[Ss]ir/{EW} WCAP("citizen"); |
135 | {W}[Mm]r"."/{EW} WCAP("brother"); |
136 | [Mm]ister/{EW} CAP("brother"); |
137 | [Mm]adame? CAP("sister"); |
138 | {W}[Mm]iss/{EW} WCAP("sister"); |
139 | [Mm]a"'"?am/{EW} CAP("sister"); |
140 | {W}[Mm]r?s"."/{EW} WCAP("sister"); |
141 | Mrs/{EW} CAP("sister"); |
142 | |
143 | {YOUNG}?[Cc]hildren CAP("young citizens"); |
144 | {YOUNG}?[Bb]oys{ANDOR}[Gg]irl/s CAP("young citizens"); |
145 | {YOUNG}?([Kk]id|[Gg]irl|[Bb]oy|[Cc]hild)/{EW} CAP("young citizen"); |
146 | |
147 | [Ff]ellow CAP("citizen"); |
148 | |
149 | [Nn]on{W}?"-"?citizen CAP("unperson"); |
150 | [Nn]on{W}?"-"?member CAP("unperson"); |
151 | [Cc]riminal/s? CAP("unperson"); |
152 | {DEAD}(man|woman) CAP("unperson"); |
153 | {DEAD}(men|women) CAP("unpersons"); |
154 | |
155 | [Ii]n{W}[Pp]erson DUMP(); |
156 | |
157 | {W}[Uu]ser WCOMP("party ","worker"); |
158 | [Ss]tudent COMP("party ","worker"); |
159 | [Cc]itizen/s?{EW} COMP("party ","worker"); |
160 | [Pp]erson/s?{EW} COMP("party ","worker"); |
161 | [Pp]eople COMP("party ","workers"); |
162 | |
163 | [Ss]enator | |
164 | [Cc]ongressman | |
165 | [Ss]upervisor | |
166 | [Pp]rofessor printf("Inner Party Member"); |
167 | [Pp]rof"."/{EW} printf("Inner Party Member"); |
168 | [Pp]rof/{EW} printf("Inner Party Member"); |
169 | |
170 | Representative/s? printf("Inner Party Member"); |
171 | representatives printf("Inner Party Members"); |
172 | |
173 | [Ww]hite{W}[Cc]ollar | |
174 | [Uu]pper{W}[Cc]lass COMP("inner ","party"); |
175 | [Mm]iddle{W}[Cc]lass CAP("party"); |
176 | [Bb]lue{W}[Cc]ollar | |
177 | [Ww]orking{W}[Cc]lass | |
178 | [Ll]ower{W}[Cc]lass CAP("prole"); |
179 | ([Ff]ool|[Ii]diot)/s?{EW} CAP("prole"); |
180 | [Ss]tupidity CAP("proleness"); |
181 | |
182 | %{ |
183 | /****************************** |
184 | * Organizations * |
185 | ******************************/ |
186 | %} |
187 | |
188 | [Aa]?{W}([Ww]hite{W}[Hh]ouse|[Gg]ovt\.?|[Gg]overnment){W}([Ss]ource|[Oo]fficial|[Ss]pokes(man|woman|person)) CAP("an Inner Party Member"); |
189 | {THE}?[Rr]epublican{W}[Pp]arty COMP("mini","luv"); |
190 | {THE}?[Dd]emocratic{W}[Pp]arty COMP("mini","plenty"); |
191 | |
192 | {THE}?Congress printf("MiniPax"); |
193 | {THE}?[Ss]enate printf("MiniPax"); |
194 | {THE}?[Hh]ouse{W}[Oo]f{W}[Rr]epresentatives printf("MiniPax"); |
195 | {THE}?[Ss]tate{W}[Dd]epartment printf("MiniPax"); |
196 | {THE}?[Ss]tate{W}[Dd]ept"."? printf("MiniPax"); |
197 | {THE}?[Dd]efen[cs]e{W}[Dd]epartment | |
198 | {THE}?[Dd]efen[cs]e{W}[Dd]ept"."? | |
199 | {THE}?[Ww]ar{W}[Dd]epartment | |
200 | {THE}?[Ww]ar{W}[Dd]ept"."? | |
201 | {THE}?[Hh]ouse{W}of{W}[Cc]ommons | |
202 | {THE}?Pentagon | |
203 | {THE}?[Ff]eds | |
204 | {THE}?FCC | |
205 | {THE}?D[Oo]D | |
206 | {THE}"D."[Oo]".D." | |
207 | {THE}?[Ss]ecret{W}[Ss]ervice COMP("mini","luv"); |
208 | {THE}?White{W}House | |
209 | {THE}?Kremlin printf("MiniTrue"); |
210 | {THE}?(CIA|NSA|FBI|MI"-"?5)/{EW} printf("MiniTrue"); |
211 | {THE}?("C.I.A."|"N.S.A."|"F.B.I.")/{EW} printf("MiniTrue"); |
212 | {THE}?[Aa]rchive/s? COMP("mini","rec"); |
213 | {THE}?[Ll]ibrary COMP("mini","rec"); |
214 | {THE}?[Ll]ibraries COMP("mini","recs"); |
215 | |
216 | [Tt]hought{W}[Pp]olice|[Nn]azis? COMP("think","pol"); |
217 | [Vv]ice{W}[Ss]quad COMP("sex","pol"); |
218 | PMRC|"P.M.R.C." COMP("sex","pol"); |
219 | |
220 | [Oo]fficer CAP("minister"); |
221 | |
222 | {THE}?[Dd]epartment{EW}of{EW}. | |
223 | {THE}?[Dd]ept"."?{EW}of{EW}. | |
224 | {THE}?[Uu]niversity{EW}of{EW}. | |
225 | {THE}?[Uu]niv"."?{EW}of{EW}. | |
226 | {THE}?[Dd]ept"."?{EW}of{EW}. | |
227 | {THE}?([Ss]ub"-"?)?[Cc]omm?itt?ee{EW}(of|on){EW}. | |
228 | {THE}?[Ss]chool{EW}of{EW}. { |
229 | if ((yytext[yyleng-1] >= 'A') && (yytext[yyleng-1] <= 'Z')) |
230 | /* "the school of Law" --> "MiniLaw" */ |
231 | printf("Mini%c",yytext[yyleng-1]); |
232 | else if ((yytext[yyleng-1] >= 'a') && (yytext[yyleng-1] <= 'z')) |
233 | /* "the school of law" --> "MiniLaw" (not "Minilaw") */ |
234 | printf("Mini%c",yytext[yyleng-1] - ('a' - 'A')); |
235 | /* "the school of 5 things" --> "Ministry of 5 things" */ |
236 | else printf("Ministry of %c",yytext[yyleng-1]); |
237 | } |
238 | |
239 | [Dd]epartment | |
240 | [Uu]niversity CAP("ministry"); |
241 | [Uu]niv"."?/{W} CAP("ministry"); |
242 | [Dd]ept"."?/{W} CAP("ministry"); |
243 | ([Ss]ub"-"?)?[Cc]omm?itt?ee CAP("ministry"); |
244 | |
245 | {THE}[Pp]roject/{EW} CAP("the Three Year Plan"); |
246 | [Oo]ur{W}[Pp]roject/{EW} CAP("our Three Year Plan"); |
247 | [Bb]udget printf("Three Year Plan"); |
248 | [Pp]roject/{ES} printf("Three Year Plan"); |
249 | |
250 | {W}({THE}|([aa]{W}))[Pp]roject printf("%cthe Three Year Plan",Y0); |
251 | |
252 | [A-Za-z]+"'"[Ss]/{W}(law|Law|LAW|book|Book|BOOK|rule|Rule|RULE){EW} printf("Goldstein's"); |
253 | |
254 | %{ |
255 | /****************************** |
256 | * Actions * |
257 | ******************************/ |
258 | %} |
259 | |
260 | [Ii]n{W}love{EW} CAP("SexCriming"); |
261 | [Ll]ove{W}you/{EW} CAP("love Big Brother"); |
262 | [Ll]ove{W}me/{EW} CAP("love Big Brother"); |
263 | |
264 | [Cc]loning | |
265 | [Rr]eproduction | |
266 | [Cc]elibacy | |
267 | [Pp]rocreation COMP("good","sex"); |
268 | |
269 | [Cc]elibate | |
270 | [Pp]rocreate COMP("good","sexwise"); |
271 | |
272 | [Tt]elevisions? | |
273 | TVs? | |
274 | [Tt]"."[Vv]"."s? | |
275 | [Rr]adios? | |
276 | [Nn]ews{W}?[Pp]apers? | |
277 | [Jj]ournalism | |
278 | [Mm]ovies? | |
279 | [Rr]ock{EW}?"-"?(and|"&"|"'"?n"'"?){EW}?"-"?[Rr]oll({W}[Mm]usic)? | |
280 | (([Rr]ock|[Cc]lassical|[Ii]ndustrial|[Pp]op|[Dd]ance|[Rr]ap){W})?[Mm]usic | |
281 | [Tt]unes | |
282 | [Mm]oney | |
283 | [Cc]ash | |
284 | [Cc]omic{W}[Bb]ooks? | |
285 | ([Ss]tar{W}?)?[Tt]rek COMP("prole","feed"); |
286 | |
287 | [Pp]eace{W}[Mm]ovement | |
288 | [Pp]eace{W}[Pp]rotest | |
289 | [Aa]nti{EW}[Ww]ar | |
290 | ([Pp]assive{W})?[Rr]esistance | |
291 | [Cc]reativity | |
292 | [Tt]reason | |
293 | [Rr]esearch COMP("crime","think"); |
294 | %{ |
295 | /****************************** |
296 | * Religion * |
297 | ******************************/ |
298 | %} |
299 | |
300 | [Jj]esus{W}[Cc]hrist | |
301 | [Jj]esus | |
302 | {THE}?[Bb]uddh?a | |
303 | [Mm]ohamm?ed | |
304 | [Mm]artin{W}[Ll]uther{W}[Kk]ing | |
305 | J\.?\ ?R\.?\ \"?Bob\"?\ Dobbs printf("doubleplus crimethinker"); |
306 | |
307 | ([Jj]esse{W})?[Hh]elms | |
308 | ([RrDd]on(ald)?{W})?[Rr]ea?gan | |
309 | [Gg]eorge{W}[Gg]uscoria printf("doubleplus goodthinker"); |
310 | |
311 | [Jj]ewish COMP("crime","thinkwise"); |
312 | [Jj]ew | |
313 | [Cc]hristian | |
314 | [Mm]oslem | |
315 | [Bb]uddhist | |
316 | [Aa]thiest | |
317 | [Aa]gnostic COMP("crime","thinker"); |
318 | |
319 | [Ff]aith COMP("belly","feel"); |
320 | |
321 | %{ |
322 | /****************************** |
323 | * Places * |
324 | ******************************/ |
325 | %} |
326 | |
327 | [Ee]ngland|{THE}?[Uu]nited{W}[Kk]ingdom | |
328 | ({THE}?[Uu]nited{W}[Ss]tates{W}[Oo]f{W})?[Aa]merica | |
329 | {THE}?[Uu]nited{W}[Ss]tates|USA|"U.S.A."|[Cc]anada | |
330 | [Gg]ermany|[Ii]srael|[Ee]urope printf("Oceana"); |
331 | |
332 | Iranian|Iraqu?i|Libyan|Russian|African|Egyptian printf("Eurasian"); |
333 | Iran|Iraq|Libya|Russia|Africa|Egypt | |
334 | ([Ss]audi{W})?Arabia|{THE}?Soviet{W}Union printf("Eurasia"); |
335 | [Ss]oviet printf("Eurasian"); |
336 | |
337 | [Cc]hinese|[Jj]apanese|[Tt]aiwanese | |
338 | [Pp]hillipino|[Ii]ndian|[Aa]ustralian|[Mm]exican | |
339 | [Nn]icaraguan|[Ss]alvadori?an printf("Eastasian"); |
340 | China|[Jj]apan|[Tt]aiwan|{THE}?[Pp]hillipines|[Ii]ndia | |
341 | [Aa]ustralia|[Mm]exico|[Nn]icaragua|[Ee]l{W}[Ss]alvador printf("Eastasia"); |
342 | |
343 | [Kk]uwaiti printf("Eurasian"); |
344 | [Kk]uwait printf("The Malabar Front"); |
345 | |
346 | %{ |
347 | /****************************** |
348 | * Miscelaneous Translations * |
349 | ******************************/ |
350 | %} |
351 | |
352 | {W}[Ff]aster WCAP("plus speedful"); |
353 | {W}[Ss]lower WCAP("plus unspeedful"); |
354 | {W}[Ff]ast WCAP("speedful"); |
355 | {W}[Ss]low WCAP("unspeedful"); |
356 | |
357 | [Mm]odern CAP("plusnew"); |
358 | [Aa]ncient CAP("plusunnew"); |
359 | {W}old/{W} WCAP("plusunnew"); |
360 | |
361 | [Hh]appiness CAP("joyfulness"); |
362 | [Hh]appy CAP("joyful"); |
363 | [Qq]uick CAP("speedful"); |
364 | {W}[Ss]peedy WCAP("speedful"); |
365 | [Hh]eavy CAP("weightful"); |
366 | [Hh]eavill?y CAP("weightfully"); |
367 | [Ss]ick(ly)? CAP("unhealthful"); |
368 | |
369 | [Gg]ross | |
370 | [Ss]ickening | |
371 | [Ff]oul | |
372 | [Pp]utrid | |
373 | [Dd]isgusting COMP("crime","thinkful"); |
374 | |
375 | [Ss]mash | |
376 | [Cc]rush | |
377 | [Oo]bliterate | |
378 | [Aa]nnihilate | |
379 | [Nn]eutralize | |
380 | [Dd]emolish | |
381 | [Dd]estroy CAP("unbuild"); |
382 | |
383 | [Ii]nanimate CAP("unlifeful"); |
384 | [Ss]ociety|[Cc]ulture printf("IngSoc"); |
385 | [A-Za-z]+isi?m/{EW} printf("Goldsteinism"); |
386 | [A-Za-z]+ist/{EW} printf("Goldsteinist"); |
387 | |
388 | {W}[Dd]ead WCAP("unlifeful"); |
389 | {W}[Dd]eath WCAP("unlife"); |
390 | {W}[Ll]ie WCAP("untruth"); |
391 | {W}[Ff]alsehood WCAP("untruth"); |
392 | {W}[Mm]istake/{EW} WCAP("untruth"); |
393 | {W}[Ww]hisper WCAP("unshout"); |
394 | {W}[Pp]roud WCAP("prideful"); |
395 | |
396 | [Ff]alse CAP("untrue"); |
397 | [Dd]ark CAP("unlight"); |
398 | [Bb]lack CAP("unwhite"); |
399 | [Ff]orbidden CAP("unallowed"); |
400 | [Ff]orbid CAP("unallow"); |
401 | [Ff]ailure CAP("unsuccess"); |
402 | [Ff]ail/{EW} CAP("unwin"); |
403 | |
404 | [Ss]tatistics?/{EW} CAP("propaganda"); |
405 | {W}[Aa]n{W}[Aa]nn?ouncement WCAP("a NewsFlash"); |
406 | [Aa]nn?ouncement printf("NewsFlash"); |
407 | [Ii]nstructions? printf("B. B. DayOrder"); |
408 | |
409 | [Aa]lmost|[Nn]early CAP("within measurable distance of"); |
410 | [Ff]unny CAP("humorful"); |
411 | |
412 | [Dd]oom CAP("unsave"); |
413 | [Cc]haos CAP("unorder"); |
414 | [Cc]haotic CAP("unorderful"); |
415 | [Ee]nslaved CAP("protected"); |
416 | [Ee]nslave CAP("protect"); |
417 | [Dd]angerous CAP("unsafewise"); |
418 | [Dd]anger CAP("unsafe"); |
419 | ([Bb]lind{W})?[Oo]bedience COMP("ing","soc"); |
420 | \"?[Nn]ew{W}[Ww]orld{W}[Oo]rder\"? printf("IngSoc"); |
421 | |
422 | [Pp]rivacy | |
423 | [Ii]ndividuality COMP("own","life"); |
424 | |
425 | IMHO printf("for the love of Big Brother"); |
426 | |
427 | [Ee]motion(al|s)? | |
428 | [Cc]onviction | |
429 | [Bb]elie(f|ve) | |
430 | [Aa]ccept(ance)? COMP("belly","feel"); |
431 | |
432 | [Dd]emocracy | |
433 | [Ll]iberty | |
434 | [Ff]reedom | |
435 | [Jj]ustice | |
436 | {THE}?[Aa]merican{W}[Ww]ay | |
437 | [Ss]ubversion | |
438 | [Pp]assion COMP("crime","think"); |
439 | |
440 | [Oo]bscenity | |
441 | [Pp]ornography | |
442 | [Oo]rgasm | |
443 | [Ee]rotica COMP("sex","crime"); |
444 | [Ss]exy | |
445 | [Oo]bscene | |
446 | [Pp]ornographic | |
447 | [Ee]rotic COMP("sex","crimeful"); |
448 | |
449 | [Cc]ritic/s?{W} COMP("crime","thinker"); |
450 | |
451 | [Ii]nfant{W}[Mm]ortality COMP("inf","mort"); |
452 | |
453 | [Ff]amilies | |
454 | [Pp]arents COMP("family ","units"); |
455 | [Mm]other{ANDOR}[Ff]ather | |
456 | [Bb]rother{ANDOR}[Ss]ister COMP("family ","unit"); |
457 | {W}[Pp]arent/s?{EW} WCOMP("family ","unit"); |
458 | [Ff]amily COMP("family ","unit"); |
459 | |
460 | God/{EW} printf("Big Brother"); |
461 | [Pp]res(ident|".")({W}([Bb]ush|[Rr]eagan))? printf("Big Brother"); |
462 | [Pp]rime{W}[Mm]inister printf("Big Brother"); |
463 | |
464 | ([Gg][Nn][Uu]{W}([Ee]macs|EMACS){W})?[Gg]eneral{W}[Pp]ublic{W}[Ll]icense printf("NewSpeak Dictionary"); |
465 | |
466 | (questioning|murder|ass?ass?ination)/{ES} printf("interrogation"); |
467 | |
468 | [Ss]keptic/{EW} CAP("unperson"); |
469 | [Ss]illy CAP("foolhardy"); |
470 | {W}[A-Za-z][A-Za-z]?illy DUMP(); |
471 | [Ss]outhern|[Ss]outherly CAP("southwise"); |
472 | [Nn]orthern|[Nn]ortherly CAP("northwise"); |
473 | [Ee]astern|[Ee]easterly CAP("eastwise"); |
474 | [Ww]estern|[Ww]esterly CAP("westwise"); |
475 | [Pl]leasant CAP("goodwise"); |
476 | [Vv]iolent CAP("unpeacewise"); |
477 | [Vv]iolence CAP("unpeaceness"); |
478 | [Ii]ndifference CAP("uncarefulness"); |
479 | [Ii]ndifferent CAP("uncareful"); |
480 | [Bb]elly CAP("abdomen"); |
481 | [Cc]omic CAP("humorwise"); |
482 | {W}[Uu]nless WCAP("lest"); |
483 | usually printf("usualwise"); |
484 | |
485 | [Gg]uerillas COMP("party ","workers"); |
486 | |
487 | [Ww]ar/{EW} CAP("engagement"); |
488 | [Dd]efen[cs]e/{EW} CAP("peace"); |
489 | [Ii]nvasion CAP("liberation"); |
490 | |
491 | %{ |
492 | /****************************** |
493 | * Syllable Rewriting * |
494 | ****************************** |
495 | isn't ___ is un___ |
496 | not the ___ the un___ |
497 | not my ___ my un___ |
498 | anti___ un___ (etc...) |
499 | ___cally ___wise |
500 | ___ally ___wise |
501 | ___lly ___wise |
502 | ___ly ___wise |
503 | ___aic ___wise |
504 | ___lic ___wise |
505 | ___nnic ___wise |
506 | <VOWEL>tric ___wise |
507 | ___ic ___wise |
508 | <VOWEL>ous ___ful |
509 | <CONSONANT>ous ___eful |
510 | ___less un___ful |
511 | |
512 | */ |
513 | %} |
514 | |
515 | [Ii]sn"'"t{W}my{W} CAP("is my un"); |
516 | [Ii]s{W}not{W}my{W} CAP("is my un"); |
517 | [Ii]sn"'"t{W}[Tt]he{W} CAP("is the un"); |
518 | [Ii]s{W}not{W}[Tt]he{W} CAP("is the un"); |
519 | [Ii]sn"'"t{W}[Ii]n{W}[Tt]he{W} CAP("is in the un"); |
520 | [Ii]s{W}not{W}[Ii]n{W}[Tt]he{W} CAP("is in the un"); |
521 | [Ii]t"'"?s{W}not{W}[Tt]he{W} CAP("it's the un"); |
522 | [Ii]sn"'"t{W} CAP("is un"); |
523 | [Ii]s{W}not{W} CAP("is un"); |
524 | [Nn]ot{W}[Tt]he{W} CAP("the un"); |
525 | [Nn]ot{W}[Mm]y{W} CAP("my un"); |
526 | [Nn]ot{W}[Aa]{W} CAP("an un"); |
527 | [Nn]ot{W}have{W} CAP("has un"); |
528 | [Nn]ot{W}be{W} CAP("be un"); |
529 | [Nn]ot{W}[Oo]nly/{W} CAP("unonly"); /* avoid "unonwise" */ |
530 | |
531 | [Aa]{W}[Nn]ot{W} | |
532 | [Aa]{W}[Nn]on"-"? printf("%cn%cun",Y0,Y1); /* "a non_" -> "an un_" */ |
533 | |
534 | %{ |
535 | /* {W}[Nn]ot{W} | */ |
536 | %} |
537 | {W}[Ii]l"-"?/[a-z][a-z] WCAP("un"); |
538 | {W}[Aa]nti"-"? | |
539 | {W}[Nn]on"-"? WCAP("un"); |
540 | |
541 | robably|ventually|[Oo]bvious|[Bb]asic|{W}[Oo]nly|otally | |
542 | [Aa]rctic|holic|{EW}ally|{EW}[Aa]pply|{W}[Tt]opic DUMP(); |
543 | |
544 | {W}([Tt]raf|[Pp]aci|[Ss]peci)fi/c{W} DUMP(); |
545 | {W}(ma|tra)gi/c{W} DUMP(); |
546 | {W}(pub|cyc|re|fro|gar)li/c{W} DUMP(); |
547 | {W}(eth|cli|to)ni/c{W} DUMP(); |
548 | {W}(E|cle|met|cit)ri/c{W} DUMP(); |
549 | {W}(ch|ep|tr?op|t|mus|stat|att)i/c{W} DUMP(); |
550 | {W}only/{W} DUMP(); |
551 | {W}[Aa]tlantic DUMP(); |
552 | |
553 | [ \t\n][drstwDRSTW]ally printf("%c%cally", Y0, Y1); |
554 | |
555 | [a-z]ically/{W} printf("%cwise", Y0); |
556 | [a-z]ally/{W} printf("%cwise", Y0); |
557 | [a-z][a-z]lly/{W} printf("%c%cwise", Y0,Y1); |
558 | [a-z][a-z][a-z]ly/{W} printf("%c%c%cwise", Y0,Y1,Y2); |
559 | [a-z]ical/{W} printf("%cwise", Y0); |
560 | |
561 | [a-km-qs-z]aic/{EW} printf("%cwise", Y0); /* not laic, raic */ |
562 | [a-z]lic/{EW} printf("%clwise", Y0); |
563 | [a-z]nnic/{EW} printf("%cnwise", Y0); |
564 | [a-z][aeiou]tric/{EW} printf("%c%ctwise", Y0, Y1); |
565 | [a-z]tric/{EW} printf("%cwise", Y0); |
566 | [a-z]ic/{EW} printf("%cwise", Y0); |
567 | [a-z]lly/{EW} printf("%cwise", Y0); |
568 | [a-z]ly/{EW} printf("%cwise", Y0); |
569 | |
570 | [aeiouy][^aeiouy]ous/{EW} printf("%c%cful",Y0,Y1); |
571 | [^aeiouy]ous/{EW} printf("%ceful",Y0); |
572 | [^e]ous/{EW} printf("%cful",Y0); |
573 | |
574 | [A-Za-z]+less/{EW} { yytext[yyleng-4] = '\0'; |
575 | if (((yytext[1] < 'A') || (yytext[1] > 'Z')) && |
576 | (yytext[0] >= 'A') && (yytext[0] <= 'Z')) |
577 | yytext[0] = yytext[0] - ('a' - 'A'); |
578 | printf("%cn%sful",C('u'), yytext); |
579 | } |
580 | |
581 | ". " { printf("%s",yytext); |
582 | fcounter &= 15; |
583 | if (14 == fcounter++) printf("(fnord) "); |
584 | } |
585 | |
3872d98c |
586 | [.,!?]\"([^\n\".!]+[.!])?\n/[\n\t ] printf("%c Hail Big Brother!\"%s",Y0,yytext+2); |
9edc0e61 |
587 | \"([.,!?][^\n\".!]+[.!])?\n/[\n\t ] printf("%c Hail Big Brother!\"%s",Y1,yytext+2); |
588 | |
9a251f02 |
589 | . printf("%s", yytext); |
9edc0e61 |
590 | \n printf("\n"); |
591 | |
592 | %{ |
593 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
594 | * Brief description of Orwell's NewSpeak: |
595 | * --------------------------------------- |
596 | * Each word was made to serve as noun, verb, adjective and adverb. In |
597 | * particular, nouns and verbs were made exactly the same -- hence "think" |
598 | * replaced "thought" as a noun (viz. "crimethink" = thought crime, "thinkpol" |
599 | * = thought police). Adjectives were formed by adding "-ful" to a noun/verb; |
600 | * adverbs were formed by adding "-wise." Hence "speedful" = fast, |
601 | * "speedwise" = quickly, "unspeedwise" = slowly. |
602 | * |
603 | * The decision on which word should be negated was made fairly randomly; |
604 | * "dark" could be "unlight," or "light" could be "undark". But in all cases |
605 | * the most important objective (aside from ideological restriction) was |
606 | * euphony; the words had to be easily pronounceable. |
607 | * |
608 | * Most verb inflections were made regular; "he thinked," "he goed," "he |
609 | * eated"; only the auxiliaries and modals (to be, to have, may, shall, will, |
610 | * etc.) were allowed to inflect irregularly. Plurals were also regularized: |
611 | * "mans," "oxes," "childs." [This isn't implemented here.] |
612 | * |
613 | * There were three sets of words. The A vocabulary was for everyday use: |
614 | * car, man, red, good, etc. It was restricted to fairly simple words. |
615 | * |
616 | * The B vocabulary consisted of political/ideological words with very |
617 | * complicated connotations. All of the B words were compound words -- |
618 | * bellyfeel (blind emotional acceptance of the ideology), oldthink (the way |
619 | * of thought before the Revolution), crimethink, Ingsoc, goodsex (intercourse |
620 | * solely for the purpose of making babies and with no physical enjoyment on |
621 | * the part of the female), sexcrime (any kind of sex but goodsex, including |
622 | * sex for its own sake), goodthink (thinking in accordance with Ingsoc), and |
623 | * so on. These words were also subject to the modifications mentioned |
624 | * above--hence "goodthinker," "goodthinkful," "goodthinkwise." |
625 | * |
626 | * The C vocabulary consisted of scientific and technical words (though there |
627 | * was no longer any word for "science," any connotation it might have being |
628 | * subsumed into "Ingsoc"). |
629 | * |
630 | * Implementing a translator for all of this would be really complicated -- |
631 | * I'd need rather extensive lists of the "irregular" words (so they could be |
632 | * regularized), as well as lists of politically meaningful words (so they |
633 | * could be excised or translated into either "goodthink" or "crimethink," as |
634 | * appropriate). Any kind of sexual topic should become "sexcrime" (it being |
635 | * unlikely that any talk of sex these days would fit into "goodsex"). |
636 | * |
637 | * Basically, the reason it's hard is that NewSpeak was intended to *decrease* |
638 | * the vocabulary, and subsume complicated ideas into politically correct |
639 | * words so that you wouldn't have to understand the ideas anymore; you'd just |
640 | * have to emit the right words. So to properly "translate" anything into |
641 | * NewSpeak, you have to cut the vocabulary way down. |
642 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
643 | */ |
644 | %} |
645 | |
646 | %% |
647 | main() |
648 | { |
649 | yylex(); |
650 | printf("\nHail Big Brother!\n"); |
651 | } |
652 | |
653 | |
654 | capstring(firstchar,string,i) |
655 | char firstchar, *string; |
656 | int i; |
657 | { |
658 | if (firstchar != 0) putchar(firstchar); |
659 | putchar( (yytext[i] <= 'Z') ? (string[0] - ' ') : string[0]); |
660 | printf("%s",string+1); |
661 | } |
662 | |
663 | compstring(firstchar,string1,string2,i) |
664 | char firstchar, *string1, *string2; |
665 | int i; |
666 | { |
667 | capstring(firstchar,string1,i); |
668 | capstring(0,string2,i); |
669 | } |
670 | |
671 | _caseify(c,i) |
672 | char c; |
673 | int i; |
674 | { |
675 | if (yytext[i] <= 'Z') return (c - ' '); |
676 | else return (c); |
677 | } |
678 | |
679 | caseify(c) |
680 | char c; |
681 | { _caseify(c,0); } |
682 | |
683 | caseify1(c) |
684 | char c; |
685 | { _caseify(c,1); } |