~/talk

Writing a Lexer with Macros

TalkinRussianat RustCon 2023 · on Friday, 2023-12-01· [rust, compilers-and-language-design]
links:none on file
slides:none on file

Describes implementing a lexer using Rust declarative macros: the talk examines whether Rust’s macro system (which is Turing-complete) can express a complex translator by building a lex-like language entirely with macros. It covers practical challenges, unavoidable compromises, and whether a workable solution can be achieved.

AI-written summary · about

  1. 0:00Introduction
  2. 0:45Why write lexer manually
  3. 3:14Regex overview
  4. 5:04Regex type in Rust
  5. 6:07Testing regex
  6. 7:11Concatenation overloading
  7. 7:56Problems with manual lexer
  8. 8:38Goal: lexer with Rust macros
  9. 10:44Demo: token processing
  10. 12:12Lexer structure
  11. 13:16Inspiration from RPN
  12. 15:11Two-stack parsing
  13. 16:40Macros syntax
  14. 19:08Base macro for tokens
  15. 20:35Postfix unary ops
  16. 23:50Sequences and repetition
  17. 26:23Literals and predicates
  18. 27:52Alternation operator
  19. 28:36Parentheses handling
  20. 30:02Simpler parentheses
  21. 31:26Lexer rules
  22. 32:48Macro for rules
  23. 33:30Processing lexer defs
  24. 34:40String literals
  25. 35:44NFA
  26. 36:30Q&A: macro optimization
  27. 37:11Q&A: grammar redundancy
  28. 38:15Q&A: procedural vs declarative
  29. 40:05Q&A: macro recursion
  30. 41:08Q&A: hybrid parsing
  31. 42:11Closing remarks
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.