home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3156 < prev    next >
Encoding:
Internet Message Format  |  1991-04-02  |  19.6 KB

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