Code Interpreter and Compiler
Ever since I got into computer programming as a kid, I’ve been fascinated by it and how I can give the computer instructions and it will just do whatever I ask. So this was a fun educational project I did on my own over the summer of 2021 by following the book Crafting Interpreters by Robert Nystrom. It takes you through building two separate versions of a made up programming language: Lox. The first project (known as jLox since he wrote it in Java) is a treewalk interpreter. I chose to write this in C# instead, which required a few changes of course.
The second half of the book takes you through creating a bytecode compiler (known as cLox since he wrote it in C) for the same fictional programming language. Since I’m familiar with C++ but not C, I wrote it in C++ instead, so it required some little modifications.
By the end of their respective sections, both projects support a fairly simple but powerful programming language (Lox), which includes classes, methods, functions, expressions, inheritance, and a few more things.
Both projects allow you to type in code at the command line since they are both console apps. They both also have the option of running scripts stored in text files with the *.Lox file extension. You do this by running the program and giving it one command line argument: the filename of the script you want to run.
Ever since I got into computer programming as a kid, I’ve been fascinated by it and how I can give the computer instructions and it will do what I ask. If it doesn’t work, it’s usually because I made a mistake somewhere. So naturally I was also curious about how interpreters and compilers work.
| IDE | Visual Studio |
| Language | C++/C# |
| Project Duration | Summer 2021 |
| Repo | GitHub |
| Relevant Skills | Compilers / Byte Code C# C++ Translating C to C++ Translating Java to C# Visitor Pattern Abstract Syntax Trees Parsing |
Screenshots
Click images to enlarge.




Related Posts
No results found.


Leave a comment