You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would probably want to implement something like Python does, where if the lexer sees a newline inside of ()[] or {} pairs it suppresses the newline token that it would otherwise emit. (Python also accepts \ to continue lines, but it's generally discouraged.)
The tricky things I can think of are:
I would want to implement some kind of forced indentation requirement, so you would still need to indent the wrapped line. I'm not sure what the exact rule should be: I'm thinking something like:
If the most recent ([{ character was at the end of the previous line, that creates a new indentation context and everything inside needs to be consistently indented at least 1 space compared to the previous indentation, like:
If the most recent ([{ character had more characters after, then everything else must be indented as far as the other characters inside, like:
if (packet_type == PacketType.FOO ||
packet_type == PacketType.BAR ||
...):
It may be difficult to have good error messages in cases where someone forgets a closing )]} character.
The current Emboss grammar actually includes comment tokens (for use in the autoformatter). This isn't too disruptive in the current grammar because comments can only occur at EOL, and there are only a few places where EOLs can occur. This change would allow comments pretty much anywhere, which would make the grammar significantly larger (or we would have to use a different strategy to handle comments).
Speaking of the autoformatter, it would need to start making real decisions about where/how to break lines, and some of those decisions are not at all trivial (see Clang-Format).
Suppose I have the following emboss definitions, along with a very long boolean expression:
For readability's sake, I'd like to be able to break up the boolean expression into multiple lines, like this:
Doing so results in the following error:
Placing the
||
as a line prefix doesn't work either:Doing so results in the following error:
Using a backslash to indicate a continuation of the line on the next also doesn't work:
Doing so results in the following error:
Using a backslash to indicate a continuation of the line along with using the
||
as a line prefix also doesn't work:Doing so results in the following error:
It seems like there is no way to have multi-line boolean expressions at the moment.
The text was updated successfully, but these errors were encountered: