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