@quenk/wml 2.11.3 → 2.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,18 +2,15 @@
2
2
  /// <reference path='generated.d.ts' />
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.parse = void 0;
5
- var parser = require("./generated");
6
- var nodes = require("./ast");
7
- var error_1 = require("@quenk/noni/lib/control/error");
5
+ const parser = require("./generated");
6
+ const nodes = require("./ast");
7
+ const error_1 = require("@quenk/noni/lib/control/error");
8
8
  /**
9
9
  * parse a string containing WML returning the resulting AST.
10
10
  */
11
- var parse = function (str, ast) {
12
- if (ast === void 0) { ast = nodes; }
13
- return (0, error_1.attempt)(function () {
14
- parser.parser.yy = { ast: ast };
15
- return parser.parser.parse(str);
16
- });
17
- };
11
+ const parse = (str, ast = nodes) => (0, error_1.attempt)(() => {
12
+ parser.parser.yy = { ast };
13
+ return parser.parser.parse(str);
14
+ });
18
15
  exports.parse = parse;
19
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;AAEvC,oCAAsC;AACtC,6BAA+B;AAE/B,uDAAgE;AAEhE;;GAEG;AACI,IAAM,KAAK,GAAG,UAAC,GAAW,EAAE,GAAgB;IAAhB,oBAAA,EAAA,WAAgB;IAC/C,OAAA,IAAA,eAAO,EAAC;QAEJ,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,KAAA,EAAE,CAAC;QAE3B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEpC,CAAC,CAAC;AANF,CAME,CAAC;AAPM,QAAA,KAAK,SAOX"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;AAEvC,sCAAsC;AACtC,+BAA+B;AAE/B,yDAAgE;AAEhE;;GAEG;AACI,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,MAAW,KAAK,EAAwB,EAAE,CACzE,IAAA,eAAO,EAAC,GAAG,EAAE;IAET,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAE3B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAEpC,CAAC,CAAC,CAAC;AAPM,QAAA,KAAK,SAOX"}
package/lib/parse/test.js CHANGED
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tests = void 0;
4
4
  exports.tests = {
5
5
  'should parse qualified import': {
6
- input: "{% import * as lib from \"path/to/libs\" %}"
6
+ input: `{% import * as lib from "path/to/libs" %}`
7
7
  },
8
8
  'should parse named import': {
9
- input: "{% import (B) from \"path/to/a/b\" %}"
9
+ input: `{% import (B) from "path/to/a/b" %}`
10
10
  },
11
11
  'should detect exact duplicate imports': {
12
- input: "{% import (A) from \"b\" %} {% import (A) from \"b\" %}"
12
+ input: `{% import (A) from "b" %} {% import (A) from "b" %}`
13
13
  },
14
14
  'should parse a self closing tag': {
15
15
  input: '<simple/>'
@@ -71,7 +71,13 @@ exports.tests = {
71
71
  '</root>'
72
72
  },
73
73
  'should parse for from statements': {
74
- input: "\n <root>\n {% for value=1 to 30 %}\n <b>{{value}}</b>\n {% endfor %}\n </root>\n "
74
+ input: `
75
+ <root>
76
+ {% for value=1 to 30 %}
77
+ <b>{{value}}</b>
78
+ {% endfor %}
79
+ </root>
80
+ `
75
81
  },
76
82
  'should parse if then expressions': {
77
83
  input: '<Html id={{@id}}>{{ if @check() then a else b }}</Html>'
@@ -95,7 +101,16 @@ exports.tests = {
95
101
  input: '<Tag>{% if value %}<text>Text</text>{% else %}<text>else</text>{% endif %}</Tag>'
96
102
  },
97
103
  'should parse if else if statements': {
98
- input: "\n <Tag>\n {% if value %}\n <text>Text</text>\n {% else if value %}\n <text>else</text>\n {% else %}\n no\n {% endif %}\n </Tag>"
104
+ input: `
105
+ <Tag>
106
+ {% if value %}
107
+ <text>Text</text>
108
+ {% else if value %}
109
+ <text>else</text>
110
+ {% else %}
111
+ no
112
+ {% endif %}
113
+ </Tag>`
99
114
  },
100
115
  'should parse short fun statements': {
101
116
  input: '{% fun vue () = <View/> %}'
@@ -146,7 +161,11 @@ exports.tests = {
146
161
  '[view] should parse typed views with type parameters': {
147
162
  input: '{% view Main [A,B] (Context[A,B]) %} <p>{{@values}}</p>'
148
163
  },
149
- '[view] should allow the where syntax': "\n\n {% view HeadView where title: String %}\n <title>{{@title}}</title>\n ",
164
+ '[view] should allow the where syntax': `
165
+
166
+ {% view HeadView where title: String %}
167
+ <title>{{@title}}</title>
168
+ `,
150
169
  'should parse context variables': {
151
170
  input: '<Input name={{@level.name}}/>'
152
171
  },
@@ -154,7 +173,10 @@ exports.tests = {
154
173
  input: '{% view MyView (Context from "./") %} <div>{{@text}}</div>'
155
174
  },
156
175
  '[view] should allow multiple inline context imports': {
157
- input: "\n {% view MyView (Context from \"./\") %} <div>{{@text}}</div>\n {% view YourView (Context from \"./\") %} <div/>\n "
176
+ input: `
177
+ {% view MyView (Context from "./") %} <div>{{@text}}</div>
178
+ {% view YourView (Context from "./") %} <div/>
179
+ `
158
180
  },
159
181
  'should allow construct expression': {
160
182
  input: '<TextView android:thing={value=1}>{{Person(@value)}}</TextView>'
@@ -175,10 +197,78 @@ exports.tests = {
175
197
  input: '<div>{{ <@action()> }}</div>'
176
198
  },
177
199
  'should allow view statements after short fun': {
178
- input: "\n\n{% fun template [A] (d: Date[A], o:A, _:String, __:A[]) = {{String(o)}} %}\n\n{% view Results [A](Date[A]) %}\n\n <ul>\n\n {% for option,index in [1,3,4] %}\n\n <li>{{option}}and{{index}}</li>\n\n {% else %}\n\n <p>De nada!</p>\n\n {% endfor %}\n\n </ul>"
200
+ input: `
201
+
202
+ {% fun template [A] (d: Date[A], o:A, _:String, __:A[]) = {{String(o)}} %}
203
+
204
+ {% view Results [A](Date[A]) %}
205
+
206
+ <ul>
207
+
208
+ {% for option,index in [1,3,4] %}
209
+
210
+ <li>{{option}}and{{index}}</li>
211
+
212
+ {% else %}
213
+
214
+ <p>De nada!</p>
215
+
216
+ {% endfor %}
217
+
218
+ </ul>`
179
219
  },
180
220
  'should allow actual code': {
181
- input: "\n {% import (Table) from \"@quenk/wml-widgets/lib/data/table\" %}\n {% import (TextField) from \"@quenk/wml-widgets/lib/control/text-field\" %}\n {% import (Panel) from \"@quenk/wml-widgets/lib/layout/panel\" %}\n {% import (PanelHeader) from \"@quenk/wml-widgets/lib/layout/panel\" %}\n {% import (Tab) from \"@quenk/wml-widgets/lib/control/tab-bar\" %}\n {% import (TabBar) from \"@quenk/wml-widgets/lib/control/tab-bar\" %}\n {% import (TabSpec) from \"..\" %}\n {% import (TabbedPanel) from \"..\" %}\n\n {% view Main (TabbedPanel) %}\n\n <Panel ww:class={{@values.root.class}}>\n\n {% if (@values.header.tabs.length > 0) || (@values.header.additionalTabs) %}\n\n <PanelHeader>\n\n <TabBar>\n\n {% for tab in @values.header.tabs %}\n\n <Tab\n ww:name={{tab.name}}\n ww:onClick={{tab.onClick}} />\n\n {% endfor %}\n\n {% if @values.header.additionalTabs %}\n\n {{<(@values.header.additionalTabs)(@)>}}\n\n {% else %}\n\n {{''}}\n\n {% endif %}\n\n </TabBar>\n\n </PanelHeader>\n\n {% else %}\n\n {{''}}\n\n {% endif %}\n\n {{@children}}\n\n</Panel>"
221
+ input: `
222
+ {% import (Table) from "@quenk/wml-widgets/lib/data/table" %}
223
+ {% import (TextField) from "@quenk/wml-widgets/lib/control/text-field" %}
224
+ {% import (Panel) from "@quenk/wml-widgets/lib/layout/panel" %}
225
+ {% import (PanelHeader) from "@quenk/wml-widgets/lib/layout/panel" %}
226
+ {% import (Tab) from "@quenk/wml-widgets/lib/control/tab-bar" %}
227
+ {% import (TabBar) from "@quenk/wml-widgets/lib/control/tab-bar" %}
228
+ {% import (TabSpec) from ".." %}
229
+ {% import (TabbedPanel) from ".." %}
230
+
231
+ {% view Main (TabbedPanel) %}
232
+
233
+ <Panel ww:class={{@values.root.class}}>
234
+
235
+ {% if (@values.header.tabs.length > 0) || (@values.header.additionalTabs) %}
236
+
237
+ <PanelHeader>
238
+
239
+ <TabBar>
240
+
241
+ {% for tab in @values.header.tabs %}
242
+
243
+ <Tab
244
+ ww:name={{tab.name}}
245
+ ww:onClick={{tab.onClick}} />
246
+
247
+ {% endfor %}
248
+
249
+ {% if @values.header.additionalTabs %}
250
+
251
+ {{<(@values.header.additionalTabs)(@)>}}
252
+
253
+ {% else %}
254
+
255
+ {{''}}
256
+
257
+ {% endif %}
258
+
259
+ </TabBar>
260
+
261
+ </PanelHeader>
262
+
263
+ {% else %}
264
+
265
+ {{''}}
266
+
267
+ {% endif %}
268
+
269
+ {{@children}}
270
+
271
+ </Panel>`
182
272
  },
183
273
  'should recognize type parameters': {
184
274
  input: '{% fun test[A:String] (a:A) %} {{a}} {% endfun %}'
@@ -194,57 +284,190 @@ exports.tests = {
194
284
  },
195
285
  '[context] should parse constructors': '{% context Test where name: String %}',
196
286
  '[context] should parse generic constructors': '{% context Test where table.name: Text[A] %}',
197
- '[context] should parse record types': "{% context Test[A] where\n \n table.data.record: { \n\n name: String,\n table.name: Text[A],\n table.data.list: A[] \n } \n %}",
198
- '[context] should parse list types': "{% context Test[A] where table.data.list: A[] %}",
199
- '[context] should parse 2d list types': "{% context Test[A,B] where table.data.list2: A[][] %}",
200
- '[context] should parse 3d list types': "{% context Test[A, B, C] where table.data.list3: A[][][] %}",
201
- '[context] should parse func with no args or parens': "{% context Test where value: Test -> Number %}",
202
- '[context] should parse func with no args': "{% context Test where value: () -> Number %}",
203
- '[context] should parse no-parens func with constructor': "{% context Test where value: String -> String %}",
204
- '[context] should parse no-parens func with generic constructor': "{% context Test where value: Text[A] -> Text[A] %}",
205
- '[context] should parse no-parens func with record arg': "{% context Test where value: {} -> { } %}",
206
- '[context] should parse no-parens func with list arg': "{% context Test where value: String[] -> String[] %}",
207
- '[context] should parse func with cons arg': "{% context Test where value: (String) -> String %}",
208
- '[context] should parse func with 2 cons args': "{% context Test where value: (String, String) -> String %}",
209
- '[context] should parse func with 3 cons args': "{% context Test where value: (String, String, String) -> String %}",
210
- '[context] should parse func with generic cons arg': "{% context Test[A] where value: (Text[A]) -> Text[A] %}",
211
- '[context] should parse func with 2 generic cons args': "{% context Test[A] where value: (Text[A], Text[A]) -> Text[A] %}",
212
- '[context] should parse func with 3 generic cons args': "{% context Test[A] where value: (Text[A], Text[A], Text[A]) -> Text[A] %}",
213
- '[context] should parse func with record arg': "{% context Test where value: ({ }) -> { } %}",
214
- '[context] should parse func with 2 record args': "{% context Test where value: ({ }, { name: String }) -> { } %}",
215
- '[context] should parse func with 3 record args': "{% context Test where value: ({ }, { name: String }, { value: A[]}) -> { } %}",
216
- '[context] should parse func with list arg': "{% context Test where value: (String[]) -> String[] %}",
217
- '[context] should parse func with 2 list args': "{% context Test where value: (String[], String[]) -> String[] %}",
218
- '[context] should parse func with 3 list args': "{% context Test where value: (String[], String[], String[]) -> String[] %}",
219
- '[context] should parse func with func arg': "{% context Test where value: (String -> String) -> String %}",
220
- '[context] should parse func with 2 func args': "{% context Test where value: ((String -> String), (String -> String)) -> String %}",
221
- '[context] should parse func with 3 func args': "{% context Test where\n value: ((String -> String), (String -> String), (String -> String)) -> String \n %}",
222
- '[context] should parse func that return array of generic type': "{% context Test[A] where value: Number -> Text[A][] %}",
223
- '[context] should parse funct that return array of array': "{% context Test where value: String -> Number[][] %}",
287
+ '[context] should parse record types': `{% context Test[A] where
288
+
289
+ table.data.record: {
290
+
291
+ name: String,
292
+ table.name: Text[A],
293
+ table.data.list: A[]
294
+ }
295
+ %}`,
296
+ '[context] should parse list types': `{% context Test[A] where table.data.list: A[] %}`,
297
+ '[context] should parse 2d list types': `{% context Test[A,B] where table.data.list2: A[][] %}`,
298
+ '[context] should parse 3d list types': `{% context Test[A, B, C] where table.data.list3: A[][][] %}`,
299
+ '[context] should parse func with no args or parens': `{% context Test where value: Test -> Number %}`,
300
+ '[context] should parse func with no args': `{% context Test where value: () -> Number %}`,
301
+ '[context] should parse no-parens func with constructor': `{% context Test where value: String -> String %}`,
302
+ '[context] should parse no-parens func with generic constructor': `{% context Test where value: Text[A] -> Text[A] %}`,
303
+ '[context] should parse no-parens func with record arg': `{% context Test where value: {} -> { } %}`,
304
+ '[context] should parse no-parens func with list arg': `{% context Test where value: String[] -> String[] %}`,
305
+ '[context] should parse func with cons arg': `{% context Test where value: (String) -> String %}`,
306
+ '[context] should parse func with 2 cons args': `{% context Test where value: (String, String) -> String %}`,
307
+ '[context] should parse func with 3 cons args': `{% context Test where value: (String, String, String) -> String %}`,
308
+ '[context] should parse func with generic cons arg': `{% context Test[A] where value: (Text[A]) -> Text[A] %}`,
309
+ '[context] should parse func with 2 generic cons args': `{% context Test[A] where value: (Text[A], Text[A]) -> Text[A] %}`,
310
+ '[context] should parse func with 3 generic cons args': `{% context Test[A] where value: (Text[A], Text[A], Text[A]) -> Text[A] %}`,
311
+ '[context] should parse func with record arg': `{% context Test where value: ({ }) -> { } %}`,
312
+ '[context] should parse func with 2 record args': `{% context Test where value: ({ }, { name: String }) -> { } %}`,
313
+ '[context] should parse func with 3 record args': `{% context Test where value: ({ }, { name: String }, { value: A[]}) -> { } %}`,
314
+ '[context] should parse func with list arg': `{% context Test where value: (String[]) -> String[] %}`,
315
+ '[context] should parse func with 2 list args': `{% context Test where value: (String[], String[]) -> String[] %}`,
316
+ '[context] should parse func with 3 list args': `{% context Test where value: (String[], String[], String[]) -> String[] %}`,
317
+ '[context] should parse func with func arg': `{% context Test where value: (String -> String) -> String %}`,
318
+ '[context] should parse func with 2 func args': `{% context Test where value: ((String -> String), (String -> String)) -> String %}`,
319
+ '[context] should parse func with 3 func args': `{% context Test where
320
+ value: ((String -> String), (String -> String), (String -> String)) -> String
321
+ %}`,
322
+ '[context] should parse func that return array of generic type': `{% context Test[A] where value: Number -> Text[A][] %}`,
323
+ '[context] should parse funct that return array of array': `{% context Test where value: String -> Number[][] %}`,
224
324
  '[context] should parse context definitions': {
225
- input: "{% context Manager[A] where\n\n name: String,\n\n table.name: Text[A],\n\n table.data.record: { name: String, table.name: Text[A], table.data.list: A[] },\n\n table.data.list: A[],\n\n table.data.list2: A[][],\n\n table.data.list3: A[][][],\n\n noArgsFunc1: -> Number,\n\n noArgsFunc0: () -> Number,\n\n noParensConsArgFunc: String -> String,\n\n noParensConsGenericArgFunc: Text[A] -> Text[A],\n\n noParensRecordArgFunc: { } -> { },\n\n noParensListArgFunc: String[] -> String[],\n\n parensConsArgFunc: (String) -> String,\n\n parensConsArg2Func: (String, String) -> String,\n\n parensConsArg3Func: (String, String, String) -> String,\n\n parensConsGenericArgFunc: (Text[A]) -> Text[A],\n\n parensConsGenericArg2Func: (Text[A], Text[A]) -> Text[A],\n\n parensConsGenericArg3Func: (Text[A], Text[A], Text[A]) -> Text[A],\n\n parensRecordArgFunc: ({ }) -> { },\n\n parensRecordArg2Func: ({ }, { name: String }) -> { },\n\n parensRecordArgFunc: ({ }, { name: String }, { value: A[]}) -> { },\n\n parensListArgFunc: (String[]) -> String[],\n\n parensListArg2Func: (String[], String[]) -> String[],\n\n parensListArg3Func: (String[], String[], String[]) -> String[],\n\n funcArgFunc1: (String -> String) -> String,\n\n funcArgFunc2: (String -> String -> String) -> String,\n\n funcArg2Func: ((String -> String), (String -> String)) -> String,\n\n funcArg3Func: ((String -> String), (String -> String), (String -> String)) -> String,\n\n funcRetGenArray: Number -> Text[A][],\n\n funcRetMultiArray: String -> Number[][]\n\n\n %} "
325
+ input: `{% context Manager[A] where
326
+
327
+ name: String,
328
+
329
+ table.name: Text[A],
330
+
331
+ table.data.record: { name: String, table.name: Text[A], table.data.list: A[] },
332
+
333
+ table.data.list: A[],
334
+
335
+ table.data.list2: A[][],
336
+
337
+ table.data.list3: A[][][],
338
+
339
+ noArgsFunc1: -> Number,
340
+
341
+ noArgsFunc0: () -> Number,
342
+
343
+ noParensConsArgFunc: String -> String,
344
+
345
+ noParensConsGenericArgFunc: Text[A] -> Text[A],
346
+
347
+ noParensRecordArgFunc: { } -> { },
348
+
349
+ noParensListArgFunc: String[] -> String[],
350
+
351
+ parensConsArgFunc: (String) -> String,
352
+
353
+ parensConsArg2Func: (String, String) -> String,
354
+
355
+ parensConsArg3Func: (String, String, String) -> String,
356
+
357
+ parensConsGenericArgFunc: (Text[A]) -> Text[A],
358
+
359
+ parensConsGenericArg2Func: (Text[A], Text[A]) -> Text[A],
360
+
361
+ parensConsGenericArg3Func: (Text[A], Text[A], Text[A]) -> Text[A],
362
+
363
+ parensRecordArgFunc: ({ }) -> { },
364
+
365
+ parensRecordArg2Func: ({ }, { name: String }) -> { },
366
+
367
+ parensRecordArgFunc: ({ }, { name: String }, { value: A[]}) -> { },
368
+
369
+ parensListArgFunc: (String[]) -> String[],
370
+
371
+ parensListArg2Func: (String[], String[]) -> String[],
372
+
373
+ parensListArg3Func: (String[], String[], String[]) -> String[],
374
+
375
+ funcArgFunc1: (String -> String) -> String,
376
+
377
+ funcArgFunc2: (String -> String -> String) -> String,
378
+
379
+ funcArg2Func: ((String -> String), (String -> String)) -> String,
380
+
381
+ funcArg3Func: ((String -> String), (String -> String), (String -> String)) -> String,
382
+
383
+ funcRetGenArray: Number -> Text[A][],
384
+
385
+ funcRetMultiArray: String -> Number[][]
386
+
387
+
388
+ %} `
226
389
  },
227
390
  '[context] should allow optional properties': {
228
- input: "{% context AContract where \n \n id?: Number,\n\n name.first: String,\n\n name.middle?: String,\n\n name.last?: String\n\n %}"
391
+ input: `{% context AContract where
392
+
393
+ id?: Number,
394
+
395
+ name.first: String,
396
+
397
+ name.middle?: String,
398
+
399
+ name.last?: String
400
+
401
+ %}`
229
402
  },
230
403
  '[context] should allow extending': {
231
- input: "{% context AContract where :BContract %}\n {% context CContract where :AContract, :BContract %}\n {% context DContract[Type] where :CContract, member: Type %}\n {% context EContract[A,B,C,D] where \n :BContract, \n :CContract, \n :DContract[D],\n member0: A,\n member1: B,\n member2: C\n %}\n {% context DContract where :AContract, member: DType %}"
232
- },
233
- '[context] should mark nested properties as optional if all are': "{% context Paper where object.\"type\"?: String %}",
234
- 'should parse type statements': "{% type Type = String | Number | Boolean | Type[] | Type -> Type %}",
235
- 'should parse tupe types': "{% type Tuple = [Number, String, Number] %}",
404
+ input: `{% context AContract where :BContract %}
405
+ {% context CContract where :AContract, :BContract %}
406
+ {% context DContract[Type] where :CContract, member: Type %}
407
+ {% context EContract[A,B,C,D] where
408
+ :BContract,
409
+ :CContract,
410
+ :DContract[D],
411
+ member0: A,
412
+ member1: B,
413
+ member2: C
414
+ %}
415
+ {% context DContract where :AContract, member: DType %}`
416
+ },
417
+ '[context] should mark nested properties as optional if all are': `{% context Paper where object."type"?: String %}`,
418
+ 'should parse type statements': `{% type Type = String | Number | Boolean | Type[] | Type -> Type %}`,
419
+ 'should parse tupe types': `{% type Tuple = [Number, String, Number] %}`,
236
420
  'should parse type assertion': '<Panel onClick={{ \e -> [*User]foo(e) }} />',
237
421
  'should parse partial application in expression': '<Link ww:text={{truncate(50)(@text)}} />',
238
- 'should transform special primitives': "<div>\n {% for kind in [\n String,\n Boolean,\n Number,\n Object,\n Undefined,\n Null,\n Void,\n Never,\n Any] %}\n {{ kind | text }}\n {% endfor %}\n </div>",
239
- 'should allow casting': "\n {% view Test (Object) %}\n <Widget\n val1={{String(@value)}}\n val2={{Number(@value)}}\n val3={{Boolean(@value)}} />\n ",
240
- 'should parse null query operator': "<div>{% if value ?? %}<b>True</b>{% else %}<b>False</b>{% endif %}</div>",
241
- '[let] should parse let statements': "{% let head:HeadCtx = {title = \"Foo\"} %}\n {% let head2:HeadCtx = {title = \"My Title\"} %}\n ",
242
- '[let] should be usable in a view': "\n {% view MyView(Object) %}\n {% let head:HeadViewContext = {title = \"My Title\"} %}\n <h1>{{<HeadView(head)>}}</h1>\n ",
243
- '[comment] should parse html comments': "<!-- This is an html comment. -->",
244
- '[comment] should parse wml comments': "{# This is a wml comment #}",
245
- '[comment] should parse wml comments in statements': "{% view Name {# This is a comment! #} (Object) %} <div/> %}",
246
- '[fun] should parse multi dimensional array parameters': "\n {% fun test (value:List[][]) %}<p/>{% endfun %}",
247
- 'should allow index access on context properties': "{% view Test (Object) %}\n <div>\n {% if @[\"type\"]?? %}\n <div/>\n {% endif %}\n </div>",
248
- 'should allow paths to use brackets': "\n {% view Test (Object) %} \n <div>\n {% if @values.controls[\"@type\"] %} value {% endif %}\n {% if @values.controls[\"@type\"].value %} value {% endif %}\n </div>"
422
+ 'should transform special primitives': `<div>
423
+ {% for kind in [
424
+ String,
425
+ Boolean,
426
+ Number,
427
+ Object,
428
+ Undefined,
429
+ Null,
430
+ Void,
431
+ Never,
432
+ Any] %}
433
+ {{ kind | text }}
434
+ {% endfor %}
435
+ </div>`,
436
+ 'should allow casting': `
437
+ {% view Test (Object) %}
438
+ <Widget
439
+ val1={{String(@value)}}
440
+ val2={{Number(@value)}}
441
+ val3={{Boolean(@value)}} />
442
+ `,
443
+ 'should parse null query operator': `<div>{% if value ?? %}<b>True</b>{% else %}<b>False</b>{% endif %}</div>`,
444
+ '[let] should parse let statements': `{% let head:HeadCtx = {title = "Foo"} %}
445
+ {% let head2:HeadCtx = {title = "My Title"} %}
446
+ `,
447
+ '[let] should be usable in a view': `
448
+ {% view MyView(Object) %}
449
+ {% let head:HeadViewContext = {title = "My Title"} %}
450
+ <h1>{{<HeadView(head)>}}</h1>
451
+ `,
452
+ '[comment] should parse html comments': `<!-- This is an html comment. -->`,
453
+ '[comment] should parse wml comments': `{# This is a wml comment #}`,
454
+ '[comment] should parse wml comments in statements': `{% view Name {# This is a comment! #} (Object) %} <div/> %}`,
455
+ '[fun] should parse multi dimensional array parameters': `
456
+ {% fun test (value:List[][]) %}<p/>{% endfun %}`,
457
+ 'should allow index access on context properties': `{% view Test (Object) %}
458
+ <div>
459
+ {% if @["type"]?? %}
460
+ <div/>
461
+ {% endif %}
462
+ </div>`,
463
+ 'should allow paths to use brackets': `
464
+ {% view Test (Object) %}
465
+ <div>
466
+ {% if @values.controls["@type"] %} value {% endif %}
467
+ {% if @values.controls["@type"].value %} value {% endif %}
468
+ </div>`,
469
+ 'should allow 2nd level bracket access': `<div>{% for item in our."items" %} <div/>{% endfor %}</div> `,
470
+ 'should allow type to be used in if statement expression': `<div>{% if item."type" == 1 %}<p/>{% endif %}</div>`,
471
+ 'should support the special wml:attrs attribute': `<Panel wml:attrs={{@panelAttrs}}><div wml:attrs={{divAttrs}}/></Panel>`
249
472
  };
250
473
  //# sourceMappingURL=test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAA2B;IAEzC,+BAA+B,EAAE;QAC7B,KAAK,EAAE,6CAA2C;KACrD;IACD,2BAA2B,EAAE;QACzB,KAAK,EAAE,uCAAqC;KAC/C;IACD,uCAAuC,EAAE;QACrC,KAAK,EAAE,yDAAqD;KAC/D;IACD,iCAAiC,EAAE;QAC/B,KAAK,EAAE,WAAW;KACrB;IACD,mDAAmD,EAAE;QACjD,KAAK,EAAE,6DAA6D;KACvE;IACD,mDAAmD,EAAE;QACjD,KAAK,EAAE,4BAA4B;KACtC;IACD,mDAAmD,EAAE;QACjD,KAAK,EAAE,8CAA8C;KACxD;IACD,2BAA2B,EAAE;QACzB,KAAK,EAAE,uCAAuC;KACjD;IACD,2CAA2C,EAAE;QACzC,KAAK,EAAE,wDAAwD;KAClE;IACD,8CAA8C,EAAE;QAC5C,KAAK,EAAE,oEAAoE;KAC9E;IACD,iDAAiD,EAAE;QAC/C,KAAK,EAAE,wBAAwB;KAClC;IACD,iDAAiD,EAAE;QAC/C,KAAK,EAAE,uDAAuD;YAC1D,gCAAgC;KACvC;IACD,iDAAiD,EAAE;QAC/C,KAAK,EAAE,8CAA8C;YACjD,gCAAgC;KACvC;IACD,+BAA+B,EAAE;QAE7B,KAAK,EAAE,oCAAoC;YACvC,uC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kD;IAEtD,8BAA8B,EAC1B,qEAAqE;IAEzE,yBAAyB,EAAE,6CAA6C;IAExE,6BAA6B,EACzB,6CAA6C;IAEjD,gDAAgD,EAC5C,0CAA0C;IAE9C,qCAAqC,EACjC;;;;;;;;;;;;;eAaO;IAEX,sBAAsB,EAAE;;;;;;OAMrB;IAEH,kCAAkC,EAC9B,0EAA0E;IAE9E,mCAAmC,EAC/B;;KAEH;IAED,kCAAkC,EAAE;;;;KAInC;IAED,sCAAsC,EAAE,mCAAmC;IAE3E,qCAAqC,EAAE,6BAA6B;IAEpE,mDAAmD,EAC/C,6DAA6D;IAEjE,uDAAuD,EAAE;oDACT;IAEhD,iDAAiD,EAC7C;;;;;aAKK;IAET,oCAAoC,EAAE;;;;;WAK/B;IAEP,uCAAuC,EACnC,8DAA8D;IAElE,yDAAyD,EACrD,qDAAqD;IAE3D,gDAAgD,EAChD,wEAAwE;CAEzE,CAAA"}
package/lib/parse/test.ts CHANGED
@@ -648,6 +648,15 @@ export const tests: { [key: string]: any } = {
648
648
  <div>
649
649
  {% if @values.controls["@type"] %} value {% endif %}
650
650
  {% if @values.controls["@type"].value %} value {% endif %}
651
- </div>`
651
+ </div>`,
652
+
653
+ 'should allow 2nd level bracket access':
654
+ `<div>{% for item in our."items" %} <div/>{% endfor %}</div> `,
655
+
656
+ 'should allow type to be used in if statement expression':
657
+ `<div>{% if item."type" == 1 %}<p/>{% endif %}</div>`,
658
+
659
+ 'should support the special wml:attrs attribute':
660
+ `<Panel wml:attrs={{@panelAttrs}}><div wml:attrs={{divAttrs}}/></Panel>`
652
661
 
653
662
  }
package/lib/parse/wml.y CHANGED
@@ -373,15 +373,18 @@ view_statement
373
373
  ;
374
374
 
375
375
  view_statement_context
376
- : type
376
+ : constructor_type
377
377
  { $$ = $1; }
378
378
 
379
- | unqualified_constructor FROM string_literal
380
- {$$ = new yy.ast.ImportStatement(new yy.ast.CompositeMember([$1],@$),
381
- $3, @$);
382
- }
379
+ | context_from_statement
380
+ {$$ = $1; }
383
381
  ;
384
382
 
383
+ context_from_statement
384
+ : constructor_type FROM string_literal
385
+ {$$ = new yy.ast.ContextFromStatement($1, $3, @$); }
386
+ ;
387
+
385
388
  view_directives
386
389
  : let_statement
387
390
  { $$ = [$1]; }
@@ -456,7 +459,7 @@ non_function_type
456
459
 
457
460
  | record_type
458
461
  { $$ = $1; }
459
-
462
+
460
463
  | list_type
461
464
  { $$ = $1; }
462
465
 
@@ -465,11 +468,17 @@ non_function_type
465
468
  ;
466
469
 
467
470
  constructor_type
468
- : cons
471
+ : unqualified_constructor
472
+ { $$ = new yy.ast.ConstructorType($1, [], @$); }
473
+
474
+ | unqualified_constructor type_parameters
475
+ { $$ = new yy.ast.ConstructorType($1, $2, @$); }
476
+
477
+ | qualified_constructor
469
478
  { $$ = new yy.ast.ConstructorType($1, [], @$); }
470
479
 
471
- | cons type_parameters
472
- { $$ = new yy.ast.ConstructorType($1, $2, @$); }
480
+ | qualified_constructor type_parameters
481
+ { $$ = new yy.ast.ConstructorType($1, $2, @$); }
473
482
  ;
474
483
 
475
484
  record_type
@@ -482,11 +491,11 @@ record_type
482
491
  ;
483
492
 
484
493
  list_type
485
- : cons '[' ']'
494
+ : unqualified_constructor '[' ']'
486
495
  { $$ = new yy.ast.ListType(
487
496
  new yy.ast.ConstructorType($1, []), @$); }
488
497
 
489
- | cons type_parameters '[' ']'
498
+ | unqualified_constructor type_parameters '[' ']'
490
499
  { $$ = new yy.ast.ListType(
491
500
  new yy.ast.ConstructorType($1, $2), @$); }
492
501
 
@@ -834,8 +843,8 @@ simple_expression
834
843
  |member_expression
835
844
  |literal
836
845
  |context_property
837
- |cons
838
- |identifier
846
+ |unqualified_constructor
847
+ |unqualified_identifier
839
848
  |context_variable)
840
849
  { $$ = $1; }
841
850
  ;
@@ -862,24 +871,24 @@ type_arg_list
862
871
  ;
863
872
 
864
873
  construct_expression
865
- : cons '(' arguments ')'
874
+ : unqualified_constructor '(' arguments ')'
866
875
  { $$ = new yy.ast.ConstructExpression($1, $3, @$); }
867
876
 
868
- | cons '(' ')'
877
+ | unqualified_constructor '(' ')'
869
878
  { $$ = new yy.ast.ConstructExpression($1, [], @$); }
870
879
  ;
871
880
 
872
881
  call_expression
873
- : identifier type_arguments '(' arguments ')'
882
+ : unqualified_identifier type_arguments '(' arguments ')'
874
883
  {$$ = new yy.ast.CallExpression($1, $2, $4, @$); }
875
884
 
876
- | identifier type_arguments '(' ')'
885
+ | unqualified_identifier type_arguments '(' ')'
877
886
  {$$ = new yy.ast.CallExpression($1, $2, [], @$); }
878
887
 
879
- | identifier '(' arguments ')'
888
+ | unqualified_identifier '(' arguments ')'
880
889
  {$$ = new yy.ast.CallExpression($1, [], $3, @$); }
881
890
 
882
- | identifier '(' ')'
891
+ | unqualified_identifier '(' ')'
883
892
  {$$ = new yy.ast.CallExpression($1, [], [], @$); }
884
893
 
885
894
  | context_property type_arguments '(' arguments ')'
@@ -926,43 +935,34 @@ call_expression
926
935
  ;
927
936
 
928
937
  member_expression
929
-
930
- : qualified_identifier '.' unqualified_identifier
931
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
932
-
933
- | qualified_constructor '.' unqualified_identifier
938
+ : member_expression_head '.' member_expression_tail
934
939
  {$$ = new yy.ast.MemberExpression($1, $3, @$); }
935
940
 
936
- | context_variable '.' unqualified_identifier
941
+ | member_expression '.' member_expression_tail
937
942
  {$$ = new yy.ast.MemberExpression($1, $3, @$); }
938
943
 
939
- | context_property '.' unqualified_identifier
940
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
941
-
942
- | list '.' unqualified_identifier
943
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
944
-
945
- | record '.' unqualified_identifier
946
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
947
-
948
- | string_literal '.' unqualified_identifier
949
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
950
-
951
- | call_expression '.' unqualified_identifier
944
+ | member_expression '[' string_literal ']'
952
945
  {$$ = new yy.ast.MemberExpression($1, $3, @$); }
946
+ ;
953
947
 
954
- |'(' expression ')' '.' unqualified_identifier
955
- {$$ = new yy.ast.MemberExpression($2, $5, @$); }
956
-
957
- | member_expression '.' unqualified_identifier
958
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
948
+ member_expression_head:
949
+ ( unqualified_identifier
950
+ | unqualified_constructor
951
+ | context_variable
952
+ | context_property
953
+ | list
954
+ | record
955
+ | string_literal
956
+ | call_expression
957
+ |'(' expression ')'
958
+ )
959
+ ;
959
960
 
960
- | member_expression '[' string_literal ']'
961
- {$$ = new yy.ast.MemberExpression($1, $3, @$); }
961
+ member_expression_tail
962
+ : (unqualified_identifier| unqualified_constructor|string_literal)
962
963
  ;
963
964
 
964
965
  function_expression
965
-
966
966
  : parameters '->' expression
967
967
  {$$ = new yy.ast.FunctionExpression($1, $3, @$); }
968
968