Lightning Talk: Improving an HTML Parser with Swift 6 Pattern Matching
summary
A C++ HTML tokenizer for Ladybird LibWeb is rewired into Swift 6 pattern matching and choice types, replacing a macro-heavy giant switch with small functions that return enum results to drive the top-level state machine. The HTML spec requires roughly 80 parser states, and the reimplementation targets the tokenizer portion, emitting tokens, switching states, or EOF via pattern matches. The result compiles and runs, yielding a far clearer, testable state machine and removing goto/macros while matching the spec.
AI-written summary · about
related talks
31mBuilding a Programming Language in Swift
22mImproving Swift Tools with libSyntax
27mAST Meta-programming
38mCompilers aren’t magic, so let’s build one in Swift
31mMaking the Most Out of Swift
01h 05mHTML: The Good Parts
21mOptimizing Swift code for separation of concerns and simplicity
53mSwift: New Paradigms for iOS Development
