-
Notifications
You must be signed in to change notification settings - Fork 0
Introduction
soup is based on a language developed by my university Compiler Construction professor, which I will not name in order to avoid plagiarism from future students of the class. The original language was itself created as a simplified version of Java with the intention of easing students in to compiler design by only featuring the most necessary, bare-bones aspects of a programming language. For example, it doesn't have for loops, because you can make a for loop out of a while loop.
To prove that soup isn't just the original language with a more delicious name, and that I haven't just copied and pasted my final project for my Compiler Construction class, here are a few key differences (so far) between the soup compiler and my original compiler from that class:
-
I wrote my original compiler in C, and I was allowed to ignore dynamic memory deallocation. Obviously, since the entire point of Rust is to ensure memory safety, this wasn't an option for the soup compiler. One of the major learning experiences that I'm getting from developing this compiler is learning how to design a compiler 'properly', without lazily allocating memory on the heap and then moving on without cleaning up after myself.
-
Although I was given the option not to, I chose to use scanner and parser generator tools in my original compiler. This made the development of those components somewhat easier, but another learning experience I wanted to gain from this compiler was how an ad-hoc scanner and recursive descent parser actually work, hands-on.
-
Somewhat embarrassingly, I didn't actually end the class with a fully functioning compiler. I struggled with the storage of register data before function calls in certain edge cases, and simply didn't bother supporting a case in which a user makes a function with more parameters than there are parameter passing registers in MIPS assembly. I have rectified that embarrassment and can proudly declare that neither of these issues exist in the soup compiler.
-
We were instructed to compile the original language to MIPS assembly so that the output could be executed on the MIPS emulator on our university's Linux servers, but I will be compiling soup to Apple M1 ARMv8 assembly (and possibly adding x86 support someday) for running on my personal M1 Macbook.
-
I have added some of my own personal syntactic flair to soup, for example, the
func function_name() returns void {}
function declaration style, not requiring boolean expressions in if statements/while loops to be wrapped in parentheses, and requiring the main function to be calledmain()
.