Skip to content

Commit 40c29d8

Browse files
committed
Prefix function names with the colon.
Change the colon from being an operator which calls functions to a sigil that prefixes function names. Closes unicode-org#242.
1 parent 440e2f2 commit 40c29d8

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

spec/message.ebnf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Placeable ::= '{' (Expression | MarkupStart | MarkupEnd)? '}'
1515
/* Expressions */
1616
Expression ::= Operand Annotation? | Annotation
1717
Operand ::= String | Variable
18-
Annotation ::= ':' Name Option*
18+
Annotation ::= Function Option*
1919
Option ::= Name '=' (String | Nmtoken | Variable)
2020

2121
/* Markup Tags */
@@ -37,6 +37,7 @@ AnyChar ::= .
3737

3838
/* Names */
3939
Variable ::= '$' Name /* ws: explicit */
40+
Function ::= ':' Name /* ws: explicit */
4041
Name ::= NameStart NameChar* /* ws: explicit */
4142
Nmtoken ::= NameChar+ /* ws: explicit */
4243
NameStart ::= [a-zA-Z] | "_"

spec/syntax.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,21 @@ hello.format({ userName: 'Anne' })
125125

126126
### Formatting Functions
127127

128-
A message with an interpolated `$date` variable formatted with the `datetime` function:
128+
A message with an interpolated `$date` variable formatted with the `:datetime` function:
129129

130-
[Today is {$date: datetime weekday=long}.]
130+
[Today is {$date :datetime weekday=long}.]
131131

132132
A message with an interpolated `$userName` variable formatted with
133-
the custom `person` function capable of
133+
the custom `:person` function capable of
134134
declension (using either a fixed dictionary, algorithmic declension, ML, etc.):
135135

136-
[Hello, {$userName: person case=vocative}!]
136+
[Hello, {$userName :person case=vocative}!]
137137

138138
A message with an interpolated `$userObj` variable formatted with
139-
the custom `person` function capable of
139+
the custom `:person` function capable of
140140
plucking the first name from the object representing a person:
141141

142-
[Hello, {$userObj: person firstName=long}!]
142+
[Hello, {$userObj :person firstName=long}!]
143143

144144
### Markup Elements
145145

@@ -152,26 +152,26 @@ which the runtime can use to construct a document tree structure for a UI framew
152152

153153
A message with a single selector:
154154

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

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

162162
{:platform} windows [Settings] * [Preferences]
163163

164-
A message with a single selector and a custom `hasCase` function
164+
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

167-
{$userName: hasCase}
168-
vocative [Hello, {$userName: person case=vocative}!]
169-
accusative [Please welcome {$userName: person case=accusative}!]
167+
{$userName :hasCase}
168+
vocative [Hello, {$userName :person case=vocative}!]
169+
accusative [Please welcome {$userName :person case=accusative}!]
170170
* [Hello!]
171171

172172
A message with 2 selectors:
173173

174-
{$photoCount: number} {$userGender: equals}
174+
{$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.]
177177
1 * [{$userName} added a new photo to their album.]
@@ -183,27 +183,27 @@ A message with 2 selectors:
183183

184184
A message defining a local variable `$whom` which is then used twice inside the pattern:
185185

186-
$whom = {$monster: noun case=accusative}
187-
[You see {$quality: adjective article=indefinite accord=$whom} {$whom}!]
186+
$whom = {$monster :noun case=accusative}
187+
[You see {$quality :adjective article=indefinite accord=$whom} {$whom}!]
188188

189189
A message defining two local variables:
190190
`$itemAcc` and `$countInt`, and using `$countInt` as a selector:
191191

192-
$countInt = {$count: number maximumFractionDigits=0}
193-
$itemAcc = {$item: noun count=$count case=accusative}
194-
one [You bought {$color: adjective article=indefinite accord=$itemAcc} {$itemAcc}.]
195-
* [You bought {$countInt} {$color: adjective accord=$itemAcc} {$itemAcc}.]
192+
$countInt = {$count :number maximumFractionDigits=0}
193+
$itemAcc = {$item :noun count=$count case=accusative}
194+
one [You bought {$color :adjective article=indefinite accord=$itemAcc} {$itemAcc}.]
195+
* [You bought {$countInt} {$color :adjective accord=$itemAcc} {$itemAcc}.]
196196

197197
### Complex Messages
198198

199199
A complex message with 2 selectors and 3 local variable definitions:
200200

201-
{$host: gender}
202-
{$guestOther: number}
201+
{$host :gender}
202+
{$guestOther :number}
203203

204-
$hostName = {$host: person firstName=long}
205-
$guestName = {$guest: person firstName=long}
206-
$guestsOther = {$guestCount: number offset=1}
204+
$hostName = {$host :person firstName=long}
205+
$guestName = {$guest :person firstName=long}
206+
$guestsOther = {$guestCount :number offset=1}
207207

208208
female 0 [{$hostName} does not give a party.]
209209
female 1 [{$hostName} invites {$guestName} to her party.]
@@ -338,7 +338,7 @@ Standalone function calls don't have any operands in front of them.
338338
```ebnf
339339
Expression ::= Operand Annotation? | Annotation
340340
Operand ::= String | Variable
341-
Annotation ::= ':' Name Option*
341+
Annotation ::= Function Option*
342342
Option ::= Name '=' (String | Nmtoken | Variable)
343343
```
344344

@@ -349,19 +349,19 @@ Examples:
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
```
364-
$when: datetime month=2-digit
364+
$when :datetime month=2-digit
365365
```
366366

367367
```
@@ -412,7 +412,7 @@ AnyChar ::= .
412412
### Names
413413

414414
The _name_ token is used for variable names (prefixed with `$`),
415-
function names as well as option names.
415+
function names (prefixed with `:`) as well as option names.
416416
A name cannot start with an ASCII digit and certain basic combining characters.
417417
Otherwise, the set of characters allowed in names is large.
418418

@@ -428,6 +428,7 @@ uses Nmtokens.
428428

429429
```ebnf
430430
Variable ::= '$' Name /* ws: explicit */
431+
Function ::= ':' Name /* ws: explicit */
431432
Name ::= NameStart NameChar* /* ws: explicit */
432433
Nmtoken ::= NameChar+ /* ws: explicit */
433434
NameStart ::= [a-zA-Z] | "_"

0 commit comments

Comments
 (0)