Skip to content

Instantly share code, notes, and snippets.

Last active Oct 14, 2021
What would you like to do?
A ridiculous interpreter for the joke esoteric programming language APLBAONWSJAS
#!/usr/bin/env python3
import re
import subprocess
This is a ridiculous interpreter for the joke esoteric programming language APLBAONWSJAS
see for details.
!!!WARNING!!! this takes user input and runs it without checking as system commands,
this could have unintended consequences, and what you type could make changes to your
filesystem etc, use at your own risk, don't run as root, or with scissors.
Any argument you pass to the EXECUTE() command will be run as a subprocess as if
you typed it into a shell.
!!!WARNING!!! this is for entertainment purposes only, and should not be used for anything,
CMD = re.compile('EXECUTE\(\s*(.*)\s*\)')
THRESH = [7, 14, 27]
def init():
assistant = Rosie()
v = assistant.__version__**(1/7)
print("A Programming Language By Any Other Name Would Smell Just As Sweet (APLBAONWSJAS) Interpreter v{:.3f}".format(v))
print("[Rosie intelligent assistant v{}]".format(assistant.__version__))
return assistant
def main(e, rosie):
c = input(PROMPT)
if CMD.match(c):
orig = CMD.match(c).group(1).strip()
cmd = orig
if cmd == 'APLBAONWSJAS':
cmd = __file__
tries = 0
while tries < 30:
if not cmd: break # successfully execute null program
tries += 1
except FileNotFoundError:
if cmd == cmd.lower():
cmd = rosie.find(orig)
cmd = cmd.lower()
print("! %s NOT FOUND" % orig)
elif c:
e += 1
for t in THRESH:
if e == t:
return e
class Rosie:
__version__ = 1.1
interpreters = {}
msg_hello = "\nHi! I'm Rosie, the APLBAONWSJAS intelligent assistant.\n\n"
msgs_hello = [msg_hello, "\nHi Again! Rosie here; ", msg_hello]
msg_looks = "It looks like you are "
msgs_error = [
"""typing randomly into an extremely limited command-line interface which only accepts one command:
You should try using that.""",
"""having trouble using the one available EXECUTE() command.
You should type
where 'n' is the name of the programming language interpreter that you want to EXECUTE.
Then hit <enter> on your keyboard. APLBAONWSJAS will then run the EXECUTE command and display an interpreter for that programming language.""",
"""having trouble comprehending or following simple instructions.
Unfortunately I am unable to help you with that."""
msg_sig = "\n\n%s\U0001f495\n%sxxx Rosıe" % (' '*37, ' '*30)
msgs_sig = [msg_sig, msg_sig, "\n\n" + ' '*34 + "Rosie \U0001F940"]
def advise(self, n):
advice = [self.msgs_hello[n], self.msg_looks, self.msgs_error[n], self.msgs_sig[n]]
return ''.join(advice)
def find(self, interpreter):
if interpreter in self.interpreters:
#TODO: what if the path is bad and Rosie keeps returning it?
#TODO: Rosie should write known interpreters to .config
return self.interpreters[interpreter]
msg_execute = "trying to EXECUTE '{0}'\nUnfortunately I can't find {0} on your computer at this time."
find_help = [self.msg_hello, self.msg_looks, msg_execute]
msg_help ="\n\nPlease help me to help you by typing the full path to the {} executable: ".format(interpreter)
path = input(msg_help)
msg_thanks = "\nThank you! I'll remember that for next time.\n Have a lovely day!"
print(''.join([msg_thanks, self.msg_sig]))
self.interpreters[interpreter] = path
return path
if __name__ == '__main__':
rosie, e = init(), 0
while 1:
e = main(e, rosie)

This comment has been minimized.

Copy link

@Warhawk947 Warhawk947 commented Jun 25, 2020

o k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment