]>
Commit | Line | Data |
---|---|---|
dc17484a | 1 | %{ |
2 | /* | |
3 | * Lex filter to transform plain English into Cockney 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 | %} | |
11 | ||
12 | BW [ \t\n] | |
13 | SP [ \t]+ | |
14 | EW [ \t.,;!\?$] | |
15 | ||
16 | %Start junk | |
17 | ||
18 | %% | |
fb5da53f | 19 | |
20 | %{ | |
21 | void eos() { | |
22 | if (yytext[yyleng-1] == '.') | |
23 | dintI(); | |
24 | else | |
25 | unput(yytext[yyleng-1]); | |
26 | } | |
27 | ||
28 | void plastc() { | |
29 | unput(yytext[yyleng-1]); | |
30 | } | |
31 | %} | |
32 | ||
dc17484a | 33 | <junk>. { srandom(time(0L)); unput(yytext[0]); BEGIN 0; } |
34 | {BW}[Tt]he{EW} { ECHO; bloody(); } | |
35 | {BW}[Ss]teal{EW} { printf("%c%cick",yytext[0],yytext[1]-5); | |
36 | eos(); | |
37 | } | |
38 | {BW}[Ss]tole{EW} { printf("%c%cicked",yytext[0],yytext[1]-5); | |
39 | eos(); | |
40 | } | |
41 | {BW}tired pooped(); | |
42 | {BW}were{EW} | | |
43 | {BW}was{EW} { printf("%cwuz",yytext[0]); eos(); } | |
44 | [Hh]ello printf("'%cllo", caseify('u')); | |
45 | {BW}[Hh] printf("%c'",yytext[0]); | |
46 | {BW}[Yy]our{EW} { printf("%.2ser",yytext); eos(); } | |
47 | {BW}it{EW} { printf("%.2s'",yytext); eos(); } | |
48 | {BW}go{EW} { printf("%.2sow",yytext); eos(); } | |
49 | {BW}and{EW} { printf("%c'n'",yytext[0]); eos(); } | |
50 | {BW}my{EW} { printf("%.2se",yytext); eos(); } | |
51 | {BW}th(is|at){EW} { printf("%.5s", yytext); eos(); } | |
52 | {BW}[Ww]e{SP}went{EW} | | |
53 | {BW}[Ww]e{SP}had{EW} | | |
54 | {BW}[Ww]e{SP}did{EW} { printf("%.*s",yyleng-1,yytext); | |
55 | set_did(2); | |
56 | eos(); | |
57 | } | |
58 | {BW}I{SP}went{EW} | | |
59 | {BW}I{SP}had{EW} | | |
60 | {BW}I{SP}did{EW} { I(); | |
61 | printf(" did"); | |
62 | set_did(1); | |
63 | eos(); | |
64 | } | |
65 | {BW}I{EW} { I(); eos(); } | |
66 | ||
67 | [Yy]ou{SP}[^aeiouy] { printf("%c'", yytext[0]); plastc(); } | |
68 | [Ww]hat{SP}are{EW} { printf("%cotta", yytext[0]); eos(); } | |
69 | ||
70 | {BW}other | | |
71 | [MmNnRr]other printf("%cuvver",yytext[0]); | |
72 | [MmSs]outh printf("%cowf", yytext[0]); | |
73 | [cYy]outh printf("%coof", yytext[0]); | |
74 | [^o]uth printf("%.2sf",yytext); | |
75 | {BW}th[^e] | | |
76 | [AaEeIiOo]th[^em] { printf("%cf",yytext[0]); plastc(); } | |
77 | oothe | | |
78 | e[ei]the { printf("%c%cve", yytext[0], yytext[0]); } | |
79 | ooth | | |
80 | eeth { printf("%c%cf", yytext[0], yytext[0]); } | |
81 | [aei]the { printf("%cvv",yytext[0]); plastc(); } | |
82 | th putchar('v'); | |
83 | a[km]e{EW} { printf("i%ce",yytext[1]); eos(); } | |
84 | [^r][Oo]ld printf("%.2swld",yytext); | |
85 | [^AaEeIiOoUu][uo]nd[a-z] printf("%cunn%c",yytext[0],yytext[yyleng-1]); | |
86 | ing{EW} { printf("in'"); eos(); } | |
87 | [^dg]get+[^h] printf("%cge'%c",yytext[0],yytext[yyleng-1]); | |
88 | ail printf("aiw"); | |
89 | any printf("enny"); | |
90 | [rSs]ay{EW} { printf("%cigh",yytext[0]); eos(); } | |
91 | way printf("why"); | |
92 | [BbHh]it{EW} { printf("%ci'",yytext[0]); eos(); } | |
93 | ait{EW} { printf("ite"); eos(); } | |
94 | ime{EW} { printf("oime"); eos(); } | |
95 | [^e]ize[^n] printf("%coize%c",yytext[0],yytext[yyleng-1]); | |
96 | [^e]ight printf("%coit",*yytext); | |
97 | [a-z]"?" { *(yytext+1) = ','; | |
98 | printf("%s roit?",yytext); | |
99 | clear_did(); | |
100 | } | |
101 | [a-z]"." { printf("%c", yytext[0]); dintI(); } | |
102 | \n printf("\n"); | |
103 | ||
104 | %% | |
105 | ||
dc17484a | 106 | caseify(c) |
107 | char c; | |
108 | { | |
109 | if (yytext[0] <= 'Z') | |
110 | return (c - ' '); | |
111 | else | |
112 | return (c); | |
113 | } | |
114 | ||
115 | ||
116 | I() | |
117 | { | |
118 | /* extern long random(); */ | |
119 | ||
120 | if (random() % 100 < 20) | |
121 | printf("%cOy",yytext[0]); | |
122 | else | |
123 | printf("%cI",yytext[0]); | |
124 | } | |
125 | ||
126 | static short b_count = 0; | |
127 | static short b_which = 0; | |
128 | ||
129 | bloody() | |
130 | { | |
131 | if (b_count++ % 2 == 0) { | |
132 | switch (b_which++ % 4) { | |
133 | case 0: printf("bloody "); break; | |
134 | case 1: printf("flinkin' "); break; | |
135 | case 2: printf("bleedin' "); break; | |
136 | case 3: printf("soddin' "); break; | |
137 | } | |
138 | } | |
139 | } | |
140 | ||
141 | static short did = 0; | |
142 | ||
143 | set_did(val) | |
144 | { | |
145 | did = val; | |
146 | } | |
147 | ||
148 | clear_did() | |
149 | { | |
150 | did = 0; | |
151 | } | |
152 | ||
153 | dintI() | |
154 | { | |
155 | /* extern long random(); */ | |
156 | ||
157 | if ((did == 1) && (random() % 100 < 50)) | |
158 | printf(", didn'I?"); | |
159 | else if ((did == 2) && (random() % 100 < 50)) | |
160 | printf(", din't we?"); | |
161 | else | |
162 | printf("."); | |
163 | clear_did(); | |
164 | } | |
165 | ||
166 | pooped() | |
167 | { | |
168 | /* extern long random(); */ | |
169 | ||
170 | switch (random() % 3) { | |
171 | case 0: | |
172 | printf("%cknackered", yytext[0]); | |
173 | break; | |
174 | case 1: | |
175 | printf("%cshagged out", yytext[0]); | |
176 | break; | |
177 | case 2: | |
178 | printf("%cdone in", yytext[0]); | |
179 | break; | |
180 | } | |
181 | } | |
182 | ||
183 | expletive() | |
184 | { | |
185 | /* | |
186 | Blimey | |
187 | Stright a light | |
188 | 'Strewth | |
189 | Cor blimey | |
190 | */ | |
191 | } |