HeadlinesBriefing favicon HeadlinesBriefing.com

AAoM-03: Building an HTML5 Parser with AI-Driven Tests

DEV Community •
×

A developer built a WHATWG HTML5 parser in MoonBit, treating an AI as a high-intensity pair programmer. The key was not writing a tokenizer first, but building the test harness first. This approach turned progress into an automated grind of reducing test failures to zero, using a spec-driven, test-driven methodology.

HTML5's complexity lies in browser-grade error recovery, not syntax. It requires an intricate state machine with no context-free grammar. The project used the official html5lib-tests suite, generating 8,251 conformance tests. The AI handled the bulk of implementation, but stalled on the final seven edge cases.

For the last 1% of difficult problems, the developer switched from Claude to GPT-5.2 (Codex). While slower, GPT-5.2 provided clearer reasoning through the state machine, solving the remaining tests quickly. The project passed all 8,251 tests, demonstrating that for spec-heavy work, AI is best used to converge within a strong testing loop.