This is the website you're currently looking at! It's the landing page where you can find info about me, my work experience, and some of the other projects I've worked on.
HTML CSSAn interpreter written in Rust for evaluating programs written in the Lua programming language.
Rust LuaMoonRust is an interpreter for a subset of the Lua programming language, written using Rust. An interpreter is a program that directly executes another program without translating it into a machine language. A web demo is coming soon, but for now you can check it out on my Github page!
This was a collaboration between me and classmates James Oh and Renee Veit (I encourage you to check them out too!) as part of a course on the Rust programming language. I had a growing interest in building a compiler, and my teammates were up to the challenge. However, compilers being massive undertakings even in the simplest of cases, and the fact that we only had half a semester to complete this, we scaled it down to something more manageable.
Interpreters are nice because there are only two major steps: parsing the code into a useful data structure and traversing the data structure to evaluate the program's result. Lua is also a very simple language with a relatively small amount of features, making it a good choice for our project. For time sake however, we decided to leave some more advanced features out, like error handling, coroutines, and chunks.
This demo shows off the evaluation of a few different Lua programs, which are run from the console. Each time MoonRust executes, it outputs the internal parse tree and evaluates the Lua program from that tree. We included some special built-in functions to get input from the user and print text to the console so that the final results are visible.
The first main challenge was parsing. Our problems stem from two factors. First, we used Nom, a parser combinator library, for our parsing needs. Nom is a great library, but it suffers from the same problems all recursive descent parsers have: it can't handle ambiguity. The Lua syntax specification is full of ambiguous rules, and if you follow them directly using Nom, as we did, the parser will run into an infinite loop. Thus, we had to restructure the grammar to eliminate things like left recursion and clarify which binary operators had precedence over others.
Another challenge was implementing the runtime environment for variables in
Lua. Rust has strict ownership rules where values can only be tied to one
owning variable. This is not the case with Lua, where multiple variables can
reference the same value. In order to accomodate this, we made use of Rust's
Rc
and RefCell
. The Rc
struct counts
the number of references to a given value, allowing them to have more than
one owner at a time. RefCell
allows for borrowing rules to be
dynamically checked at runtime, meaning we can mutably borrow a value while
other immutable references exist. By combining both structs, we can simulate
Lua's rules for values and variables: multiple variables can point to the
same value, and changes made to the value are reflected in every variable
that references them. Pretty neat!
You can find out more about some of our other challenges, including the lessons we learned, in the project's README.
This is my personal website where you can find out more about my work experience and my other personal projects. Right now, it's written entirely with HTML and CSS with Bootstrap.
In its current state, my website makes no use of any dynamic content. Could I have made this a fancy single-page application with event hooks and state management? Absolutely! I might even rebuild this site in React or Angular at some point in the future when I want those things. Right now though, I find that to be overkill for what should be something very simple and lightweight.
Sticking with my previous point, I wanted to keep things simple. I currently don't need to keep track of analytics or add user-generated content to my website. Plus, I wanted full control over how my website was styled and laid out. Many of the themes for Hugo or Jekyll didn't really appeal to me and what I wanted. It's also more fun to do it yourself anyways!