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