Stream: beginners

Topic: formal grammar / newlines in the grammar


view this post on Zulip John Colvin (Sep 24 2023 at 12:57):

is there a formal grammar written out for Roc? If not, can someone give me a quick overview of how newlines function in the grammar? E.g. it seems newlines are an important part of backpassing.

view this post on Zulip Brian Carroll (Sep 24 2023 at 18:13):

Can you provide the specific example that's not working?

view this post on Zulip John Colvin (Sep 24 2023 at 18:23):

I don't have a problem with something not working, I'm more asking from a language design point of view, I'm interested to know what role newlines play in the grammar. I guess i can just keep playing with the language and find out, but I imagine that it's been thought through and wondered if someone could share some insight or explanation. E.g. (these are me working it out otoh so forgive mistakes) for D you can say "newlines play no role in the grammar beyond being whitespace, with the exception of // comments and shebangs. For ANSI C you can say "after pre-processing, newlines play no role in the grammar beyond being whitespace". That sort of thing

view this post on Zulip Richard Feldman (Sep 24 2023 at 23:01):

we don't have a formal grammar...off the top of my head, the places where newlines are currently significant is:

view this post on Zulip Richard Feldman (Sep 24 2023 at 23:04):

I think that's it, but there might be more I'm not thinking of. Also we've talked about introducing a simplifying/unifying concept of "blocks" based on indentation level, which wouldn't affect any current code I've seen written in practice, but which might simplify explaining the rules (among other potential benefits)


Last updated: Jul 06 2025 at 12:14 UTC