My Interpreters

Writing interpreters teaches about grammar, parsing, and down to optimization strategies. Newly inventing interpreters is a programmer's way of expressing creativity.

ButterBrain

Butterbrain is a newly created esoteric language, written in C and based on bf. Expressing yourself in butterbrain makes you think about problems differently. For example, in butterbrain to dereference you use the operator '@', and because butterbrain's 'pointers' are just integers, dereferencing more than once causes you to jump around the memory tape. This is a very "useful" feature that I only noticed after completing the interpreter.
Concise code is great, but this is taking it a little far:


				s3g1s5g2s7g4ig5s0g6s1g7s1[g3s3[g(@vpg3s-1]ng4
				{g5ig6i}g4s!@v{g8s0g9s1[g9s@@8g10s@8s+1s%3
				s@@vg11s@8s+2s%3s@@vg10s^@)1g9s-@10g12s@9s<1g13s@@8
				s<@9s|@12g12s!@13{g15s1g5s@8g6s@9}g8
				s+1g14s@8s<3]g15s!@v{g5s0g6s1[s@@5s!@v
				{g5s+1}g6]g6s1}}g6g@(1s-@6g7s@0s+@1s+@2]g4s!@vp

The above is "obviously" the code for a nim game with an optimal AI opponent



				

Lisp Like Interpreter

LLI is an interpreter written in python that runs scripts of a lisp-like language. Functions and variables which are the same in this functional language are created over a discord message starting with !var. Functions can then be executed over discord using !eval. Because this was my first interpreter, the parsing code was quite sloppy (I'll clean it up one day). I learned from this, though, so I kept the source code for butterbrain neater. That may also be, in part, because designing clean code is much easier for me in C. I don't have access to the source because my desktop is at WPI in quarantine as of 5/5/2020.