newspeak: Fix caseify() and remove unused caseify1()
[filters.git] / nyc.l
CommitLineData
dc17484a 1%{
2/*
3 * Lex filter to transform plain English into Brooklyn English.
4 * No racial or societal slurs are intended. For amusement only.
5 *
6 * Copyright 1986 by Daniel Klein.
7 *
8 * Reproduction permitted so long as this notice is retained.
9 */
10%}
11BW [ \t]
12SP [ \t]
13EW [ \t.,;!\?$]
ff7b4674 14
dc17484a 15%%
fb5da53f 16%{
ff7b4674 17 void plastc();
fb5da53f 18%}
dc17484a 19".so ".*$ printf("%s", yytext);
20[ao]ther printf("%cdder", yytext[0]=='a'?'a':'u');
21[Nn]othing printf("%cuttin'", yytext[0]);
22[Tt]hin printf("%cin", yytext[0]);
23[Tt]hir printf("%coi", yytext[0]);
24[Tt]h[ei] printf("%c%c", caseify('d'), yytext[yyleng-1]);
25[Tt]hat printf("%cat", caseify('d'));
26I'm{SP}going{SP}to printf("I'manna");
27going{SP}to printf("gonna");
28want{SP}to printf("wanna");
29t{SP}you printf("tcha");
30[Dd]id{SP}you{SP}[eaiou] printf("%c'j%c", yytext[0], yytext[yyleng-1]);
31[Dd]id{SP}you printf("%c'ja", yytext[0]);
32[Yy]ou printf("%cuh", yytext[0]);
33[Hh]ow{SP}are{SP}you printf("%cowahrya", yytext[0]);
34[Ww]ith printf("%cit'", yytext[0]);
35[Dd]on't printf("%coan", yytext[0]);
36ldn't |
37dn't printf("n't");
38isn't printf("ain't");
39er{EW} { printf("uh"); plastc(); }
40ing{EW} { printf("in'"); plastc(); }
41[Ww]ord |
42[Hh]eard |
43[BbGgLlPpSs]urg |
44[CcHh][eu]r[ntv] printf("%coi%c", yytext[0], yytext[yyleng-1]);
45[^Mm]mer[^aeiouhrs] printf("%cmoi%c", yytext[0], yytext[yyleng-1]);
46[Oo]re{EW} { printf("%cwh", caseify('a')); plastc(); }
47[Oo]r printf("%cwh", caseify('a'));
48[Oo]f printf("%chv", caseify('u'));
49tion printf("shun");
50alk |
51our[st] |
52or[st] printf("awh%c", yytext[yyleng-1]);
53ause printf("awze");
54[Oo]ff printf("%cwhf", caseify('a'));
55[Ss]tupid printf("%ctoopid", yytext[0]);
56{BW}under printf(" unner");
57{BW}to{EW} { printf(" tuh"); plastc(); }
58[Aa]ctual printf("%cckshul", yytext[0]);
59negro printf("spade");
60[Pp]uerto{SP}[Rr]ican printf("%cpic", caseify('s'));
61[Ii]talian printf("%creaser", caseify('g'));
62[Jj]ewish printf("%cew boy", yytext[0]);
63[Jj]ew printf("%cebe", caseify('h'));
64[a-z]":" { *(yytext+1) = ',';
65 printf("%s like, uhh:",yytext);
66 }
67[a-z]"?" { *(yytext+1) = ',';
68 printf("%s or what?",yytext);
69 }
70! printf("! Okay?");
71[a-z]"." { printf("%s", yytext);expletive();}
72%%
dc17484a 73
ff7b4674
JH
74void plastc()
75{
76 yyunput(yytext[yyleng-1], yytext);
77}
78
dc17484a 79caseify(c)
80char c;
81{
82 if (yytext[0] <= 'Z')
83 return (c - ' ');
84 else
85 return (c);
86}
87
88short count = 0;
89short which = 0;
90
91expletive()
92{
93 if (count++ % 4 == 0) {
94 switch (which++ % 5) {
95 case 0: printf(" Okay?"); break;
96 case 1: printf(" Right?"); break;
97 case 2: printf(" Yuh got me so fahr?"); break;
98 case 3: printf(" Ya' dig?"); break;
99 case 4: printf(" Yuh with me?"); break;
100 }
101 }
102}
7f4e9d5e 103
7f4e9d5e 104int yywrap()
105{
106 return 1;
107}
This page took 0.017043 seconds and 4 git commands to generate.