table of contents
THE DATA STRUCTURES ASSIGNMENT
We can add vars to this. It wouldn’t be a big change
Actually implementing it in C
Arena Allocator
Making the Env Table
UPGRADING THE MEMORY ALLOCATOR
BUILDING THE GARBAGE COLLECTOR
What to expect in the next parts
What have we achieved so far?
WAIT. BUT DOES IT EVALUATE 1+1
I was given a data structures problem of converting an arithmetic expression into a binary tree. Naturally, I decided to build an evaluator.
A few days later I implemented closures, a garbage collector, a custom memory allocator, a REPL, an FFI, and a whole bunch of other stuff in C.
graphLang
THE DATA STRUCTURES ASSIGNMENT
The problem was: Evaluate 1 + 1 + 1 to 3 using a binary tree.
How do we get there?
Well, we first form our tree for 1+1+1
(+) / \ (+) (1) / \ (1) (1)
The operator becomes the root, with its two operands as children.
Now let’s evaluate this tree.
First, we evaluate the root’s left operand.…