Back to Browse

Creating a Lexer in C - Part 3: Testing & Validation

124 views
Jan 26, 2026
25:01

In Part 3 (the final episode) of this series, we complete our lexer written in C by adding proper testing using assert(). Instead of guessing whether the lexer works, we validate it by asserting that each generated token matches what we expect. This ensures correctness, catches subtle bugs, and gives us confidence that the lexer is ready to be used by a parser. In this video, you’ll learn: How to use assert() for lightweight testing in C How to test nextToken() reliably How to verify token types and values How to structure tests for compiler-style code How to finish a lexer cleanly and safely 📌 This completes the series: Part 1 – Lexer foundations & input handling Part 2 – nextToken() and createToken() Part 3 – Testing with assert() By the end of this video, you’ll have a fully working and tested lexer, and a solid foundation for moving on to parsing, ASTs, and language design. If you enjoyed this series, consider subscribing - future videos will continue deeper into systems programming and language tooling in C! #programminglanguage #lexer #cprogramming #coding #unix #unittesting #project Chapters: Introduction - 0:00 Resolving Previous Issues - 1:16 Beginning our Tests - 5:00 Input/Expected - 7:20 Running our Tests - 20:00

Download

0 formats

No download links available.

Creating a Lexer in C - Part 3: Testing & Validation | NatokHD