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

Syntax for empty string value #73

Closed
Pike opened this issue Dec 4, 2017 · 4 comments
Closed

Syntax for empty string value #73

Pike opened this issue Dec 4, 2017 · 4 comments
Milestone

Comments

@Pike
Copy link
Contributor

Pike commented Dec 4, 2017

Right now, there's no syntax for an empty string value, AFAICT.

One way to think about that would be to just use

my-text =

The other way is to try to create a non-"" AST value that evaluates to "". One candidate would be

my-text = {""}

But that's also not allowed, 'cause quote-text is '"' (text-char - '"' | '\"')+ '"', note the + instead of a *.

I didn't investigate what the fall-out of allowing * would be.

@stasm
Copy link
Contributor

stasm commented Dec 5, 2017

As I'd like to use the first form for all messages (#63), my preference (and an ongoing intent) has been to go for the second form. It has the benefit of being explicit and clearly visually distinctive, which I find helpful in this case. A zero-length value is an edge-case and I'd like to mark it visually as such.

@stasm
Copy link
Contributor

stasm commented Jan 30, 2018

#83 clarified the requirements for quoted-text making {""} legal. Regarding the null value, here's the summary of the rules as defined by Syntax 0.5.

# ERROR: messages must have values or attributes.
message =

# ERROR: terms must have values.
-term =
# OK: messages can have no values.
message =
    .attr = An attribute

# ERROR: terms must always have values.
-term =
    .attr = An attribute
# OK: both values here are empty strings (length == 0).
message = {""}
-term = {""}
# OK: variant values can also be empty strings.
message =
    { $num ->
        [zero] {""}
        [one] One something.
       *[other] Many somethings.
    }

@stasm
Copy link
Contributor

stasm commented Jan 31, 2018

I talked to @Pike and @zbraniecki about this and they agreed to use {""} to denote empty strings. Closing.

@stasm stasm closed this as completed Jan 31, 2018
@langpavel
Copy link

langpavel commented Nov 30, 2018

{""} is terrible for translators — they are not programmers. I must study grammar what is possible/how should I write it down.
I'm proposing #223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants