@weborigami/language 0.5.2-test.1 → 0.5.3
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.
- package/index.ts +1 -6
- package/package.json +3 -3
- package/src/compiler/origami.pegjs +33 -25
- package/src/compiler/parse.js +585 -454
- package/src/compiler/parserHelpers.js +5 -1
- package/src/runtime/HandleExtensionsTransform.js +1 -1
- package/src/runtime/jsGlobals.js +63 -4
- package/src/runtime/ops.js +22 -0
- package/test/compiler/parse.test.js +67 -37
- package/test/runtime/jsGlobals.test.js +23 -0
- package/test/runtime/ops.test.js +17 -0
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnpackFunction } from "@weborigami/async-tree";
|
|
2
2
|
|
|
3
3
|
export * from "./main.js";
|
|
4
4
|
|
|
@@ -64,8 +64,3 @@ export type Source = {
|
|
|
64
64
|
text: string;
|
|
65
65
|
url?: URL;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A function that converts a value from a persistent form into a live value.
|
|
70
|
-
*/
|
|
71
|
-
export type UnpackFunction = (input: Packed, options?: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/language",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Web Origami expression language compiler and runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./main.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"typescript": "5.9.2"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@weborigami/async-tree": "0.5.
|
|
15
|
-
"@weborigami/types": "0.5.
|
|
14
|
+
"@weborigami/async-tree": "0.5.3",
|
|
15
|
+
"@weborigami/types": "0.5.3",
|
|
16
16
|
"watcher": "2.3.1",
|
|
17
17
|
"yaml": "2.8.1"
|
|
18
18
|
},
|
|
@@ -106,7 +106,7 @@ arrayEntry
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
arrowFunction
|
|
109
|
-
= "(" __ parameters:parameterList? __ ")" __ doubleArrow __ pipeline:expectPipelineExpression {
|
|
109
|
+
= ("async" __)? "(" __ parameters:parameterList? __ ")" __ doubleArrow __ pipeline:expectPipelineExpression {
|
|
110
110
|
const lambdaParameters = parameters ?? annotate([], location());
|
|
111
111
|
return annotate([ops.lambda, lambdaParameters, pipeline], location());
|
|
112
112
|
}
|
|
@@ -417,21 +417,21 @@ keyChar
|
|
|
417
417
|
= keyCharStart
|
|
418
418
|
// Also allow some math operators (not slash)
|
|
419
419
|
/ "!"
|
|
420
|
-
/ "+"
|
|
421
|
-
/ minus
|
|
422
|
-
/ "*"
|
|
423
420
|
/ "%"
|
|
424
421
|
/ "&"
|
|
425
|
-
/ "
|
|
422
|
+
/ "*"
|
|
423
|
+
/ "+"
|
|
426
424
|
/ "^"
|
|
425
|
+
/ "|"
|
|
426
|
+
/ minus
|
|
427
427
|
|
|
428
428
|
// First character in a key
|
|
429
429
|
keyCharStart
|
|
430
430
|
// All JS identifier characters
|
|
431
431
|
= char:. &{ return char.match(/[$_\p{ID_Continue}]/u) }
|
|
432
432
|
/ "."
|
|
433
|
-
/ "~"
|
|
434
433
|
/ "@"
|
|
434
|
+
/ "~"
|
|
435
435
|
|
|
436
436
|
// A separated list of values
|
|
437
437
|
list "list"
|
|
@@ -549,23 +549,24 @@ objectProperty "object property"
|
|
|
549
549
|
|
|
550
550
|
// A shorthand reference inside an object literal: `foo`
|
|
551
551
|
objectShorthandProperty "object identifier"
|
|
552
|
-
=
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
552
|
+
= path:pathLiteral {
|
|
553
|
+
const lastKey = path[0] === ops.unpack
|
|
554
|
+
// [ops.unpack, [markers.traverse, [markers.reference, lastKey]]]
|
|
555
|
+
? path[1][1][1]
|
|
556
|
+
// [markers.traverse, ..., [markers.reference, lastKey]
|
|
557
|
+
: path.at(-1)[1];
|
|
558
|
+
return annotate([lastKey, path], location());
|
|
556
559
|
}
|
|
557
560
|
/ path:angleBracketLiteral {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
lastKey
|
|
561
|
+
// [markers.traverse, ..., [markers.reference, lastKey]]
|
|
562
|
+
const lastKey = path.at(-1)[1];
|
|
563
|
+
return annotate([lastKey, path], location());
|
|
561
564
|
}
|
|
562
|
-
return annotate([lastKey, path], location());
|
|
563
|
-
}
|
|
564
565
|
|
|
565
566
|
objectPublicKey
|
|
566
567
|
= key:key slash:"/"? {
|
|
567
|
-
|
|
568
|
-
|
|
568
|
+
return text();
|
|
569
|
+
}
|
|
569
570
|
/ string:stringLiteral {
|
|
570
571
|
// Remove `ops.literal` from the string code
|
|
571
572
|
return string[1];
|
|
@@ -573,8 +574,8 @@ objectPublicKey
|
|
|
573
574
|
|
|
574
575
|
optionalChaining
|
|
575
576
|
= __ "?." __ property:identifier {
|
|
576
|
-
|
|
577
|
-
|
|
577
|
+
return annotate([ops.optionalTraverse, property], location());
|
|
578
|
+
}
|
|
578
579
|
|
|
579
580
|
// Name of a unction parameter
|
|
580
581
|
parameter
|
|
@@ -838,6 +839,15 @@ unaryExpression
|
|
|
838
839
|
}
|
|
839
840
|
/ callExpression
|
|
840
841
|
|
|
842
|
+
unaryOperator
|
|
843
|
+
= "!"
|
|
844
|
+
/ "+"
|
|
845
|
+
/ @"~" ![\/\)\]\}] // don't match `~/` or end of term
|
|
846
|
+
/ minus
|
|
847
|
+
/ @"await" &whitespaceOrParenthesis
|
|
848
|
+
/ @"typeof" &whitespaceOrParenthesis
|
|
849
|
+
/ @"void" &whitespaceOrParenthesis
|
|
850
|
+
|
|
841
851
|
// URI
|
|
842
852
|
uri
|
|
843
853
|
// Double slashes after colon: `https://example.com/index.html`
|
|
@@ -887,12 +897,6 @@ uriScheme
|
|
|
887
897
|
return annotate([markers.global, text()], location());
|
|
888
898
|
}
|
|
889
899
|
|
|
890
|
-
unaryOperator
|
|
891
|
-
= "!"
|
|
892
|
-
/ "+"
|
|
893
|
-
/ @"~" ![\/\)\]\}] // don't match `~/` or end of term
|
|
894
|
-
/ minus
|
|
895
|
-
|
|
896
900
|
whitespace
|
|
897
901
|
= (whitespaceChar / comment)+
|
|
898
902
|
|
|
@@ -907,5 +911,9 @@ whitespaceOptionalForProgram
|
|
|
907
911
|
= programMode __
|
|
908
912
|
/ shellMode
|
|
909
913
|
|
|
914
|
+
whitespaceOrParenthesis
|
|
915
|
+
= whitespace
|
|
916
|
+
/ "("
|
|
917
|
+
|
|
910
918
|
whitespaceWithNewLine
|
|
911
919
|
= inlineSpace* comment? newLine __
|