Skip to content
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

Line continuations can be terminated with EOF only when a comment is present #337

Closed
eilvelia opened this issue Nov 3, 2023 · 4 comments · Fixed by #356
Closed

Line continuations can be terminated with EOF only when a comment is present #337

eilvelia opened this issue Nov 3, 2023 · 4 comments · Fixed by #356
Labels
breaking This can only be done for the next major version of KDL bug Something isn't working

Comments

@eilvelia
Copy link
Contributor

eilvelia commented Nov 3, 2023

I thought this was already reported, but I can't seem to find any issue/discussion, so I'm opening a new one.

Right now, the line continuation is defined as

escline := '\\' ws* (single-line-comment | newline)

Where single-line-comment is (includes eof):

single-line-comment := '//' ^newline* (newline | eof)

This means that node \ // comment <EOF> is allowed as the last line, but node \ <EOF> is not, which feels weird. I think escline should probably include eof as well.

@Patitotective
Copy link
Contributor

As far as I understand the line continuations breaks a node, let's say:

node 1 2 \
     3 4

So you can't really put nothing (or end the file) after \, that's why it expects a new line.
Just like the KDL below is invalid, ending a file after a line continuation is invalid.

node 1 2 \
node

Instead a single line comment CAN end a file since it's not really part of a node, and it's not breaking a node.

Or at least that's why I understood from the specification 😅.

@zkat zkat added bug Something isn't working breaking This can only be done for the next major version of KDL labels Nov 28, 2023
@zkat
Copy link
Member

zkat commented Nov 28, 2023

probably what we want is something like (single-line-comment eof? | newline)

@eilvelia
Copy link
Contributor Author

So you can't really put nothing (or end the file) after , that's why it expects a new line.

It feels like it would be better UX if the file is valid regardless of the final newline (and regardless of whether the editor is configured the insert the final \n or not). FWIW, zsh (but not bash) seems to allow \ before EOF:

$ zsh -c "echo 1 \\"
1 

zkat added a commit that referenced this issue Dec 11, 2023
@zkat zkat linked a pull request Dec 11, 2023 that will close this issue
zkat added a commit that referenced this issue Dec 13, 2023
zkat added a commit that referenced this issue Dec 13, 2023
zkat added a commit that referenced this issue Dec 13, 2023
#352)

* fix some confusion in grammar syntax, and actually specify the syntax itself

Fixes: #345

* allow ,<> as identifier characters since they no longer need to be reserved

* fix typo

* disallow more code points and outright ban certain ones from KDL documents altogether (#353)

Fixes: #250

* `r` prefix is no longer required for raw strings (#354)

Fixes: #337
@zkat
Copy link
Member

zkat commented Dec 13, 2023

This has been merged into the kdl-v2 branch

@zkat zkat closed this as completed Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This can only be done for the next major version of KDL bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants