I have been looking around in the new Zig code and just wanted to hear the reasoning for why some syntax checks like balancing of " ( [ { are done in the tokenizer? (I ask just to learn and understand). It is my understanding that its common to keep the tokenizer free from syntax checks and have the parser handle that?
@Joshua Warner @Anthony Bullard
Because the tokenizer needs to deal with ${}
-delimited string interpolations, it must track balancing of braces inside those. It doesn't strictly need to track balancing outside of string interpolations, but the code works fine there so :shrug:. I haven't evaluated whether it'd be better to not do brace-balancing outside of string interpolations. I could be convinced.
Henrik Larsson has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC