Skip to content

Commit e182d20

Browse files
committed
Merge branch 'main' into match-vars
2 parents 9929077 + 40db4e0 commit e182d20

15 files changed

+149
-747
lines changed

spec/README.md

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,7 @@ Updates to this specification MUST NOT specify the use of a fallback value for a
9090
that previously did not specify a fallback value.
9191

9292
Updates to this specification will not change the syntactical meaning
93-
of any syntax defined in this specification except for that syntax marked as
94-
"reserved for future standardization".
95-
96-
Updates to this specification will not assign any meaning to or change the syntactical
97-
requirements for any private-use annotation.
98-
99-
Updates to this specification will not remove any reserved keywords or sigils.
100-
101-
Updates to this specification will not add any additional Unicode code points to
102-
those in `reserved-annotation-start`.
93+
of any syntax defined in this specification.
10394

10495
Updates to this specification will not remove any functions defined in the default registry.
10596

@@ -114,13 +105,6 @@ defined in the default registry.
114105
> differences in implementation or changes to locale data
115106
> (such as due to the release of new CLDR versions).
116107
117-
Updates to this specification will not introduce message syntax that,
118-
when parsed according to earlier versions of this specification,
119-
would produce syntax or data model errors.
120-
Messages that use syntax introduced in a future version of this specification
121-
could produce resolution or message function errors
122-
when formatted according to an earlier version of this specification.
123-
124108
Updates to this specification will only reserve, define, or require
125109
function names or function option names
126110
consisting of characters in the ranges a-z, A-Z, and 0-9.
@@ -137,29 +121,19 @@ based on this version being invalid.
137121

138122
> For example, existing interfaces or fields will not be removed.
139123
140-
Future versions of this specification will not introduce syntax that cannot be
141-
represented by this version of the data model.
142-
143-
> For example, a future version could introduce a new keyword.
144-
> The future version's data model would provide an interface for that keyword
145-
> while this version of the data model would parse the value into
146-
> the interface `UnsupportedStatement`.
147-
> Both data models would be "valid" in their context,
148-
> but this version's would be missing any functionality for the new statement type.
149-
150124
> [!IMPORTANT]
151125
> This stability policy allows any of the following, non-exhaustive list, of changes
152126
> in future versions of this specification:
127+
> - Future versions may define new syntax and structures
128+
> that would not be supported by this version of the specification.
153129
> - Future versions may add additional structure or meaning to existing syntax.
154130
> - Future versions may define new keywords.
155-
> - Future versions may define annotations that use portions of the `reserved-annotation`
156-
> syntax.
157131
> - Future versions may make previously invalid messages valid.
158132
> - Future versions may define additional functions in the default registry
159133
> or may reserve the names of functions for the purposes of interoperability.
160134
> - Future versions may define additional options to existing functions.
161135
> - Future versions may define additional option values for existing options.
162-
> - Future versions may deprecate functions, options, or option values.
136+
> - Future versions may deprecate (but not remove) keywords, functions, options, or option values.
163137
> - Future versions of this specification may introduce changes
164138
> to the data model that would result in future data model representations
165139
> not being valid for implementations of this version of the data model.

spec/data-model/README.md

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ Implementations that expose APIs supporting the production, consumption, or tran
1717
_message_ as a data structure are encouraged to use this data model.
1818

1919
This data model provides these capabilities:
20-
- any MessageFormat 2 message (including future versions)
21-
can be parsed into this representation
20+
- any MessageFormat 2.0 message can be parsed into this representation
2221
- this data model representation can be serialized as a well-formed
23-
MessageFormat 2 message
24-
- parsing a MessageFormat 2 message into a data model representation
22+
MessageFormat 2.0 message
23+
- parsing a MessageFormat 2.0 message into a data model representation
2524
and then serializing it results in an equivalently functional message
2625

2726
This data model might also be used to:
@@ -98,21 +97,8 @@ The `name` does not include the initial `$` of the _variable_.
9897
The `name` of an `InputDeclaration` MUST be the same
9998
as the `name` in the `VariableRef` of its `VariableExpression` `value`.
10099

101-
An `UnsupportedStatement` represents a statement not supported by the implementation.
102-
Its `keyword` is a non-empty string name (i.e. not including the initial `.`).
103-
If not empty, the `body` is the "raw" value (i.e. escape sequences are not processed)
104-
starting after the keyword and up to the first _expression_,
105-
not including leading or trailing whitespace.
106-
The non-empty `expressions` correspond to the trailing _expressions_ of the _reserved statement_.
107-
108-
> [!NOTE]
109-
> Be aware that future versions of this specification
110-
> might assign meaning to _reserved statement_ values.
111-
> This would result in new interfaces being added to
112-
> this data model.
113-
114100
```ts
115-
type Declaration = InputDeclaration | LocalDeclaration | UnsupportedStatement;
101+
type Declaration = InputDeclaration | LocalDeclaration;
116102

117103
interface InputDeclaration {
118104
type: "input";
@@ -125,13 +111,6 @@ interface LocalDeclaration {
125111
name: string;
126112
value: Expression;
127113
}
128-
129-
interface UnsupportedStatement {
130-
type: "unsupported-statement";
131-
keyword: string;
132-
body?: string;
133-
expressions: Expression[];
134-
}
135114
```
136115

137116
In a `SelectMessage`,
@@ -173,34 +152,26 @@ type Pattern = Array<string | Expression | Markup>;
173152
type Expression =
174153
| LiteralExpression
175154
| VariableExpression
176-
| FunctionExpression
177-
| UnsupportedExpression;
155+
| FunctionExpression;
178156

179157
interface LiteralExpression {
180158
type: "expression";
181159
arg: Literal;
182-
annotation?: FunctionAnnotation | UnsupportedAnnotation;
160+
function?: FunctionRef;
183161
attributes: Attributes;
184162
}
185163

186164
interface VariableExpression {
187165
type: "expression";
188166
arg: VariableRef;
189-
annotation?: FunctionAnnotation | UnsupportedAnnotation;
167+
function?: FunctionRef;
190168
attributes: Attributes;
191169
}
192170

193171
interface FunctionExpression {
194172
type: "expression";
195173
arg?: never;
196-
annotation: FunctionAnnotation;
197-
attributes: Attributes;
198-
}
199-
200-
interface UnsupportedExpression {
201-
type: "expression";
202-
arg?: never;
203-
annotation: UnsupportedAnnotation;
174+
function: FunctionRef;
204175
attributes: Attributes;
205176
}
206177
```
@@ -209,7 +180,7 @@ interface UnsupportedExpression {
209180

210181
The `Literal` and `VariableRef` correspond to the the _literal_ and _variable_ syntax rules.
211182
When they are used as the `body` of an `Expression`,
212-
they represent _expression_ values with no _annotation_.
183+
they represent _expression_ values with no _function_.
213184

214185
`Literal` represents all literal values, both _quoted literal_ and _unquoted literal_.
215186
The presence or absence of quotes is not preserved by the data model.
@@ -229,14 +200,14 @@ interface VariableRef {
229200
}
230201
```
231202

232-
A `FunctionAnnotation` represents a _function_ _annotation_.
203+
A `FunctionRef` represents a _function_.
233204
The `name` does not include the `:` starting sigil.
234205

235206
`Options` is a key-value mapping containing options,
236-
and is used to represent the _annotation_ and _markup_ _options_.
207+
and is used to represent the _function_ and _markup_ _options_.
237208

238209
```ts
239-
interface FunctionAnnotation {
210+
interface FunctionRef {
240211
type: "function";
241212
name: string;
242213
options: Options;
@@ -245,31 +216,13 @@ interface FunctionAnnotation {
245216
type Options = Map<string, Literal | VariableRef>;
246217
```
247218

248-
An `UnsupportedAnnotation` represents a
249-
_private-use annotation_ not supported by the implementation or a _reserved annotation_.
250-
The `source` is the "raw" value (i.e. escape sequences are not processed),
251-
including the starting sigil.
252-
253-
When parsing the syntax of a _message_ that includes a _private-use annotation_
254-
supported by the implementation,
255-
the implementation SHOULD represent it in the data model
256-
using an interface appropriate for the semantics and meaning
257-
that the implementation attaches to that _annotation_.
258-
259-
```ts
260-
interface UnsupportedAnnotation {
261-
type: "unsupported-annotation";
262-
source: string;
263-
}
264-
```
265-
266219
## Markup
267220

268221
A `Markup` object has a `kind` of either `"open"`, `"standalone"`, or `"close"`,
269222
each corresponding to _open_, _standalone_, and _close_ _markup_.
270223
The `name` in these does not include the starting sigils `#` and `/`
271224
or the ending sigil `/`.
272-
The `options` for markup use the same key-value mapping as `FunctionAnnotation`.
225+
The `options` for markup use the same key-value mapping as `FunctionRef`.
273226

274227
```ts
275228
interface Markup {

spec/data-model/message.dtd

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!ELEMENT message (
2-
(declaration | unsupportedStatement)*,
2+
(declaration)*,
33
(pattern | (selectors,variant+))
44
)>
55

@@ -10,12 +10,6 @@
1010
name NMTOKEN #REQUIRED
1111
>
1212

13-
<!ELEMENT unsupportedStatement (expression)+>
14-
<!ATTLIST unsupportedStatement
15-
keyword CDATA #REQUIRED
16-
body CDATA #IMPLIED
17-
>
18-
1913
<!ELEMENT selectors (variable)+>
2014
<!ELEMENT variant (key+,pattern)>
2115
<!ELEMENT key (#PCDATA)>
@@ -24,23 +18,21 @@
2418
<!ELEMENT pattern (#PCDATA | expression | markup)*>
2519

2620
<!ELEMENT expression (
27-
((literal | variable), (functionAnnotation | unsupportedAnnotation)?, attribute*) |
28-
((functionAnnotation | unsupportedAnnotation), attribute*)
21+
((literal | variable), function?, attribute*) |
22+
(function, attribute*)
2923
)>
3024

3125
<!ELEMENT literal (#PCDATA)>
3226

3327
<!ELEMENT variable (EMPTY)>
3428
<!ATTLIST variable name NMTOKEN #REQUIRED>
3529

36-
<!ELEMENT functionAnnotation (option)*>
37-
<!ATTLIST functionAnnotation name NMTOKEN #REQUIRED>
30+
<!ELEMENT function (option)*>
31+
<!ATTLIST function name NMTOKEN #REQUIRED>
3832

3933
<!ELEMENT option (literal | variable)>
4034
<!ATTLIST option name NMTOKEN #REQUIRED>
4135

42-
<!ELEMENT unsupportedAnnotation (#PCDATA)>
43-
4436
<!ELEMENT attribute (literal)?>
4537
<!ATTLIST attribute name NMTOKEN #REQUIRED>
4638

spec/data-model/message.json

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
},
3838

39-
"function-annotation": {
39+
"function": {
4040
"type": "object",
4141
"properties": {
4242
"type": { "const": "function" },
@@ -45,65 +45,17 @@
4545
},
4646
"required": ["type", "name"]
4747
},
48-
"unsupported-annotation": {
49-
"type": "object",
50-
"properties": {
51-
"type": { "const": "unsupported-annotation" },
52-
"source": { "type": "string" }
53-
},
54-
"required": ["type", "source"]
55-
},
56-
"annotation": {
57-
"oneOf": [
58-
{ "$ref": "#/$defs/function-annotation" },
59-
{ "$ref": "#/$defs/unsupported-annotation" }
60-
]
61-
},
62-
63-
"literal-expression": {
64-
"type": "object",
65-
"properties": {
66-
"type": { "const": "expression" },
67-
"arg": { "$ref": "#/$defs/literal" },
68-
"annotation": { "$ref": "#/$defs/annotation" },
69-
"attributes": { "$ref": "#/$defs/attributes" }
70-
},
71-
"required": ["type", "arg"]
72-
},
73-
"variable-expression": {
74-
"type": "object",
75-
"properties": {
76-
"type": { "const": "expression" },
77-
"arg": { "$ref": "#/$defs/variable" },
78-
"annotation": { "$ref": "#/$defs/annotation" },
79-
"attributes": { "$ref": "#/$defs/attributes" }
80-
},
81-
"required": ["type", "arg"]
82-
},
83-
"function-expression": {
84-
"type": "object",
85-
"properties": {
86-
"type": { "const": "expression" },
87-
"annotation": { "$ref": "#/$defs/function-annotation" },
88-
"attributes": { "$ref": "#/$defs/attributes" }
89-
},
90-
"required": ["type", "annotation"]
91-
},
92-
"unsupported-expression": {
48+
"expression": {
9349
"type": "object",
9450
"properties": {
9551
"type": { "const": "expression" },
96-
"annotation": { "$ref": "#/$defs/unsupported-annotation" },
52+
"arg": { "$ref": "#/$defs/literal-or-variable" },
53+
"function": { "$ref": "#/$defs/function" },
9754
"attributes": { "$ref": "#/$defs/attributes" }
9855
},
99-
"required": ["type", "annotation"]
100-
},
101-
"expression": {
10256
"oneOf": [
103-
{ "$ref": "#/$defs/literal-expression" },
104-
{ "$ref": "#/$defs/variable-expression" },
105-
{ "$ref": "#/$defs/function-expression" },
106-
{ "$ref": "#/$defs/unsupported-expression" }
57+
{ "required": ["type", "arg"] },
58+
{ "required": ["type", "function"] }
10759
]
10860
},
10961

@@ -148,26 +100,12 @@
148100
},
149101
"required": ["type", "name", "value"]
150102
},
151-
"unsupported-statement": {
152-
"type": "object",
153-
"properties": {
154-
"type": { "const": "unsupported-statement" },
155-
"keyword": { "type": "string" },
156-
"body": { "type": "string" },
157-
"expressions": {
158-
"type": "array",
159-
"items": { "$ref": "#/$defs/expression" }
160-
}
161-
},
162-
"required": ["type", "keyword", "expressions"]
163-
},
164103
"declarations": {
165104
"type": "array",
166105
"items": {
167106
"oneOf": [
168107
{ "$ref": "#/$defs/input-declaration" },
169-
{ "$ref": "#/$defs/local-declaration" },
170-
{ "$ref": "#/$defs/unsupported-statement" }
108+
{ "$ref": "#/$defs/local-declaration" }
171109
]
172110
}
173111
},

0 commit comments

Comments
 (0)