@@ -25,6 +25,10 @@ Two equivalent definitions of the data model are also provided:
25
25
A ` SelectMessage ` corresponds to a syntax message that includes _ selectors_ .
26
26
A message without _ selectors_ and with a single _ pattern_ is represented by a ` PatternMessage ` .
27
27
28
+ In the syntax,
29
+ a ` PatternMessage ` may be represented either as a _ simple message_ or as a _ complex message_ ,
30
+ depending on whether it has declarations and if its ` pattern ` is allowed in a _ simple message_ .
31
+
28
32
``` ts
29
33
type Message = PatternMessage | SelectMessage ;
30
34
@@ -43,15 +47,47 @@ interface SelectMessage {
43
47
```
44
48
45
49
Each message _ declaration_ is represented by a ` Declaration ` ,
46
- which connects the ` name ` of the _ variable_
50
+ which connects the ` name ` of a _ variable_
47
51
with its _ expression_ ` value ` .
48
52
The ` name ` does not include the initial ` $ ` of the _ variable_ .
49
53
54
+ The ` name ` of an ` InputDeclaration ` MUST be the same
55
+ as the ` name ` in the ` VariableRef ` of its ` VariableExpression ` ` value ` .
56
+
57
+ An ` UnsupportedStatement ` represents a statement not supported by the implementation.
58
+ Its ` keyword ` is a non-empty string name (i.e. not including the initial ` . ` ).
59
+ If not empty, the ` body ` is the "raw" value (i.e. escape sequences are not processed)
60
+ starting after the keyword and up to the first _ expression_ ,
61
+ not including leading or trailing whitespace.
62
+ The non-empty ` expressions ` correspond to the trailing _ expressions_ of the _ reserved statement_ .
63
+
64
+ > ** Note**
65
+ > Be aware that future versions of this specification
66
+ > might assign meaning to _ reserved statement_ values.
67
+ > This would result in new interfaces being added to
68
+ > this data model.
69
+
50
70
``` ts
51
- interface Declaration {
71
+ type Declaration = InputDeclaration | LocalDeclaration | UnsupportedStatement ;
72
+
73
+ interface InputDeclaration {
74
+ type: " input" ;
75
+ name: string ;
76
+ value: VariableExpression ;
77
+ }
78
+
79
+ interface LocalDeclaration {
80
+ type: " local" ;
52
81
name: string ;
53
82
value: Expression ;
54
83
}
84
+
85
+ interface UnsupportedStatement {
86
+ type: " unsupported-statement" ;
87
+ keyword: string ;
88
+ body? : string ;
89
+ expressions: Expression [];
90
+ }
55
91
```
56
92
57
93
In a ` SelectMessage ` ,
@@ -74,28 +110,35 @@ interface CatchallKey {
74
110
## Patterns
75
111
76
112
Each ` Pattern ` represents a linear sequence, without selectors.
77
- Each element of the sequence MUST have either a ` Text ` or an ` Expression ` shape .
78
- ` Text ` represents literal _ text_ ,
113
+ Each element of the ` body ` array MUST either be a non-empty string or an ` Expression ` object .
114
+ String values represent literal _ text_ ,
79
115
while ` Expression ` wraps each of the potential _ expression_ shapes.
80
- The ` value ` of ` Text ` is the "cooked" value ( i.e. escape sequences are processed) .
116
+ The ` body ` strings are the "cooked" _ text _ values, i.e. escape sequences are processed.
81
117
82
- Implementations MUST NOT rely on the set of ` Expression ` ` body ` values being exhaustive,
118
+ Implementations MUST NOT rely on the set of ` Expression ` interfaces being exhaustive,
83
119
as future versions of this specification MAY define additional expressions.
84
- A ` body ` with an unrecognized value SHOULD be treated as an ` Unsupported ` value.
120
+ An ` Expression ` ` func ` with an unrecognized value SHOULD be treated as an ` UnsupportedExpression ` value.
85
121
86
122
``` ts
87
123
interface Pattern {
88
- body: Array <Text | Expression >;
124
+ body: Array <string | Expression >;
89
125
}
90
126
91
- interface Text {
92
- type: " text" ;
93
- value: string ;
127
+ type Expression = LiteralExpression | VariableExpression | FunctionExpression ;
128
+
129
+ interface LiteralExpression {
130
+ arg: Literal ;
131
+ func? : FunctionRef | UnsupportedExpression ;
132
+ }
133
+
134
+ interface VariableExpression {
135
+ arg: VariableRef ;
136
+ func? : FunctionRef | UnsupportedExpression ;
94
137
}
95
138
96
- interface Expression {
97
- type : " expression " ;
98
- body : Literal | VariableRef | FunctionRef | Unsupported ;
139
+ interface FunctionExpression {
140
+ arg ? : never ;
141
+ func : FunctionRef | UnsupportedExpression ;
99
142
}
100
143
```
101
144
@@ -148,31 +191,31 @@ interface Option {
148
191
}
149
192
```
150
193
151
- An ` Unsupported ` represents an _ expression_ with a
152
- _ reserved _ _ annotation _ or a _ private-use _ _ annotation _ not supported
194
+ An ` UnsupportedExpression ` represents an _ expression_ with a
195
+ _ reserved annotation _ or a _ private-use annotation _ not supported
153
196
by the implementation.
154
197
The ` sigil ` corresponds to the starting sigil of the _ annotation_ .
155
198
The ` source ` is the "raw" value (i.e. escape sequences are not processed)
156
199
and does not include the starting ` sigil ` .
157
200
158
201
> ** Note**
159
202
> Be aware that future versions of this specification
160
- > might assign meaning to _ reserved _ ` sigil ` values.
203
+ > might assign meaning to _ reserved annotation _ ` sigil ` values.
161
204
> This would result in new interfaces being added to
162
205
> this data model.
163
206
164
207
If the _ expression_ includes a _ literal_ or _ variable_ before the _ annotation_ ,
165
208
it is included as the ` operand ` .
166
209
167
- When parsing the syntax of a _ message_ that includes a _ private-use _ _ annotation _
210
+ When parsing the syntax of a _ message_ that includes a _ private-use annotation _
168
211
supported by the implementation,
169
212
the implementation SHOULD represent it in the data model
170
213
using an interface appropriate for the semantics and meaning
171
214
that the implementation attaches to that _ annotation_ .
172
215
173
216
``` ts
174
- interface Unsupported {
175
- type: " unsupported" ;
217
+ interface UnsupportedExpression {
218
+ type: " unsupported-expression " ;
176
219
sigil: " !" | " @" | " #" | " %" | " ^" | " &" | " *" | " <" | " >" | " /" | " ?" | " ~" ;
177
220
source: string ;
178
221
operand? : Literal | VariableRef ;
0 commit comments