@shapeshift-labs/frontier-lang-parser 0.3.54 → 0.3.55
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/action-body.js
CHANGED
|
@@ -92,6 +92,7 @@ function parseActionRepeatBlock(header, body, index, state) {
|
|
|
92
92
|
const details = readActionRepeatHeader(header, index);
|
|
93
93
|
return compactRecord({
|
|
94
94
|
kind: 'repeat',
|
|
95
|
+
repeatKind: 'times',
|
|
95
96
|
id: details.id,
|
|
96
97
|
name: details.name,
|
|
97
98
|
indexName: details.indexName,
|
|
@@ -21,8 +21,7 @@ export function readRepeatHeaderBlock(source, offset, endOffset, helpers = {}) {
|
|
|
21
21
|
export function readActionRepeatHeader(header, index) {
|
|
22
22
|
const rawText = rawHeader(header, 'repeat');
|
|
23
23
|
const hasExplicitId = hasId(rawText);
|
|
24
|
-
const
|
|
25
|
-
const shape = /^([A-Za-z_$][\w$-]*)\s+times\s+(.+)$/.exec(text);
|
|
24
|
+
const shape = /^([A-Za-z_$][\w$-]*)\s+@id\(\s*["'][^"']+["']\s*\)\s+times\s+(.+)$/.exec(rawText);
|
|
26
25
|
const indexName = shape?.[1];
|
|
27
26
|
const countText = shape?.[2]?.trim();
|
|
28
27
|
const count = countText ? readActionValue(countText) : undefined;
|
|
@@ -41,7 +40,11 @@ export function validateActionRepeatHeader(header) {
|
|
|
41
40
|
const details = readActionRepeatHeader(header, 0);
|
|
42
41
|
const stripped = stripIds(rawHeader(header, 'repeat'));
|
|
43
42
|
if (details.malformed && /^times\b/.test(stripped)) return { ok: false, reason: 'missing-action-repeat-index' };
|
|
43
|
+
if (details.malformed && /\btimes\s*$/.test(stripped)) return { ok: false, reason: 'missing-action-repeat-count' };
|
|
44
44
|
if (details.malformed && !/\btimes\b/.test(stripped)) return { ok: false, reason: 'missing-action-repeat-count' };
|
|
45
|
+
if (details.malformed && !details.hasExplicitId && /^[A-Za-z_$][\w$-]*\s+times\s+.+$/.test(stripped)) {
|
|
46
|
+
return { ok: false, reason: 'missing-action-repeat-id' };
|
|
47
|
+
}
|
|
45
48
|
if (details.malformed) return { ok: false, reason: 'malformed-action-repeat-header' };
|
|
46
49
|
if (!details.indexName) return { ok: false, reason: 'missing-action-repeat-index' };
|
|
47
50
|
if (!isActionBindingName(details.indexName) || details.indexName === 'times') return { ok: false, reason: 'unsupported-action-repeat-index' };
|
|
@@ -56,7 +59,7 @@ export function validateActionRepeatHeader(header) {
|
|
|
56
59
|
|
|
57
60
|
function isSupportedCountExpression(value) {
|
|
58
61
|
if (Object.hasOwn(value ?? {}, 'value')) {
|
|
59
|
-
return typeof value.value === 'number' && Number.
|
|
62
|
+
return typeof value.value === 'number' && Number.isInteger(value.value) && value.value >= 0;
|
|
60
63
|
}
|
|
61
64
|
const ast = value?.expressionAst;
|
|
62
65
|
return ast?.kind === 'ref'
|