-
Notifications
You must be signed in to change notification settings - Fork 0
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
potential ambiguity for empty values and flexspace #3
Comments
How the second example is interpreted seems like a bad idea in the first place TBH. I would suggest that there has to be at least one non-whitespace character on the same line otherwise it should count as an empty value. In other words: A value can contain vertical whitespace, but not at the beginning or end. |
This physically can't work. The reason this happens is that we count \s (whitespace in general) as insignificant (i.e flexspace).
But again, that's not the problem. One way of fixing this would be to specify that whitespace (that may be skipped over) must be horizontal only, and use vertical whitespace for delineation.
are now impossible. It also complicates the parser significantly, since we have to explicitly throw a bunch of \v around. |
Another option would be to disallow
Since whitespace is insignificant, this is identical to:
which looks like a syntax error to me. If you really wanted an equal sign in your value you could still use raw values:
|
that's a way of handling it, but (imo) it's more common to have an = in a value than it is to have explicitly empty values (which is the tradeoff here) on the other hand, values are empty "by default", so a comment effectively replaces it, and you only need one whenever you need to override a previous value (which isn't never, but it's not nearly as common) another way would be to change the kv (not rkv) type to a token (i.e whitespace-significant) and require only horizontal whitespace around the I'm thinking about other potential solutions, still |
Makes me think of how people often write out empty Yacc or bison grammar rules: You can write nothing (the drawback being that people, not computers in this case, might misunderstand you), or you can write a comment We could take that same recommendation to use |
That sounds like a good idea. GotchasDue to the focus of grammar simplicity, a few minor things may be unintuitive. Empty ValuesAn empty kv may not do what you want it to do.
This will actually set the value of "a" to "b = c" verbatim. Here are the recommended ways of dealing with (explicitly empty values).
This makes your intent explicit. Adding a comment:
This works around the parser, and the comment may explain why the value should be empty. Another possibility to consider is simply not setting the value to begin with, i.e
Not setting a value at all means you cannot override previous values, but should (for most intents and purposes) be equivalent. How does that sound? |
Sounds good! I think you are right that equal signs in values definitely outweigh the use cases of explicitly empty values.
|
consider the following text:
so far so good
however, let's remove the "b" (we intend to make a an empty value)
this actually becomes
a => "c=d"
However, if we turn this into:
this becomes
a => "", c => "d"
While we do discourage people from using flexspace in this way, it may be useful to explicitly recommend using raw values for empty strings.
The text was updated successfully, but these errors were encountered: