Expressive Compile-time Parsers in C++
Talkat CppCon 2023 · on Monday, 2023-10-02· at 11:00· Cottonwood 2/3, 6700 North Gaylord Rockies Boulevard·
summary
Survey of compile-time parsing libraries from C++11→23, showing concrete code, benchmarks and working examples: Boost.MetaPars, Lexi, CT(regular expressions), ctpg and a macro-rules emulator, plus a homegrown parser-combinator. Demonstrations include compile-time JSON/AST and a TypeScript-like struct generator, assembly comparison proving zero runtime overhead, regex construction that outperforms std::regex, and compile-time cost measurements (parsing 1,000 structs adds ~100–200 ms, while the custom DSL path costs 14 seconds for 1000 structs).
AI-written summary · about
chapters (20)
- 0:00Introduction
- 1:07Talk structure and goals
- 3:35Parsers and parsing techniques
- 7:28Compile-time parsing importance
- 8:11Boost.Metaparse
- 12:23Lexi: C++17 parsers
- 15:10CTRE: compile-time regex
- 17:42CTPG: LR1 generator
- 20:32Macro Rules: Rust-like DSL
- 24:47Custom parser combinator demo
- 26:14Reflection and parsing integration
- 31:30Nested member access
- 36:37Advanced syntax operators
- 41:17Creating structs
- 43:46When to use compile-time parsing
- 45:11Choosing a parsing library
- 45:52Handling errors
- 47:16Performance benchmarks
- 50:05Future of compile-time parsing
- 51:11Q&A
related talks
01h 03mTemplate Metaprogramming: Practical Application
33mHidden Gems of TypeScript compiler
21mType dependence
06mLightning Talk: C++20 - A New Way of Meta-Programming?
01h 03mTemplate-less Metaprogramming in C++
26mDesign a new language in JS: from zero to autocomplete
01h 03mTemplates Made Easy with C++20
01h 05mYour New Mental Model of constexpr
