2 ms·
Early on in the WebAssembly project, when it was still a pre-order AST encoding, I wrote an LR-style shift-reduce parser for the bytecode. It was fun exercise,
by titzer 9y ago
Early on in the WebAssembly project, when it was still a pre-order AST encoding, I wrote an LR-style shift-reduce parser for the bytecode. It was fun exercise, until it came to debugging. It's fast but relatively hard to maintain, even for a constrained, designed bytecode like WebAssembly. WASM is now a stack machine, so parsing maintains an abstract stack. It's remarkably close to the same algorithm, but a lot easier to think about because of WASM's (now) explicit stack.