Strategies for very fast Lexers

A tutorial on techniques used to make the lexer of one hobby language fast.

Author
xnacly
Published
Jul 14, 2025
Kind
Personal blog post, a long tutorial in C with benchmarks
Original
xnacly.me/posts/2025/fast-lexer-strategies/
Subject
Compilers and interpreters
Themes
Close to the machine

What it is

xnacly is the author of purple-garden, an s-expression language built for personal use. The post explains the lexing stage and the optimizations applied to it. It warns that not every approach suits every use case.

What it says

What evidence it gives

The post shows C code for each step. It quotes commit messages with timings, and some use hyperfine. It reports totals on a laptop and a tower. It compares with figures from another article.

Interests and limits

The author benchmarks own language on own synthetic input. The input repeats a fixed 15-line sample to reach about a million lines. Timings come from two machines and individual commits. The comparison table uses numbers from another article, so the setups may differ. The post says SIMD could go further but did not test it.

Connections

These links are this wiki's own reading, not claims the sources make.