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