-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement multi-line string #1097
Conversation
Note that the known issue is addressed in #1029 by forcing multi line string delimiters to being different lines and forcing the opening delimiter to have a line break after it. Edit: now that I've looked at the PR quickly it seems the problem is that single line raw strings and multi line raw string overlapping in their functionality might be the real culprit, in other words, single line raw strings should not span multiple lines. Is that it? |
@andrevidela My example above might be inaccurate. Let's think this one instead:
Is this a raw string or a raw multiline string? |
Exactly. But, if dis-allowing raw strings to span multiline to de-ambiguous, the semantic of the beginning quote will depend on whether the last quote is in the other line. |
Ah, I understand, I guess we could afford this kind of lookahead because we only need to read until the end of the line, but that would make the lexing even more complex than it already is. I Suggest we leave this be for now and make a note of the progress on #1029, I'll add this summary: When we see |
What about this: only lex the multiline begin quote if |
Ah yes that's actually much simpler |
I imagine some of the "multiline" strings made up of single line strings (even in this PR) can't be moved to the new syntax in the same version as the syntax is introduced, huh? I noticed there's no entry in the changelog in this PR, and this change is certainly worth calling out! |
Replying @mattpolzin
yeah, we have to wait until the next minor release.
Because the raw string, multiline string and interpolated string are highly related, I'd like to write the changelog together in an independent pr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, error messages could be improved but we can open issues for those. Ideally I would like to also have a nicer error message when starting a multine string with non-whitespace characters """hello
instead of "bracket not properly closed" but I think it's out of scope for this PR. Good job!
Signed-off-by: Andy Lok <[email protected]>
Implements #1029. For example, the idris2 banner can be rewritten with multi-line string:
Before
After
Known issue (Update: Solved)
In this PR, multiline string is not compatible with the '#' escape introduced by raw string. This is because the syntax chosen for multiline will be ambiguous if '#' is allowed. For example,
#""""""#
can be interpreted as a raw string equals to"\"\"\"\""
and also can be interpreted as an multiline string (although it is invalid in this example because it's single-line).