Skip to content

Commit 972dc1f

Browse files
eemelistasm
andcommitted
Apply suggestions from code review
Co-authored-by: Stanisław Małolepszy <sta@malolepszy.org>
1 parent 8e7d743 commit 972dc1f

File tree

1 file changed

+6
-125
lines changed

1 file changed

+6
-125
lines changed

spec/syntax.md

Lines changed: 6 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
1. [Selection](#selection)
1414
1. [Local Variables](#local-variables)
1515
1. [Complex Messages](#complex-messages)
16-
1. [Comparison with ICU MessageFormat 1.0](#comparison-with-icu-messageformat-10)
1716
1. [Productions](#productions)
1817
1. [Message](#message)
1918
1. [Plain](#plain)
@@ -44,10 +43,10 @@ the successor to ICU MessageFormat, henceforth called ICU MessageFormat 1.0.
4443

4544
The design goals of the syntax specification are as follows:
4645

47-
1. The syntax should be an incremental update over the ICU MessageFormat 1.0 syntax
48-
in order to leverage the familiarity and the single-message model
49-
that is ubiquitous in the localization tooling today,
50-
and increase the chance of adoption.
46+
1. The syntax should leverage the familiarity with ICU MessageFormat 1.0
47+
in order to lower the barrier to entry and increase the chance of adoption.
48+
At the same time,
49+
the syntax should fix the [pain points of ICU MessageFormat 1.0](../docs/why_mf_next.md).
5150

5251
- _Non-Goal_: Be backwards-compatible with the ICU MessageFormat 1.0 syntax.
5352

@@ -221,62 +220,6 @@ A complex message with 2 selectors and 3 local variable definitions:
221220
_ 2 [{$hostName} invites {$guestName} and one other person to their party.]
222221
_ _ [{$hostName} invites {$guestName} and {$guestsOther} other people to their party.]
223222

224-
## Comparison with ICU MessageFormat 1.0
225-
226-
MessageFormat 2.0 improves upon the ICU MessageFormat 1.0 syntax through the following changes:
227-
228-
1. In MessageFormat 2.0,
229-
variants can only be defined at the top level of the message,
230-
thus precluding any possible nestedness of expressions.
231-
232-
ICU MessageFormat 1.0:
233-
234-
```
235-
{foo, func,
236-
foo1 {Value 1},
237-
foo2 {
238-
{bar, func,
239-
bar1 {Value 2a}
240-
bar2 {Value 2b}}}}
241-
```
242-
243-
MessageFormat 2.0:
244-
245-
```
246-
{$foo: func} {$bar: func}
247-
foo1 [Value 1]
248-
foo2 bar1 [Value 2a]
249-
foo2 bar2 [Value 2b]
250-
```
251-
252-
1. MessageFormat 2.0 differentiates between
253-
the syntax used to introduce expressions (`{...}`) and
254-
the syntax used to defined translatable content (`[...]`).
255-
256-
1. MessageFormat 2.0 uses the dollar sign (`$`) as the sigil for variable references,
257-
the colon (`:`) as the function call syntax,
258-
and only allows named options to functions.
259-
The purpose of this change is to help disambiguate between
260-
the different parts of a placeholder (variable references, function names, literals etc.).
261-
262-
ICU MessageFormat 1.0:
263-
264-
```
265-
{when, date, short}
266-
```
267-
268-
MessageFormat 2.0:
269-
270-
```
271-
{$when: date style=short}
272-
```
273-
274-
1. MessageFormat 2.0 doesn't provide the `#` shorthand inside variants.
275-
Instead it allows local variables to be defined in the preamble,
276-
which can then be referred to inside patterns similar to other variables.
277-
278-
1. MessageFormat 2.0 doesn't require commas (`,`) inside placeholders.
279-
280223
## Productions
281224

282225
The specification defines the following grammar productions.
@@ -531,68 +474,6 @@ WhiteSpace ::= #x9 | #xD | #xA | #x20 /* ws: definition */
531474

532475
## Complete EBNF
533476

534-
The following EBNF uses the [W3C flavor](https://www.w3.org/TR/xml/#sec-notation) of the BNF notation.
477+
The complete EBNF is available as [`message.ebnf`](./message.ebnf).
478+
It uses the [W3C flavor](https://www.w3.org/TR/xml/#sec-notation) of the BNF notation.
535479
The grammar is an LL(1) grammar without backtracking.
536-
537-
```ebnf
538-
Message ::= Plain | Pattern | Preamble Variant+
539-
540-
/* Preamble */
541-
Preamble ::= Selector+
542-
Selector ::= (Variable '=')? '{' Expression '}'
543-
544-
/* Variants and Patterns */
545-
Variant ::= VariantKey* Pattern
546-
VariantKey ::= String | Nmtoken
547-
Pattern ::= '[' (Text | Placeable)* ']' /* ws: explicit */
548-
549-
/* Placeables */
550-
Placeable ::= '{' (Expression | MarkupStart | MarkupEnd)? '}'
551-
552-
/* Expressions */
553-
Expression ::= Operand Annotation? | Annotation
554-
Operand ::= String | Variable
555-
Annotation ::= ':' Name Option*
556-
Option ::= Name '=' (String | Nmtoken | Variable)
557-
558-
/* Markup Tags */
559-
MarkupStart ::= Name Option*
560-
MarkupEnd ::= '/' Name
561-
562-
<?TOKENS?>
563-
564-
/* Plain */
565-
Plain ::= PlainStart (PlainChar* PlainEnd)? /* ws: explicit */
566-
PlainChar ::= AnyChar - ('{' | '}')
567-
PlainStart ::= PlainChar - ('[' | '$' | WhiteSpace)
568-
PlainEnd ::= PlainChar - WhiteSpace
569-
570-
/* Text */
571-
Text ::= (TextChar | TextEscape)+
572-
TextChar ::= AnyChar - ('[' | ']' | '{' | '}' | Esc)
573-
AnyChar ::= .
574-
575-
/* Names */
576-
Variable ::= '$' Name /* ws: explicit */
577-
Name ::= NameStart NameChar* /* ws: explicit */
578-
Nmtoken ::= NameChar+ /* ws: explicit */
579-
NameStart ::= [a-zA-Z] | "_"
580-
| [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF]
581-
| [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D]
582-
| [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF]
583-
| [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
584-
NameChar ::= NameStart | [0-9] | "-" | "." | #xB7
585-
| [#x0300-#x036F] | [#x203F-#x2040]
586-
587-
/* Quoted strings */
588-
String ::= '"' (StringChar | StringEscape)* '"' /* ws: explicit */
589-
StringChar ::= AnyChar - ('"'| Esc)
590-
591-
/* Escape sequences */
592-
Esc ::= '\'
593-
TextEscape ::= Esc Esc | Esc '[' | Esc ']' | Esc '{' | Esc '}'
594-
StringEscape ::= Esc Esc | Esc '"'
595-
596-
/* WhiteSpace */
597-
WhiteSpace ::= #x9 | #xD | #xA | #x20 /* ws: definition */
598-
```

0 commit comments

Comments
 (0)