Skip to content

Commit 4eed446

Browse files
eemeliaphillipsmarkusicu
authored andcommitted
Use (parentheses) rather than "quotes" around literal values (#276)
Co-authored-by: Addison Phillips <[email protected]> Co-authored-by: Markus Scherer <[email protected]>
1 parent dea6db9 commit 4eed446

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

spec/message.ebnf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ Selector ::= (Variable '=')? '{' Expression '}'
66

77
/* Variants and Patterns */
88
Variant ::= VariantKey* Pattern
9-
VariantKey ::= String | Nmtoken | '*'
9+
VariantKey ::= Literal | Nmtoken | '*'
1010
Pattern ::= '[' (Text | Placeholder)* ']' /* ws: explicit */
1111

1212
/* Placeholders */
1313
Placeholder ::= '{' (Expression | MarkupStart | MarkupEnd)? '}'
1414

1515
/* Expressions */
1616
Expression ::= Operand Annotation? | Annotation
17-
Operand ::= String | Variable
17+
Operand ::= Literal | Variable
1818
Annotation ::= Function Option*
19-
Option ::= Name '=' (String | Nmtoken | Variable)
19+
Option ::= Name '=' (Literal | Nmtoken | Variable)
2020

2121
/* Markup Tags */
2222
MarkupStart ::= Name Option*
@@ -48,14 +48,14 @@ NameStart ::= [a-zA-Z] | "_"
4848
NameChar ::= NameStart | [0-9] | "-" | "." | #xB7
4949
| [#x0300-#x036F] | [#x203F-#x2040]
5050

51-
/* Quoted strings */
52-
String ::= '"' (StringChar | StringEscape)* '"' /* ws: explicit */
53-
StringChar ::= AnyChar - ('"'| Esc)
51+
/* Literals */
52+
Literal ::= '(' (LiteralChar | LiteralEscape)* ')' /* ws: explicit */
53+
LiteralChar ::= AnyChar - ('(' | ')' | Esc)
5454

5555
/* Escape sequences */
5656
Esc ::= '\'
5757
TextEscape ::= Esc Esc | Esc '[' | Esc ']' | Esc '{' | Esc '}'
58-
StringEscape ::= Esc Esc | Esc '"'
58+
LiteralEscape ::= Esc Esc | Esc '(' | Esc ')'
5959

6060
/* WhiteSpace */
6161
WhiteSpace ::= #x9 | #xD | #xA | #x20 /* ws: definition */

spec/syntax.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ The key `*` is a "catch-all" key, matching all selector values.
280280

281281
```ebnf
282282
Variant ::= VariantKey* Pattern
283-
VariantKey ::= String | Nmtoken | '*'
283+
VariantKey ::= Literal | Nmtoken | '*'
284284
```
285285

286286
A well-formed message is considered valid if the following requirements are satisfied:
@@ -300,8 +300,8 @@ This serves 3 purposes:
300300
`hello = [Hello]` will unambiguously define the `Hello` message without the space in front of it.
301301
- The message should be conveniently embeddable in various programming languages
302302
without the need to escape characters commonly related to strings, e.g. `"` and `'`.
303-
Such need may still occur when a singe or double quote is
304-
used in the translatable content or to delimit a string literal.
303+
Such need may still occur when a single or double quote is
304+
used in the translatable content.
305305
- The syntax should make it as clear as possible which parts of the message body
306306
are translatable and which ones are part of the formatting logic definition.
307307

@@ -327,7 +327,7 @@ Placeholder ::= '{' (Expression | MarkupStart | MarkupEnd) '}'
327327

328328
Expressions can either start with an operand, or be standalone function calls.
329329

330-
The operand is a quoted string literal or a variable name.
330+
The operand is a literal or a variable name.
331331
The operand can be optionally followed by an _annotation_:
332332
a formatting function and its named options.
333333
Formatting functions do not accept any positional arguments
@@ -337,27 +337,27 @@ Standalone function calls don't have any operands in front of them.
337337

338338
```ebnf
339339
Expression ::= Operand Annotation? | Annotation
340-
Operand ::= String | Variable
340+
Operand ::= Literal | Variable
341341
Annotation ::= Function Option*
342-
Option ::= Name '=' (String | Nmtoken | Variable)
342+
Option ::= Name '=' (Literal | Nmtoken | Variable)
343343
```
344344

345345
Examples:
346346

347347
```
348-
"1.23"
348+
(1.23)
349349
```
350350

351351
```
352-
"1.23" :number maxFractionDigits=1
352+
(1.23) :number maxFractionDigits=1
353353
```
354354

355355
```
356-
"1970-01-01T13:37:00.000Z" :datetime weekday=long
356+
(1970-01-01T13:37:00.000Z) :datetime weekday=long
357357
```
358358

359359
```
360-
"Thu Jan 01 1970 14:37:00 GMT+0100 (CET)" :datetime weekday=long
360+
(Thu Jan 01 1970 14:37:00 GMT+0100 \(CET\)) :datetime weekday=long
361361
```
362362

363363
```
@@ -388,7 +388,7 @@ Examples:
388388
```
389389

390390
```
391-
[{h1 name="above-and-beyond"}Above And Beyond{/h1}]
391+
[{h1 name=(above-and-beyond)}Above And Beyond{/h1}]
392392
```
393393

394394
## Tokens
@@ -440,26 +440,26 @@ NameChar ::= NameStart | [0-9] | "-" | "." | #xB7
440440
| [#x0300-#x036F] | [#x203F-#x2040]
441441
```
442442

443-
### Quoted Strings
443+
### Literal
444444

445-
Any Unicode codepoint is allowed in quoted string literals, with the exception of
446-
`"` (which ends the string literal),
445+
Any Unicode code point is allowed in literals,
446+
with the exception of its delimiters `(` and `)`,
447447
and `\` (which starts an escape sequence).
448448

449449
```ebnf
450-
String ::= '"' (StringChar | StringEscape)* '"' /* ws: explicit */
451-
StringChar ::= AnyChar - ('"'| Esc)
450+
Literal ::= '(' (LiteralChar | LiteralEscape)* ')' /* ws: explicit */
451+
LiteralChar ::= AnyChar - ('(' | ')' | Esc)
452452
```
453453

454454
### Escape Sequences
455455

456456
Escape sequences are introduced by the backslash character (`\`).
457-
They are allowed in translatable text as well as in string literals.
457+
They are allowed in translatable text as well as in literals.
458458

459459
```ebnf
460460
Esc ::= '\'
461461
TextEscape ::= Esc Esc | Esc '[' | Esc ']' | Esc '{' | Esc '}'
462-
StringEscape ::= Esc Esc | Esc '"'
462+
LiteralEscape ::= Esc Esc | Esc '(' | Esc ')'
463463
```
464464

465465
### Whitespace

0 commit comments

Comments
 (0)