Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e20060

Browse files
eemeliecheran
authored andcommitted
Use * instead of _ as the catch-all variant key
1 parent 9fbd771 commit 3e20060

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

spec/message.ebnf

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

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

1212
/* Placeables */

spec/syntax.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,30 +154,30 @@ A message with a single selector:
154154

155155
{$count: number}
156156
1 [You have one notification.]
157-
_ [You have {$count} notifications.]
157+
* [You have {$count} notifications.]
158158

159159
A message with a single selector which is an invocation of
160160
a custom function `platform`, formatted on a single line:
161161

162-
{:platform} windows [Settings] _ [Preferences]
162+
{:platform} windows [Settings] * [Preferences]
163163

164164
A message with a single selector and a custom `hasCase` function
165165
which allows the message to query for presence of grammatical cases required for each variant:
166166

167167
{$userName: hasCase}
168168
vocative [Hello, {$userName: person case=vocative}!]
169169
accusative [Please welcome {$userName: person case=accusative}!]
170-
_ [Hello!]
170+
* [Hello!]
171171

172172
A message with 2 selectors:
173173

174174
{$photoCount: number} {$userGender: equals}
175175
1 masculine [{$userName} added a new photo to his album.]
176176
1 feminine [{$userName} added a new photo to her album.]
177-
1 _ [{$userName} added a new photo to their album.]
178-
_ masculine [{$userName} added {$photoCount} photos to his album.]
179-
_ feminine [{$userName} added {$photoCount} photos to her album.]
180-
_ _ [{$userName} added {$photoCount} photos to their album.]
177+
1 * [{$userName} added a new photo to their album.]
178+
* masculine [{$userName} added {$photoCount} photos to his album.]
179+
* feminine [{$userName} added {$photoCount} photos to her album.]
180+
* * [{$userName} added {$photoCount} photos to their album.]
181181

182182
### Local Variables
183183

@@ -192,7 +192,7 @@ A message defining two local variables:
192192
$countInt = {$count: number maximumFractionDigits=0}
193193
$itemAcc = {$item: noun count=$count case=accusative}
194194
one [You bought {$color: adjective article=indefinite accord=$itemAcc} {$itemAcc}.]
195-
_ [You bought {$countInt} {$color: adjective accord=$itemAcc} {$itemAcc}.]
195+
* [You bought {$countInt} {$color: adjective accord=$itemAcc} {$itemAcc}.]
196196

197197
### Complex Messages
198198

@@ -208,17 +208,17 @@ A complex message with 2 selectors and 3 local variable definitions:
208208
female 0 [{$hostName} does not give a party.]
209209
female 1 [{$hostName} invites {$guestName} to her party.]
210210
female 2 [{$hostName} invites {$guestName} and one other person to her party.]
211-
female _ [{$hostName} invites {$guestName} and {$guestsOther} other people to her party.]
211+
female * [{$hostName} invites {$guestName} and {$guestsOther} other people to her party.]
212212

213213
male 0 [{$hostName} does not give a party.]
214214
male 1 [{$hostName} invites {$guestName} to his party.]
215215
male 2 [{$hostName} invites {$guestName} and one other person to his party.]
216-
male _ [{$hostName} invites {$guestName} and {$guestsOther} other people to his party.]
216+
male * [{$hostName} invites {$guestName} and {$guestsOther} other people to his party.]
217217

218-
_ 0 [{$hostName} does not give a party.]
219-
_ 1 [{$hostName} invites {$guestName} to their party.]
220-
_ 2 [{$hostName} invites {$guestName} and one other person to their party.]
221-
_ _ [{$hostName} invites {$guestName} and {$guestsOther} other people to their party.]
218+
* 0 [{$hostName} does not give a party.]
219+
* 1 [{$hostName} invites {$guestName} to their party.]
220+
* 2 [{$hostName} invites {$guestName} and one other person to their party.]
221+
* * [{$hostName} invites {$guestName} and {$guestsOther} other people to their party.]
222222

223223
## Productions
224224

@@ -269,23 +269,24 @@ Examples:
269269
```
270270
$frac = {$count: number minFractionDigits=2}
271271
1 [One apple]
272-
_ [{$frac} apples]
272+
* [{$frac} apples]
273273
```
274274

275275
### Variants
276276

277277
A variant is a keyed pattern.
278278
The keys are used to match against the selectors defined in the preamble.
279+
The key `*` is a "catch-all" key, matching all selector values.
279280

280281
```ebnf
281282
Variant ::= VariantKey* Pattern
282-
VariantKey ::= String | Nmtoken
283+
VariantKey ::= String | Nmtoken | '*'
283284
```
284285

285286
A well-formed message is considered valid if the following requirements are satisfied:
286287

287288
- The number of keys on each variant must be fewer or equal to the number of selectors defined in the preamble.
288-
- At least one variant's keys must all be equal to the catch-all key (`_`).
289+
- At least one variant's keys must all be equal to the catch-all key (`*`).
289290

290291
### Patterns
291292

0 commit comments

Comments
 (0)