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