7e3afbba |
1 | %e 3000 |
2 | %p 8000 |
3 | %n 2000 |
4 | %k 2000 |
5 | %a 3000 |
6 | %o 2000 |
7 | BW [ ] |
8 | EW [ .,:;!?_] |
9 | ES [.:;!?] |
10 | VO [aeiouy] |
11 | CO [bcdfghjklmnpqrstvwxz] |
12 | CC [cdfgjklmnprtz] |
13 | SC [cg] |
14 | HC [bdfhjklmnpqrstvwxz] |
15 | ST [pbtdkg] |
16 | LE [a-zA-Z] |
17 | |
18 | %{ |
19 | |
20 | /* English to australian translator */ |
21 | |
22 | /* to build with standard at&t lex |
23 | * lex aust.l |
24 | * cc lex.yy.c -ll -o aust |
25 | * |
26 | * to build with flex |
27 | * flex -I aust.l |
28 | * cc lex.yy.c -o aust |
29 | * |
30 | * (flex is a pd version of lex that runs under Unix, VMS and MSDOS.) |
31 | */ |
32 | |
33 | /* 16Jan90 - wb - first version, based on biffa.l by |
34 | * Stephen K Mulrine <smulrine@cs.strath.ac.uk> */ |
35 | /* 30Jan90 - wb - added more words */ |
36 | /* 16Feb90 - wb - converted from jive to aust */ |
37 | /* 12Mar90 - wb - added some randomness */ |
38 | |
39 | |
40 | /* BW = begin word */ |
41 | /* EW = end word */ |
42 | /* ES = end sentence */ |
43 | /* VO = vowel */ |
44 | /* CO = consonant */ |
45 | /* CC = end of consonant cluster */ |
46 | /* SC = soft consonant (need an 'e') */ |
47 | /* HC = hard consonant (does not need an 'e') */ |
48 | /* ST = stop */ |
49 | /* LE = any letter */ |
50 | |
51 | bloody(n) |
52 | int n; |
53 | { |
54 | if (n == 0 || rand() < n) |
55 | printf((rand() < 20000)? "bloody ": "bleedin' "); |
56 | } |
57 | |
58 | say(msg, n) |
59 | char *msg; |
60 | int n; |
61 | { |
62 | if (rand() < n) |
63 | printf("%s", msg); |
64 | } |
65 | |
66 | oi(n) |
67 | int n; |
68 | { |
69 | say(" Blimey!", n); |
70 | while (rand() < n) |
71 | printf(" OI!"); |
72 | } |
73 | |
74 | |
75 | %} |
76 | |
77 | %% |
78 | "That is" | |
79 | "That's" printf("Thaz"); |
80 | "that is" | |
81 | "that's" printf("thaz"); |
82 | bathroom | |
83 | toilet printf("loo"); |
84 | {BW}john{EW} printf("%cloo%c", yytext[0], yytext[5]); |
85 | [Aa]lright printf("%clrighty", yytext[0]); |
86 | {BW}mad{EW} printf("%cpissed%c", yytext[0], yytext[4]); |
87 | angry | |
88 | annoyed printf("pissed"); |
89 | drunk printf("loaded"); |
90 | drank printf("swilled"); |
91 | drink printf("swill"); |
92 | {BW}beer printf("%cFoster's", yytext[0]); /* Australian for beer, mate */ |
93 | "ught to" printf("ughta"); |
94 | {BW}train printf("%cland train", yytext[0]); |
95 | ough{EW} printf("o%c", yytext[4]); |
96 | Hello{EW} | |
97 | "Good day"{EW} printf("G'day!"); |
98 | hello{EW} | |
99 | "good day"{EW} printf("g'day!"); |
100 | "in Austrailia" | |
101 | "to Austrailia" printf("down under"); |
102 | {BW}bit{EW} printf("%ctad%c", yytext[0], yytext[4]); |
103 | |
104 | {CO}{CC}{EW} printf("%c'%c", yytext[0], yytext[2]); |
105 | {CO}{CC}ed{EW} printf("%c%s", yytext[0], yytext+2); |
106 | of{EW} printf("o'%c", yytext[2]); |
107 | |
108 | Some{BW}one | |
109 | Someone | |
110 | Guy printf("Dude"); |
111 | some{BW}one | |
112 | someone | |
113 | guy printf("dude"); |
114 | |
115 | [Ww]ha printf("%co", yytext[0]); |
116 | {BW}esp printf("'sp"); |
117 | {BW}Esp printf("'Sp"); |
118 | |
119 | {BW}h{LE} printf("%c'%c", yytext[0], yytext[2]); |
120 | off{BW}of printf("offa"); |
121 | |
122 | [Yy]our printf("%cer", yytext[0]); |
123 | you{EW} printf("ya%c", yytext[3]); |
124 | my printf("me"); |
125 | |
126 | {CO}[ai]{SC}e printf("%coi%ce", yytext[0], yytext[2]); |
127 | {CO}[ai]{HC}e printf("%coi%c", yytext[0], yytext[2]); |
128 | {CO}[ai]{CO}[aiouy] printf("%coi%c%c", yytext[0], yytext[2], yytext[3]); |
129 | r[ai]{CO}{CO} printf("%coi%c%c", yytext[0], yytext[2], yytext[3]); |
130 | {CO}igh{LE} printf("%coi%c", yytext[0], yytext[4]); |
131 | extremely | |
132 | really | |
133 | very printf("roit"); |
134 | Extremely | |
135 | Really | |
136 | Very printf("Roit"); |
137 | that printf("wot"); |
138 | Well printf("Welp"); |
139 | baseball | |
140 | football | |
141 | hockey printf("cricket"); |
142 | {VO}th({EW}|{VO}) printf("%ct%c", yytext[0], yytext[3]); |
143 | Who printf("Oo"); |
144 | {BW}who printf("%c'oo", yytext[0]); |
145 | {LE}{CO}er{EW} printf("%c%ca%c", yytext[0], yytext[1], yytext[4]); |
146 | {VO}{CO}e{BW}to printf("%c%ceda", yytext[0], yytext[1]); |
147 | {VO}{CO}{BW}to printf("%c%c%ca", yytext[0], yytext[1], yytext[1]); |
148 | {BW}[Bb]e{CO}{LE} printf("%c'%s", yytext[0], yytext+3); |
149 | {BW}[Aa]{CO}{LE} printf("%c'%s", yytext[0], yytext+2); |
150 | {BW}[Oo]ne? printf("%c'un", yytext[0]); |
151 | |
152 | {LE}\, {ECHO; say(" moit,", 10000);} |
153 | {BW}an?{EW} {if(rand()<12000){printf(" a ");bloody(0);}else printf("%s",yytext);} |
154 | An?{EW} {if(rand()<12000){printf("A ");bloody(0);}else printf("%s",yytext);} |
155 | (T|({BW}t))he{EW} | |
156 | (T|({BW}t))hose{EW} {ECHO; bloody(12000);} |
157 | |
158 | \!|\? {say(", moit", 6000); ECHO; oi(12000);} |
159 | \. {say(", moit", 2000); ECHO; oi(6000);} |
160 | |
161 | {BW}-*[0-9]+" "*("degrees"|([Ff]{LE}*)){EW} {printf("%c%dc%c",*yytext,((atoi(yytext+1)-24)/9)*5,yytext[strlen(yytext)-1]);} |
162 | |
163 | . printf("%s", yytext); |
164 | \n printf("\n"); |
165 | |
166 | %% |
167 | main() |
168 | { |
169 | yylex(); |
170 | } |
171 | |