File tree 10 files changed +286
-17
lines changed
10 files changed +286
-17
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,9 @@ MessageReference ::= Identifier
65
65
TermReference ::= " -" Identifier
66
66
VariableReference ::= " $" Identifier
67
67
FunctionReference ::= Identifier
68
- CallExpression ::= FunctionReference blank ? " (" blank ? argument_list blank ? " )"
68
+ CallExpression ::= Callee blank ? " (" blank ? argument_list blank ? " )"
69
+ Callee ::= FunctionReference
70
+ | TermReference
69
71
argument_list ::= (Argument blank ? " ," blank ? )* Argument ?
70
72
Argument ::= NamedArgument
71
73
| InlineExpression
Original file line number Diff line number Diff line change @@ -54,5 +54,6 @@ Invalid Select Expressions:
54
54
55
55
SelectExpression.selector > MessageReference
56
56
SelectExpression.selector > TermReference
57
+ SelectExpression.selector > CallExpression.callee > TermReference
57
58
SelectExpression.selector > VariantExpression
58
59
SelectExpression.selector > AttributeExpression.ref > MessageReference
Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ export function list_into(Type) {
68
68
let invalid_selector_found =
69
69
selector instanceof FTL . MessageReference
70
70
|| selector instanceof FTL . TermReference
71
+ || ( selector instanceof FTL . CallExpression
72
+ && selector . callee instanceof FTL . TermReference )
71
73
|| selector instanceof FTL . VariantExpression
72
74
|| ( selector instanceof FTL . AttributeExpression
73
75
&& selector . ref instanceof FTL . MessageReference ) ;
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ let FunctionReference = defer(() =>
243
243
244
244
let CallExpression = defer ( ( ) =>
245
245
sequence (
246
- FunctionReference . abstract ,
246
+ Callee . abstract ,
247
247
maybe ( blank ) ,
248
248
string ( "(" ) ,
249
249
maybe ( blank ) ,
@@ -253,6 +253,11 @@ let CallExpression = defer(() =>
253
253
. map ( keep_abstract )
254
254
. chain ( list_into ( FTL . CallExpression ) ) ) ;
255
255
256
+ let Callee =
257
+ either (
258
+ FunctionReference ,
259
+ TermReference ) ;
260
+
256
261
let argument_list = defer ( ( ) =>
257
262
sequence (
258
263
repeat (
Original file line number Diff line number Diff line change 1
1
## Callees
2
2
3
3
function-callee = { FUNCTION( ) }
4
+ term-callee = { -term ()}
4
5
5
6
# ERROR Equivalent to a MessageReference callee.
6
7
mixed-case-callee = { Function ()}
7
8
8
9
# ERROR MessageReference is not a valid callee.
9
10
message-callee = { message ()}
10
- # ERROR TermReference is not a valid callee.
11
- term-callee = { -term ()}
12
11
# ERROR VariableReference is not a valid callee.
13
12
variable-callee = { $variable ()}
14
13
Original file line number Diff line number Diff line change 34
34
"attributes" : [],
35
35
"comment" : null
36
36
},
37
+ {
38
+ "type" : " Message" ,
39
+ "id" : {
40
+ "type" : " Identifier" ,
41
+ "name" : " term-callee"
42
+ },
43
+ "value" : {
44
+ "type" : " Pattern" ,
45
+ "elements" : [
46
+ {
47
+ "type" : " Placeable" ,
48
+ "expression" : {
49
+ "type" : " CallExpression" ,
50
+ "callee" : {
51
+ "type" : " TermReference" ,
52
+ "id" : {
53
+ "type" : " Identifier" ,
54
+ "name" : " term"
55
+ }
56
+ },
57
+ "positional" : [],
58
+ "named" : []
59
+ }
60
+ }
61
+ ]
62
+ },
63
+ "attributes" : [],
64
+ "comment" : null
65
+ },
37
66
{
38
67
"type" : " Comment" ,
39
68
"content" : " ERROR Equivalent to a MessageReference callee."
52
81
"annotations" : [],
53
82
"content" : " message-callee = {message()}\n "
54
83
},
55
- {
56
- "type" : " Comment" ,
57
- "content" : " ERROR TermReference is not a valid callee."
58
- },
59
- {
60
- "type" : " Junk" ,
61
- "annotations" : [],
62
- "content" : " term-callee = {-term()}\n "
63
- },
64
84
{
65
85
"type" : " Comment" ,
66
86
"content" : " ERROR VariableReference is not a valid callee."
Original file line number Diff line number Diff line change @@ -4,17 +4,29 @@ new-messages =
4
4
*[ other ] { " " } Other
5
5
}
6
6
7
- valid-selector =
7
+ valid-selector-term-attribute =
8
8
{ -term .case ->
9
9
*[ key ] value
10
10
}
11
11
12
12
# ERROR
13
- invalid-selector =
13
+ invalid-selector-term-value =
14
+ { -term ->
15
+ *[ key ] value
16
+ }
17
+
18
+ # ERROR
19
+ invalid-selector-term-variant =
14
20
{ -term [case ] ->
15
21
*[ key ] value
16
22
}
17
23
24
+ # ERROR
25
+ invalid-selector-term-call =
26
+ { -term (case : " nominative " ) ->
27
+ *[ key ] value
28
+ }
29
+
18
30
empty-variant =
19
31
{ 1 ->
20
32
*[ one ] { " " }
Original file line number Diff line number Diff line change 80
80
"type" : " Message" ,
81
81
"id" : {
82
82
"type" : " Identifier" ,
83
- "name" : " valid-selector"
83
+ "name" : " valid-selector-term-attribute "
84
84
},
85
85
"value" : {
86
86
"type" : " Pattern" ,
136
136
{
137
137
"type" : " Junk" ,
138
138
"annotations" : [],
139
- "content" : " invalid-selector =\n { -term[case] ->\n *[key] value\n }\n "
139
+ "content" : " invalid-selector-term-value =\n { -term ->\n *[key] value\n }\n "
140
+ },
141
+ {
142
+ "type" : " Comment" ,
143
+ "content" : " ERROR"
144
+ },
145
+ {
146
+ "type" : " Junk" ,
147
+ "annotations" : [],
148
+ "content" : " invalid-selector-term-variant =\n { -term[case] ->\n *[key] value\n }\n "
149
+ },
150
+ {
151
+ "type" : " Comment" ,
152
+ "content" : " ERROR"
153
+ },
154
+ {
155
+ "type" : " Junk" ,
156
+ "annotations" : [],
157
+ "content" : " invalid-selector-term-call =\n { -term(case: \" nominative\" ) ->\n *[key] value\n }\n "
140
158
},
141
159
{
142
160
"type" : " Message" ,
Original file line number Diff line number Diff line change
1
+ -term = { $arg ->
2
+ *[ key ] Value
3
+ }
4
+
5
+ key01 = { -term }
6
+ key02 = { -term () }
7
+ key03 = { -term (arg : 1 ) }
8
+ key04 = { -term (" positional " , narg1 : 1 , narg2 : 2 ) }
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Resource" ,
3
+ "body" : [
4
+ {
5
+ "type" : " Term" ,
6
+ "id" : {
7
+ "type" : " Identifier" ,
8
+ "name" : " term"
9
+ },
10
+ "value" : {
11
+ "type" : " Pattern" ,
12
+ "elements" : [
13
+ {
14
+ "type" : " Placeable" ,
15
+ "expression" : {
16
+ "type" : " SelectExpression" ,
17
+ "selector" : {
18
+ "type" : " VariableReference" ,
19
+ "id" : {
20
+ "type" : " Identifier" ,
21
+ "name" : " arg"
22
+ }
23
+ },
24
+ "variants" : [
25
+ {
26
+ "type" : " Variant" ,
27
+ "key" : {
28
+ "type" : " Identifier" ,
29
+ "name" : " key"
30
+ },
31
+ "value" : {
32
+ "type" : " Pattern" ,
33
+ "elements" : [
34
+ {
35
+ "type" : " TextElement" ,
36
+ "value" : " Value"
37
+ }
38
+ ]
39
+ },
40
+ "default" : true
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ ]
46
+ },
47
+ "attributes" : [],
48
+ "comment" : null
49
+ },
50
+ {
51
+ "type" : " Message" ,
52
+ "id" : {
53
+ "type" : " Identifier" ,
54
+ "name" : " key01"
55
+ },
56
+ "value" : {
57
+ "type" : " Pattern" ,
58
+ "elements" : [
59
+ {
60
+ "type" : " Placeable" ,
61
+ "expression" : {
62
+ "type" : " TermReference" ,
63
+ "id" : {
64
+ "type" : " Identifier" ,
65
+ "name" : " term"
66
+ }
67
+ }
68
+ }
69
+ ]
70
+ },
71
+ "attributes" : [],
72
+ "comment" : null
73
+ },
74
+ {
75
+ "type" : " Message" ,
76
+ "id" : {
77
+ "type" : " Identifier" ,
78
+ "name" : " key02"
79
+ },
80
+ "value" : {
81
+ "type" : " Pattern" ,
82
+ "elements" : [
83
+ {
84
+ "type" : " Placeable" ,
85
+ "expression" : {
86
+ "type" : " CallExpression" ,
87
+ "callee" : {
88
+ "type" : " TermReference" ,
89
+ "id" : {
90
+ "type" : " Identifier" ,
91
+ "name" : " term"
92
+ }
93
+ },
94
+ "positional" : [],
95
+ "named" : []
96
+ }
97
+ }
98
+ ]
99
+ },
100
+ "attributes" : [],
101
+ "comment" : null
102
+ },
103
+ {
104
+ "type" : " Message" ,
105
+ "id" : {
106
+ "type" : " Identifier" ,
107
+ "name" : " key03"
108
+ },
109
+ "value" : {
110
+ "type" : " Pattern" ,
111
+ "elements" : [
112
+ {
113
+ "type" : " Placeable" ,
114
+ "expression" : {
115
+ "type" : " CallExpression" ,
116
+ "callee" : {
117
+ "type" : " TermReference" ,
118
+ "id" : {
119
+ "type" : " Identifier" ,
120
+ "name" : " term"
121
+ }
122
+ },
123
+ "positional" : [],
124
+ "named" : [
125
+ {
126
+ "type" : " NamedArgument" ,
127
+ "name" : {
128
+ "type" : " Identifier" ,
129
+ "name" : " arg"
130
+ },
131
+ "value" : {
132
+ "type" : " NumberLiteral" ,
133
+ "value" : " 1"
134
+ }
135
+ }
136
+ ]
137
+ }
138
+ }
139
+ ]
140
+ },
141
+ "attributes" : [],
142
+ "comment" : null
143
+ },
144
+ {
145
+ "type" : " Message" ,
146
+ "id" : {
147
+ "type" : " Identifier" ,
148
+ "name" : " key04"
149
+ },
150
+ "value" : {
151
+ "type" : " Pattern" ,
152
+ "elements" : [
153
+ {
154
+ "type" : " Placeable" ,
155
+ "expression" : {
156
+ "type" : " CallExpression" ,
157
+ "callee" : {
158
+ "type" : " TermReference" ,
159
+ "id" : {
160
+ "type" : " Identifier" ,
161
+ "name" : " term"
162
+ }
163
+ },
164
+ "positional" : [
165
+ {
166
+ "type" : " StringLiteral" ,
167
+ "value" : " positional"
168
+ }
169
+ ],
170
+ "named" : [
171
+ {
172
+ "type" : " NamedArgument" ,
173
+ "name" : {
174
+ "type" : " Identifier" ,
175
+ "name" : " narg1"
176
+ },
177
+ "value" : {
178
+ "type" : " NumberLiteral" ,
179
+ "value" : " 1"
180
+ }
181
+ },
182
+ {
183
+ "type" : " NamedArgument" ,
184
+ "name" : {
185
+ "type" : " Identifier" ,
186
+ "name" : " narg2"
187
+ },
188
+ "value" : {
189
+ "type" : " NumberLiteral" ,
190
+ "value" : " 2"
191
+ }
192
+ }
193
+ ]
194
+ }
195
+ }
196
+ ]
197
+ },
198
+ "attributes" : [],
199
+ "comment" : null
200
+ }
201
+ ]
202
+ }
You can’t perform that action at this time.
0 commit comments