Stream: compiler development

Topic: ✔ Balancing check in tokenizer vs parser


view this post on Zulip Henrik Larsson (Mar 28 2025 at 15:52):

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?

view this post on Zulip Anton (Mar 28 2025 at 15:55):

@Joshua Warner @Anthony Bullard

view this post on Zulip Joshua Warner (Mar 28 2025 at 15:59):

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.

view this post on Zulip Notification Bot (Mar 28 2025 at 16:00):

Henrik Larsson has marked this topic as resolved.


Last updated: Jul 06 2025 at 12:14 UTC