Stream: compiler development

Topic: single quote parsing


view this post on Zulip Kiryl Dziamura (Jun 30 2025 at 21:56):

I'm currently poking the single quote parsing. already implemented a very dirty working variant. now want to make it right. I noticed we have StringStart, StringEnd and pairs for braces. But SingleQuote doesn't have start/end pair. I assume tokens seq for a valid single quote (e.g. 'a') are expected to be [SingleQuoteStart, StringPart, SingleQuoteEnd] (StringPart in the middle)? wdyt?

view this post on Zulip Anthony Bullard (Jun 30 2025 at 21:57):

i don't think we should be parsing this

view this post on Zulip Anthony Bullard (Jun 30 2025 at 21:58):

we only parse strings due to interpolation

view this post on Zulip Anthony Bullard (Jun 30 2025 at 21:58):

it should come out of the tokenizer as a single token with the value inside of it interned like the strings for num literals

view this post on Zulip Joshua Warner (Jun 30 2025 at 21:59):

My original thinking with parsing single quotes interpolations was for devs coming from python who though single and double quotes were equivalent, so that we can have better error messages and auto fixes

view this post on Zulip Joshua Warner (Jun 30 2025 at 22:00):

I don’t feel super strongly tho; open to changing that

view this post on Zulip Kiryl Dziamura (Jun 30 2025 at 22:00):

yes, and that's how it's implemented in rust compiler (rocR?)

view this post on Zulip Kiryl Dziamura (Jun 30 2025 at 22:00):

I like this touch. it's also valid for js devs

view this post on Zulip Kiryl Dziamura (Jun 30 2025 at 22:05):

on the other hand we can still generate a similar message when there are >1 unicode chars

view this post on Zulip Joshua Warner (Jun 30 2025 at 22:06):

Yeah there are multiple ways to accomplish that better error messaging, and only some of them involve parsing single quotes similarly to strings

view this post on Zulip Notification Bot (Jun 30 2025 at 22:07):

10 messages were moved here from #compiler development > casual conversation by Luke Boswell.

view this post on Zulip Kiryl Dziamura (Jun 30 2025 at 22:09):

let's keep it simple then

view this post on Zulip Kiryl Dziamura (Jun 30 2025 at 22:20):

@Anthony Bullard could you please take a look my draft pr? https://github.com/roc-lang/roc/pull/7914

I feel that if I start cleaning it up on my own, it would take muuuch longer than if I get some guidance


Last updated: Jul 06 2025 at 12:14 UTC