git @ Cat's Eye Technologies Beatnik / 4e62cd3
Initial import of files for our Beatnik distribution. Chris Pressey 8 years ago
9 changed file(s) with 812 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 Beatnik
1 =======
2
3 This is Cat's Eye Technologies' distribution of tools for Cliff L. Biffle's
4 **[Beatnik][]** programming language. This includes an interpreter for Beatnik,
5 some example Beatnik programs, a compiler from a wimpmode dialect called
6 **Wottasquare**, and various small utilities which can (for example) search a
7 dictionary file for all words with a given Scrabble score.
8
9 Usage information for these tools TBW.
10
11 The contents of this repository are in the public domain.
12
13 [Beatnik]: http://esolangs.org/wiki/Beatnik
0 This is free and unencumbered software released into the public domain.
1
2 Anyone is free to copy, modify, publish, use, compile, sell, or
3 distribute this software, either in source code form or as a compiled
4 binary, for any purpose, commercial or non-commercial, and by any
5 means.
6
7 In jurisdictions that recognize copyright laws, the author or authors
8 of this software dedicate any and all copyright interest in the
9 software to the public domain. We make this dedication for the benefit
10 of the public at large and to the detriment of our heirs and
11 successors. We intend this dedication to be an overt act of
12 relinquishment in perpetuity of all present and future rights to this
13 software under copyright law.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 OTHER DEALINGS IN THE SOFTWARE.
22
23 For more information, please refer to <http://unlicense.org/>
0 Hello, aunts! Totem snaps stoves!
0 Soars, larkspurs, rains.
1 Indistinctness.
2 Mario snarl (nurses, natures, rules...) sensuously retries goal.
3 Agribusinesses' costs par lain ropes (mopes) autos' cores.
4 Tuner ambitiousness.
5 Flit.
6 Dour entombment.
7 Legals' saner kinking lapse.
8 Nests glint.
9 Dread, tied futures, dourer usual tumor grunts alter atonal
10 garb tries shouldered coins.
11 Taste a vast lustiness.
12 Stile stuns gad subgroup gram lanes.
13 Draftee insurer road: cuckold blunt, strut sunnier.
14 Rely enure pantheism: arty gain groups (genies, pan) titters, tattles, nears.
15 Bluffer tapes? Idle diatom stooge!
16 Feted antes anklets ague? Remit goiter gout!
17 Doubtless teared toed alohas will dull gangs' aerials' tails' sluices;
18 Gusset ends! Gawkier halo!
19
20 Enter abstruse rested loser beer guy louts.
21 Curtain roams lasso weir lupus stunt.
22 Truant bears animate talon. Entire torte originally timer.
23 Redo stilt gobs.
24
25 Utter centaurs;
26 Urgent stars;
27 Usurers (dilute);
28 Noses;
29 Bones;
30 Brig sonar graders;
31 Utensil silts;
32 Lazies.
33 Fret arson veterinary rows.
34
35 Atlas grunted: "Pates, slues, sulfuric manor liaising tines,
36 trailers, rep... unfair! Instant snots!"
37
38 Sled rested until eatery fail.
39 Ergs fortitude
40 Indent spotter
41 Euros enter egg.
42 Curious tenures.
43 Torus cutlasses.
44 Sarong torso earns cruel lags it reeled.
45
46 Engineer: "Erase handbag -- unite ratification!"
47
48 oaring oaten donkeys unsold, surer rapid saltest tags
49 BUTTERED TIBIA LUGS REWIRING TOILETS
50 anion festers raring edit epilogues.
51 DIRGE ROTOR.
52 linnet oaring.
53 GORE BOOTIES.
54 Ironed goon lists tallest sublets --
55 Riots,
56 Raucous onset.
57
58 Ignobly, runners' diet anguishes sunrise loner.
59 Erode mob, slier switcher!
60 Loaners stilt drudge pearl atoll, risking hats' ends.
61
62 Rebind sitters.
63
64 Toga epistles -- crud lard. (Pager purse dons souls.)
65
66 glob title a curio hired rites shed suds lade grease strut arctic revs toad
67 unless idlers rind stilt region land GERMICIDES SULTANA GUTS gill siting leans
68 nice spurs
69 tests gloves
70 roused asp
71
72 Holes! Moles! (Sores!)
73 Hygienists! Scars! (Asses!)
74 Smells spell rares.
75
76 Cubs instant sing in parse goodies.
77 Rosin. Unhelpful sisal acres. Slope told.
78 MALENESS PASTA LAB. "Infirmary vine," rang illiterates (beans).
79 Rosin sours, insults truss abalones, nailed rules, helical atlases.
80 Dear remodeling stings mar rents.
81 Sunless shiner orb (silly idol.)
82 Clarity disses senna.
83 Vagabonds sauted; sloes performed gelds.
84 Alter post radial lip sectioning gums.
85 Saint Towellings.
86 Larger aeons telephone stolid char, pal!
87 Boats Dean forsook, rosters, tunas, terrariums -- united, traced.
88 Nude pagoda careens.
0 [5:PUSH]
1 [15]
2 [5:PUSH]
3 [17]
4 [7:ADD]
5 [5:PUSH]
6 [6]
7 [7:ADD]
8 [5:PUSH]
9 [13]
10 [7:ADD]
11 [5:PUSH]
12 [17]
13 [7:ADD]
14 [5:PUSH]
15 [4]
16 [7:ADD]
17 [9:OUTPUT]
18
19 [5:PUSH]
20 [7]
21 [5:PUSH]
22 [17]
23 [7:ADD]
24 [5:PUSH]
25 [16]
26 [7:ADD]
27 [5:PUSH]
28 [16]
29 [7:ADD]
30 [5:PUSH]
31 [6]
32 [7:ADD]
33 [5:PUSH]
34 [10]
35 [7:ADD]
36 [5:PUSH]
37 [7]
38 [7:ADD]
39 [5:PUSH]
40 [6]
41 [7:ADD]
42 [5:PUSH]
43 [15]
44 [7:ADD]
45 [5:PUSH]
46 [1]
47 [7:ADD]
48 [9:OUTPUT]
49
50 [5:PUSH]
51 [5]
52 [5:PUSH]
53 [13]
54 [7:ADD]
55 [5:PUSH]
56 [11]
57 [7:ADD]
58 [5:PUSH]
59 [16]
60 [7:ADD]
61 [5:PUSH]
62 [7]
63 [7:ADD]
64 [5:PUSH]
65 [16]
66 [7:ADD]
67 [5:PUSH]
68 [9]
69 [7:ADD]
70 [5:PUSH]
71 [7]
72 [7:ADD]
73 [5:PUSH]
74 [15]
75 [7:ADD]
76 [5:PUSH]
77 [9]
78 [7:ADD]
79 [9:OUTPUT]
80
81 [5:PUSH]
82 [11]
83 [5:PUSH]
84 [7]
85 [7:ADD]
86 [5:PUSH]
87 [12]
88 [7:ADD]
89 [5:PUSH]
90 [9]
91 [7:ADD]
92 [5:PUSH]
93 [7]
94 [7:ADD]
95 [5:PUSH]
96 [9]
97 [7:ADD]
98 [5:PUSH]
99 [15]
100 [7:ADD]
101 [5:PUSH]
102 [10]
103 [7:ADD]
104 [5:PUSH]
105 [6]
106 [7:ADD]
107 [5:PUSH]
108 [9]
109 [7:ADD]
110 [5:PUSH]
111 [7]
112 [7:ADD]
113 [5:PUSH]
114 [6]
115 [7:ADD]
116 [9:OUTPUT]
117
118 [5:PUSH]
119 [6]
120 [5:PUSH]
121 [14]
122 [7:ADD]
123 [5:PUSH]
124 [5]
125 [7:ADD]
126 [5:PUSH]
127 [10]
128 [7:ADD]
129 [5:PUSH]
130 [7]
131 [7:ADD]
132 [5:PUSH]
133 [7]
134 [7:ADD]
135 [5:PUSH]
136 [9]
137 [7:ADD]
138 [5:PUSH]
139 [15]
140 [7:ADD]
141 [5:PUSH]
142 [16]
143 [7:ADD]
144 [5:PUSH]
145 [9]
146 [7:ADD]
147 [5:PUSH]
148 [13]
149 [7:ADD]
150 [9:OUTPUT]
151
152 [5:PUSH]
153 [8]
154 [5:PUSH]
155 [9]
156 [7:ADD]
157 [5:PUSH]
158 [5]
159 [7:ADD]
160 [5:PUSH]
161 [9]
162 [7:ADD]
163 [5:PUSH]
164 [13]
165 [7:ADD]
166 [9:OUTPUT]
167
168 [5:PUSH]
169 [5]
170 [5:PUSH]
171 [9]
172 [7:ADD]
173 [5:PUSH]
174 [11]
175 [7:ADD]
176 [5:PUSH]
177 [5]
178 [7:ADD]
179 [5:PUSH]
180 [2]
181 [7:ADD]
182 [9:OUTPUT]
183
184 [5:PUSH]
185 [14]
186 [5:PUSH]
187 [17]
188 [7:ADD]
189 [5:PUSH]
190 [15]
191 [7:ADD]
192 [5:PUSH]
193 [8]
194 [7:ADD]
195 [5:PUSH]
196 [11]
197 [7:ADD]
198 [5:PUSH]
199 [12]
200 [7:ADD]
201 [5:PUSH]
202 [10]
203 [7:ADD]
204 [5:PUSH]
205 [12]
206 [7:ADD]
207 [5:PUSH]
208 [6]
209 [7:ADD]
210 [5:PUSH]
211 [9]
212 [7:ADD]
213 [5:PUSH]
214 [5]
215 [7:ADD]
216 [9:OUTPUT]
217
218 [5:PUSH]
219 [9]
220 [5:PUSH]
221 [13]
222 [7:ADD]
223 [5:PUSH]
224 [13]
225 [7:ADD]
226 [5:PUSH]
227 [6]
228 [7:ADD]
229 [5:PUSH]
230 [16]
231 [7:ADD]
232 [5:PUSH]
233 [9]
234 [7:ADD]
235 [5:PUSH]
236 [12]
237 [7:ADD]
238 [5:PUSH]
239 [9]
240 [7:ADD]
241 [5:PUSH]
242 [10]
243 [7:ADD]
244 [5:PUSH]
245 [8]
246 [7:ADD]
247 [5:PUSH]
248 [5]
249 [7:ADD]
250 [5:PUSH]
251 [1]
252 [7:ADD]
253 [9:OUTPUT]
254
255 [5:PUSH]
256 [8]
257 [5:PUSH]
258 [5]
259 [7:ADD]
260 [5:PUSH]
261 [10]
262 [7:ADD]
263 [5:PUSH]
264 [6]
265 [7:ADD]
266 [5:PUSH]
267 [5]
268 [7:ADD]
269 [5:PUSH]
270 [16]
271 [7:ADD]
272 [5:PUSH]
273 [5]
274 [7:ADD]
275 [5:PUSH]
276 [6]
277 [7:ADD]
278 [5:PUSH]
279 [10]
280 [7:ADD]
281 [5:PUSH]
282 [8]
283 [7:ADD]
284 [5:PUSH]
285 [17]
286 [7:ADD]
287 [5:PUSH]
288 [8]
289 [7:ADD]
290 [5:PUSH]
291 [8]
292 [7:ADD]
293 [5:PUSH]
294 [2]
295 [7:ADD]
296 [9:OUTPUT]
297
298 [5:PUSH]
299 [17]
300 [5:PUSH]
301 [7]
302 [7:ADD]
303 [5:PUSH]
304 [10]
305 [7:ADD]
306 [5:PUSH]
307 [17]
308 [7:ADD]
309 [5:PUSH]
310 [11]
311 [7:ADD]
312 [5:PUSH]
313 [5]
314 [7:ADD]
315 [5:PUSH]
316 [10]
317 [7:ADD]
318 [5:PUSH]
319 [12]
320 [7:ADD]
321 [5:PUSH]
322 [14]
323 [7:ADD]
324 [5:PUSH]
325 [5]
326 [7:ADD]
327 [9:OUTPUT]
328
329 [5:PUSH]
330 [8]
331 [5:PUSH]
332 [12]
333 [7:ADD]
334 [5:PUSH]
335 [16]
336 [7:ADD]
337 [5:PUSH]
338 [17]
339 [7:ADD]
340 [5:PUSH]
341 [6]
342 [7:ADD]
343 [5:PUSH]
344 [13]
345 [7:ADD]
346 [5:PUSH]
347 [14]
348 [7:ADD]
349 [5:PUSH]
350 [14]
351 [7:ADD]
352 [9:OUTPUT]
353
354 [5:PUSH]
355 [7]
356 [5:PUSH]
357 [14]
358 [7:ADD]
359 [5:PUSH]
360 [12]
361 [7:ADD]
362 [9:OUTPUT]
363
364 [5:PUSH]
365 [10]
366 [9:OUTPUT]
0 usual banalities
1 usual banalities
2 apron
3 usual banalities
4 apron
5 usual banalities
6 apron
7 usual banalities
8 apron
9 usual banalities
10 apron
11 booster
12
13 usual killjoy
14 usual killjoy
15 apron
16 usual killjoy
17 apron
18 usual killjoy
19 apron
20 usual killjoy
21 apron
22 booster
0 #!/usr/bin/env python
1
2 import sys
3 import re
4
5 SCRABBLE = {
6 'A': 1,
7 'B': 3,
8 'C': 3,
9 'D': 2,
10 'E': 1,
11 'F': 4,
12 'G': 2,
13 'H': 4,
14 'I': 1,
15 'J': 8,
16 'K': 5,
17 'L': 1,
18 'M': 3,
19 'N': 1,
20 'O': 1,
21 'P': 3,
22 'Q': 10,
23 'R': 1,
24 'S': 1,
25 'T': 1,
26 'U': 1,
27 'V': 4,
28 'W': 4,
29 'X': 8,
30 'Y': 4,
31 'Z': 10
32 }
33
34 ACTION = {
35 5: 'PUSH',
36 6: 'DISCARD',
37 7: 'ADD',
38 8: 'INPUT',
39 9: 'OUTPUT',
40 10: 'SUBTRACT',
41 11: 'SWAP',
42 12: 'DUP',
43 13: 'SKIP_AHEAD_ZERO',
44 14: 'SKIP_AHEAD_NONZERO',
45 15: 'SKIP_BACK_ZERO',
46 16: 'SKIP_BACK_NONZERO',
47 17: 'STOP',
48 }
49
50 def scrabble(word):
51 acc = 0
52 for c in word.upper():
53 acc += SCRABBLE[c]
54 return acc
55
56 DEBUG = False
57
58 def debug(s, *args):
59 if not DEBUG:
60 return
61 sys.stderr.write(s % args)
62 sys.stderr.write("\n")
63
64
65 def main(args):
66 global DEBUG
67 tokenize = False
68 text = None
69
70 while args and args[0].startswith('--'):
71 switch = args.pop(0)
72 if switch == '--debug':
73 DEBUG = True
74 elif switch == '--tokenize':
75 tokenize = True
76 elif switch == '--eval':
77 text = args.pop(0)
78 else:
79 raise KeyError("Unknown command-line option '%s'" % switch)
80
81 words = []
82 if text is not None:
83 for word in re.findall(r'[a-zA-Z]+', text):
84 words.append(word)
85 else:
86 with open(args[0]) as f:
87 for line in f:
88 for word in re.findall(r'[a-zA-Z]+', line):
89 words.append(word)
90
91 if tokenize:
92 for word in words:
93 value = scrabble(word)
94 print "'%s' = %s (%s)" % (word, value, ACTION.get(value, '(none)'))
95 sys.exit(0)
96
97 words.append('FOXY') # stop if you get to the end
98
99 stack = []
100 pc = 0
101 done = False
102
103 while not done:
104 value = scrabble(words[pc])
105 debug("* '%s' = %s (%s)", words[pc], value, ACTION.get(value, '(none)'))
106 if value == 5:
107 pc += 1
108 a = scrabble(words[pc])
109 stack.append(a)
110 elif value == 6:
111 stack.pop()
112 elif value == 7:
113 a = stack.pop()
114 b = stack.pop()
115 debug("...ADD %s %s", a, b)
116 stack.append(a + b)
117 elif value == 8:
118 c = sys.stdin.read(1)
119 stack.append(ord(c))
120 elif value == 9:
121 c = stack.pop()
122 debug("...WRITE %s", c)
123 sys.stdout.write(chr(c))
124 elif value == 10:
125 a = stack.pop()
126 b = stack.pop()
127 stack.append(b - a)
128 elif value == 11:
129 a = stack.pop()
130 b = stack.pop()
131 stack.append(a)
132 stack.append(b)
133 elif value == 12:
134 a = stack.pop()
135 stack.append(a)
136 stack.append(a)
137 elif value == 13:
138 a = stack.pop()
139 pc += 1
140 dist = scrabble(words[pc])
141 if a == 0:
142 pc += dist
143 elif value == 14:
144 a = stack.pop()
145 pc += 1
146 dist = scrabble(words[pc])
147 if a != 0:
148 pc += dist
149 elif value == 15:
150 a = stack.pop()
151 pc += 1
152 dist = scrabble(words[pc])
153 if a == 0:
154 pc -= dist
155 elif value == 16:
156 a = stack.pop()
157 pc += 1
158 dist = scrabble(words[pc])
159 if a != 0:
160 pc -= dist
161 elif value == 17:
162 done = True
163 pc += 1
164
165
166 if __name__ == '__main__':
167 main(sys.argv[1:])
0 #!/usr/bin/env python
1
2 import sys
3 import random
4
5
6 def main(args):
7 words = []
8 s = args[0]
9 for c in s:
10 v = ord(c)
11 first = True
12 while v > 0:
13 t = min(random.randint(5, 17), v)
14 v -= t
15 print "[5:PUSH]"
16 print "[%s]" % t
17 if not first:
18 print "[7:ADD]"
19 first = False
20 print "[9:OUTPUT]"
21 print
22
23
24 if __name__ == '__main__':
25 main(sys.argv[1:])
0 #!/usr/bin/env python
1
2 import sys
3 import random
4 import re
5
6
7 SCRABBLE = {
8 'A': 1,
9 'B': 3,
10 'C': 3,
11 'D': 2,
12 'E': 1,
13 'F': 4,
14 'G': 2,
15 'H': 4,
16 'I': 1,
17 'J': 8,
18 'K': 5,
19 'L': 1,
20 'M': 3,
21 'N': 1,
22 'O': 1,
23 'P': 3,
24 'Q': 10,
25 'R': 1,
26 'S': 1,
27 'T': 1,
28 'U': 1,
29 'V': 4,
30 'W': 4,
31 'X': 8,
32 'Y': 4,
33 'Z': 10
34 }
35
36 def scrabble(word):
37 acc = 0
38 for c in word.upper():
39 acc += SCRABBLE[c]
40 return acc
41
42
43 dictionary = {
44 1: ['a', 'I'],
45 2: ['in', 'is', 'no', 'on', 'so', 'it']
46 }
47
48
49 def load_dictionary():
50 with open('/usr/share/dict/words') as f:
51 for line in f:
52 for word in re.findall(r'[A-Za-z]+', line):
53 if len(word) <= 2 or word[0].isupper():
54 continue
55 dictionary.setdefault(scrabble(word), set()).add(word)
56
57
58 def pick_word(num):
59 return random.choice(list(dictionary[num]))
60
61
62 def main(args):
63 find_text = None
64 find_amount = 20
65 while args and args[0].startswith('--'):
66 switch = args.pop(0)
67 if switch == '--find':
68 find_text = args.pop(0)
69 elif switch == '--find-all':
70 find_text = args.pop(0)
71 find_amount = None
72 else:
73 raise KeyError("Unknown command-line option '%s'" % switch)
74
75 load_dictionary()
76
77 if find_text:
78 value = None
79 if find_text.isdigit():
80 value = int(find_text)
81 else:
82 value = scrabble(find_text)
83 print value
84 if find_amount is None:
85 print ' '.join(sorted(dictionary[value]))
86 else:
87 words = list(dictionary[value])
88 random.shuffle(words)
89 print ' '.join(words[:find_amount])
90 sys.exit(0)
91
92 with open(args[0]) as f:
93 for line in f:
94 for num in re.findall(r'\[(\d+)\:?.*?\]', line):
95 print pick_word(int(num))
96
97
98 if __name__ == '__main__':
99 main(sys.argv[1:])