Stream: compiler development

Topic: Indent insensitive parsing and disallowing some line breaks


view this post on Zulip Joshua Warner (Feb 13 2025 at 04:37):

There are a couple of interesting places where, with indent insensitive parsing, we need to disallow line breaks at that point in the expression.

For example, you can't put a line break after the function and before the parentheses. and you can't put a line break between the ? operator and it's right operand.

Some motivating examples:

# If we allowed this:
foo
     (1, 2) # user intends these to be args of a funtion

# ... then we'd have trouble with this:
y = 1 + x
(1, 2) # returning a tuple

# If we allowed this:
text = File.readUtf8!(path) ?
                    ErrorReadingConfig # user intend this to be a binary '?'

# ... then we'd have trouble with this:
text = File.readUtf8!(path)? # Unary '?' is intended
MyTag value = give_me_a_tagged_return_value(text)

view this post on Zulip Joshua Warner (Feb 13 2025 at 04:38):

I don't think these cases are particularly controversial, but they are a few interesting exceptions to the general rule that you can usually put in a line break where you need to.

view this post on Zulip Brendan Hansknecht (Feb 15 2025 at 16:42):

@Richard Feldman this is the link

view this post on Zulip Anthony Bullard (Feb 19 2025 at 23:07):

I am of the opinion that there needs to be NoSpaceOpenRound and NoSpaceOpQuestion tokens. Application requires NoSpaceOpenRound and Try suffix requires NoSpaceOpQuestion

view this post on Zulip Joshua Warner (Feb 19 2025 at 23:24):

That makes sense to me


Last updated: Jul 06 2025 at 12:14 UTC