# What is this project? This project contains a compiler and runtime environment to calculate simple arithmetic expressions (simple as in only `+-*/`). The compiler is written in Haskell and the the runtimesystem is written in C. # How does it work? The compiler restructures the arithmetic expression into an abstract syntax tree. The nodes of this tree contain the operation and the leafes are the constants of the expression. The syntax tree is then traversed in order to transform the expression into Reverse Polish Notation ([RPN](https://en.wikipedia.org/wiki/Reverse_Polish_notation)) and building the commands to calculate the results on a [stack machine](https://en.wikipedia.org/wiki/Stack_machine). The assembler then translates the commands into a bytestring an saves the result an a file. The runtime system reads the bytestring reconstructing the commands and executes them using an operand stack. This design is heavily influence by the [Java Virtual Machine](https://en.wikipedia.org/wiki/Java_virtual_machine), but providing not nearly as much features. # But why?! Mainly for the fun and learning. I need to learn Haskell for University so I figuered I try to write the compiler and assembler in it. However I also always wanted to write something more than a "Hello world!" in C and figured a stack machine would be the perfect fit, as it isn't too complex but also more than the simple "Hello world!".