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