@weborigami/language 0.2.12 → 0.3.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.
@@ -364,6 +364,15 @@ export function makeProperty(key, value) {
364
364
  return [key, modified];
365
365
  }
366
366
 
367
+ export function makeJsPropertyAccess(expression, property) {
368
+ const location = {
369
+ source: expression.location.source,
370
+ start: expression.location.start,
371
+ end: property.location.end,
372
+ };
373
+ return annotate([expression, property], location);
374
+ }
375
+
367
376
  export function makeReference(identifier) {
368
377
  // We can't know for sure that an identifier is a builtin reference until we
369
378
  // see whether it's being called as a function.
@@ -8,7 +8,7 @@
8
8
  import {
9
9
  ObjectTree,
10
10
  Tree,
11
- concatTrees,
11
+ deepText,
12
12
  isUnpackable,
13
13
  scope as scopeFn,
14
14
  symbols,
@@ -533,7 +533,7 @@ addOpLabel(subtraction, "«ops.subtraction»");
533
533
  * Apply the default tagged template function.
534
534
  */
535
535
  export async function template(strings, ...values) {
536
- return concatTrees(strings, ...values);
536
+ return deepText(strings, ...values);
537
537
  }
538
538
  addOpLabel(template, "«ops.template»");
539
539
 
@@ -236,6 +236,24 @@ describe("Origami parser", () => {
236
236
  ]);
237
237
  });
238
238
 
239
+ test("callExpression using property acccess", () => {
240
+ assertParse("callExpression", "(foo).bar", [
241
+ ops.traverse,
242
+ [ops.scope, "foo"],
243
+ [ops.literal, "bar"],
244
+ ]);
245
+ assertParse("callExpression", "(foo).bar.baz", [
246
+ ops.traverse,
247
+ [ops.traverse, [ops.scope, "foo"], [ops.literal, "bar"]],
248
+ [ops.literal, "baz"],
249
+ ]);
250
+ assertParse("callExpression", "foo[bar]", [
251
+ ops.traverse,
252
+ [ops.scope, "foo/"],
253
+ [ops.scope, "bar"],
254
+ ]);
255
+ });
256
+
239
257
  test("commaExpression", () => {
240
258
  assertParse("commaExpression", "1", [ops.literal, 1]);
241
259
  assertParse("commaExpression", "a, b, c", [
@@ -567,6 +585,26 @@ Body`,
567
585
  ]);
568
586
  });
569
587
 
588
+ test("jsIdentifier", () => {
589
+ assertParse("jsIdentifier", "foo", "foo", false);
590
+ assertParse("jsIdentifier", "$Δelta", "$Δelta", false);
591
+ assertThrows(
592
+ "jsIdentifier",
593
+ "1stCharacterIsNumber",
594
+ "Expected JavaScript identifier start"
595
+ );
596
+ assertThrows(
597
+ "jsIdentifier",
598
+ "has space",
599
+ "Expected JavaScript identifier continuation"
600
+ );
601
+ assertThrows(
602
+ "jsIdentifier",
603
+ "foo.bar",
604
+ "Expected JavaScript identifier continuation"
605
+ );
606
+ });
607
+
570
608
  test("list", () => {
571
609
  assertParse("list", "1", [[ops.literal, 1]]);
572
610
  assertParse("list", "1,2,3", [