Languages & Interpreters
States and automata to regular expressions, parsers, and a tiny language run first by walking its tree, then as bytecode.
Software Engineering
Before you start
Some lessons here build on lessons from other arcs: Modular Arithmetic: The Clock and Fast Powers.
- 1
Finite State Machinesin review
Software · State Machines & Parsing · ~20 minA machine whose only memory is which state it is in: one table lookup per symbol, accept if it ends on a double ring, then merge the states no word can tell apart.
- 2
Regex Under the Hood: NFAsin review
Software · State Machines & Parsing · ~25 minA regular expression compiles to a machine with one state per letter that runs in many states at once; turning each set of states into one state gives a DFA.
- 3
Parsing: Recursive Descentin review
Software · State Machines & Parsing · ~25 minA grammar becomes a program: one method per rule, one token of lookahead per decision, and a tree comes out whose shape is the precedence of the operators.
- 4
Build a Tiny Interpreterin review
Software · Compilers & Interpreters · ~20 minRun a program by walking its syntax tree: visit a node, evaluate its children, act on their values. The tree is the program, and a loop is the walk coming back to the same node.
- 5
A Bytecode VMin review
Software · Compilers & Interpreters · ~25 minCompile the tree once into postfix instructions and run them with a stack: fetch, advance, execute. A loop is a jump backwards, and nothing is matched on its kind again.