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

identifier-char grammar is invalid #345

Closed
tabatkins opened this issue Nov 30, 2023 · 8 comments · Fixed by #351
Closed

identifier-char grammar is invalid #345

tabatkins opened this issue Nov 30, 2023 · 8 comments · Fixed by #351
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@tabatkins
Copy link
Contributor

Currently the identifier-char grammar is:

identifier-char := unicode - linespace - [\/(){}<>;[]=,"]

The bit at the end is using a [...] character class, but it tries to include [] characters as well. These presumably need to be escaped somehow.

(It's also not clear to me, on inspection, whether the first \ is actually meant to be a \ char, or if it's escaping the following / char. This grammar isn't using an official grammar language, so it's not quite clear what the conventions are.)

@zkat zkat added bug Something isn't working documentation Improvements or additions to documentation labels Nov 30, 2023
@zkat
Copy link
Member

zkat commented Dec 10, 2023

You know what, I don't know why we ban \ at all. Let's just allow it and make Windows users happy.

@zkat
Copy link
Member

zkat commented Dec 10, 2023

and yeah, we should allow / too.

@zkat
Copy link
Member

zkat commented Dec 10, 2023

oh right. That's why we don't allow /. Comments.

I guess this means we need to add some special cases so /*, /- and // are not valid identifiers.

@larsgw
Copy link
Contributor

larsgw commented Dec 10, 2023

Those should be invalid identifier prefixes in that case, /*a should still start a comment.

@zkat
Copy link
Member

zkat commented Dec 10, 2023

oh right, and \ is disallowed because of line continuations.

...I'm thinking that maybe we should just keep banning \ and / and just make it clearer to resolve this Issue, so it doesn't seem like we're using \ to escape / in the grammar.

and yeah, we should clarify []

@larsgw
Copy link
Contributor

larsgw commented Dec 10, 2023

Right, I'm realizing now it's not even just prefixes, it's those sequences anywhere in the identifier.

@zkat
Copy link
Member

zkat commented Dec 10, 2023

It's too bad. I was really into the idea of supporting #path/to/foo and #C:\foo\bar but I just don't see a good way to do so without a lot of "will this parse as an identifier?" overhead. Unless I'm thinking about it too much

@zkat zkat self-assigned this Dec 11, 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

The fixes for this have 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
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants