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