3 ms·
Write a parser for a complicated file format. Write a simple interpreter for a C-like language by parsing it into a syntax tree, constructing a stack of symbol
by tptacek 8y ago
Write a parser for a complicated file format.
Write a simple interpreter for a C-like language by parsing it into a syntax tree, constructing a stack of symbol tables, and evaluating the nodes.
Once that works, write a version that emits code for a stack-based virtual machine (a simple stack machine written concisely might eat just a few screenfuls of code).
When that works, symbolically evaluate the stack bytecode into variable references, pick a simple architecture (I like MSP430 for this but ARM will do) do a trivial register allocator, implement register spill to the stack, and emit real code.
Then read Lisp In Small Pieces.
Worked OK for me!
A surprising amount of the complexity you might perceive in a "real" programming language just comes down to how expressions are parsed.