@malloydata/malloy-tag 0.0.349 → 0.0.351
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/dist/parser.js +1 -69
- package/dist/parser.js.map +1 -1
- package/package.json +5 -4
- package/src/parser.ts +2 -81
package/dist/parser.js
CHANGED
|
@@ -32,81 +32,13 @@ function mapMOTLYError(error) {
|
|
|
32
32
|
offset: error.begin.column,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Parse a reference string like "$^^path.to[0].thing" back into
|
|
37
|
-
* structured form {ups, refPath}.
|
|
38
|
-
*/
|
|
39
|
-
function parseRefString(linkTo) {
|
|
40
|
-
let i = 1;
|
|
41
|
-
let ups = 0;
|
|
42
|
-
while (i < linkTo.length && linkTo[i] === '^') {
|
|
43
|
-
ups++;
|
|
44
|
-
i++;
|
|
45
|
-
}
|
|
46
|
-
const refPath = [];
|
|
47
|
-
const rest = linkTo.slice(i);
|
|
48
|
-
if (rest.length === 0) {
|
|
49
|
-
return { ups, refPath };
|
|
50
|
-
}
|
|
51
|
-
let pos = 0;
|
|
52
|
-
let needDot = false;
|
|
53
|
-
while (pos < rest.length) {
|
|
54
|
-
if (rest[pos] === '.') {
|
|
55
|
-
pos++;
|
|
56
|
-
needDot = false;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
if (rest[pos] === '[') {
|
|
60
|
-
const close = rest.indexOf(']', pos);
|
|
61
|
-
refPath.push(Number(rest.slice(pos + 1, close)));
|
|
62
|
-
pos = close + 1;
|
|
63
|
-
needDot = true;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (needDot) {
|
|
67
|
-
// Expected a dot separator but didn't get one
|
|
68
|
-
}
|
|
69
|
-
if (rest[pos] === '`') {
|
|
70
|
-
pos++;
|
|
71
|
-
let seg = '';
|
|
72
|
-
while (pos < rest.length && rest[pos] !== '`') {
|
|
73
|
-
if (rest[pos] === '\\') {
|
|
74
|
-
pos++;
|
|
75
|
-
seg += rest[pos];
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
seg += rest[pos];
|
|
79
|
-
}
|
|
80
|
-
pos++;
|
|
81
|
-
}
|
|
82
|
-
pos++;
|
|
83
|
-
refPath.push(seg);
|
|
84
|
-
needDot = true;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
let seg = '';
|
|
88
|
-
while (pos < rest.length &&
|
|
89
|
-
rest[pos] !== '.' &&
|
|
90
|
-
rest[pos] !== '[' &&
|
|
91
|
-
rest[pos] !== '`') {
|
|
92
|
-
seg += rest[pos];
|
|
93
|
-
pos++;
|
|
94
|
-
}
|
|
95
|
-
if (seg.length > 0) {
|
|
96
|
-
refPath.push(seg);
|
|
97
|
-
needDot = true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return { ups, refPath };
|
|
101
|
-
}
|
|
102
35
|
/**
|
|
103
36
|
* Convert a MOTLYPropertyValue (node or ref) into a Tag tree with parent links.
|
|
104
37
|
* Env references (@env.NAME) are resolved from process.env during hydration.
|
|
105
38
|
*/
|
|
106
39
|
function hydrate(pv, parent) {
|
|
107
40
|
if ((0, motly_ts_parser_1.isRef)(pv)) {
|
|
108
|
-
|
|
109
|
-
return new tags_1.RefTag(ups, refPath, parent);
|
|
41
|
+
return new tags_1.RefTag(pv.linkUps, pv.linkTo, parent);
|
|
110
42
|
}
|
|
111
43
|
const tag = new tags_1.Tag({}, parent);
|
|
112
44
|
if (pv.eq !== undefined) {
|
package/dist/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA4GH,4BAcC;AAvHD,iEAA0E;AAC1E,iCAAmC;AAGnC;;GAEG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"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "jest --config=../../jest.config.js",
|
|
25
|
-
"clean": "rm -rf dist && tsc --build --clean && rm -f tsconfig.tsbuildinfo && rimraf @flowtyped",
|
|
25
|
+
"clean": "rm -rf dist && tsc --build --clean && rm -f tsconfig.tsbuildinfo && node ../../scripts/femto-build.js --clean && rimraf @flowtyped",
|
|
26
|
+
"dev": "tsc --build",
|
|
26
27
|
"build": "tsc --build && npm run generate-flow",
|
|
27
28
|
"prepublishOnly": "npm run clean && npm run build",
|
|
28
|
-
"generate-flow": "
|
|
29
|
+
"generate-flow": "node ../../scripts/femto-build.js flow"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@malloydata/motly-ts-parser": "^0.
|
|
32
|
+
"@malloydata/motly-ts-parser": "^0.4.0",
|
|
32
33
|
"assert": "^2.0.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
package/src/parser.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type {MOTLYError, MOTLYPropertyValue} from '@malloydata/motly-ts-parser';
|
|
7
7
|
import {MOTLYSession, isRef, isEnvRef} from '@malloydata/motly-ts-parser';
|
|
8
8
|
import {Tag, RefTag} from './tags';
|
|
9
|
-
import type {TagParse, TagError
|
|
9
|
+
import type {TagParse, TagError} from './tags';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Strip the Malloy tag prefix (e.g., "# " or "#(docs) ") from source.
|
|
@@ -34,92 +34,13 @@ function mapMOTLYError(error: MOTLYError): TagError {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
/**
|
|
38
|
-
* Parse a reference string like "$^^path.to[0].thing" back into
|
|
39
|
-
* structured form {ups, refPath}.
|
|
40
|
-
*/
|
|
41
|
-
function parseRefString(linkTo: string): {ups: number; refPath: Path} {
|
|
42
|
-
let i = 1;
|
|
43
|
-
let ups = 0;
|
|
44
|
-
while (i < linkTo.length && linkTo[i] === '^') {
|
|
45
|
-
ups++;
|
|
46
|
-
i++;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const refPath: Path = [];
|
|
50
|
-
const rest = linkTo.slice(i);
|
|
51
|
-
|
|
52
|
-
if (rest.length === 0) {
|
|
53
|
-
return {ups, refPath};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
let pos = 0;
|
|
57
|
-
let needDot = false;
|
|
58
|
-
|
|
59
|
-
while (pos < rest.length) {
|
|
60
|
-
if (rest[pos] === '.') {
|
|
61
|
-
pos++;
|
|
62
|
-
needDot = false;
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (rest[pos] === '[') {
|
|
67
|
-
const close = rest.indexOf(']', pos);
|
|
68
|
-
refPath.push(Number(rest.slice(pos + 1, close)));
|
|
69
|
-
pos = close + 1;
|
|
70
|
-
needDot = true;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (needDot) {
|
|
75
|
-
// Expected a dot separator but didn't get one
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (rest[pos] === '`') {
|
|
79
|
-
pos++;
|
|
80
|
-
let seg = '';
|
|
81
|
-
while (pos < rest.length && rest[pos] !== '`') {
|
|
82
|
-
if (rest[pos] === '\\') {
|
|
83
|
-
pos++;
|
|
84
|
-
seg += rest[pos];
|
|
85
|
-
} else {
|
|
86
|
-
seg += rest[pos];
|
|
87
|
-
}
|
|
88
|
-
pos++;
|
|
89
|
-
}
|
|
90
|
-
pos++;
|
|
91
|
-
refPath.push(seg);
|
|
92
|
-
needDot = true;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
let seg = '';
|
|
97
|
-
while (
|
|
98
|
-
pos < rest.length &&
|
|
99
|
-
rest[pos] !== '.' &&
|
|
100
|
-
rest[pos] !== '[' &&
|
|
101
|
-
rest[pos] !== '`'
|
|
102
|
-
) {
|
|
103
|
-
seg += rest[pos];
|
|
104
|
-
pos++;
|
|
105
|
-
}
|
|
106
|
-
if (seg.length > 0) {
|
|
107
|
-
refPath.push(seg);
|
|
108
|
-
needDot = true;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return {ups, refPath};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
37
|
/**
|
|
116
38
|
* Convert a MOTLYPropertyValue (node or ref) into a Tag tree with parent links.
|
|
117
39
|
* Env references (@env.NAME) are resolved from process.env during hydration.
|
|
118
40
|
*/
|
|
119
41
|
function hydrate(pv: MOTLYPropertyValue, parent?: Tag): Tag {
|
|
120
42
|
if (isRef(pv)) {
|
|
121
|
-
|
|
122
|
-
return new RefTag(ups, refPath, parent);
|
|
43
|
+
return new RefTag(pv.linkUps, pv.linkTo, parent);
|
|
123
44
|
}
|
|
124
45
|
|
|
125
46
|
const tag = new Tag({}, parent);
|