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