@vesk/compiler 0.2.95 → 0.2.97
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/ir-generator.js +7 -7
- package/dist/parser.d.ts +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +6 -4
- package/package.json +2 -2
package/dist/ir-generator.js
CHANGED
|
@@ -710,7 +710,7 @@ function assertNoVskNamespaceValue(source, expr) {
|
|
|
710
710
|
if (!hit)
|
|
711
711
|
return;
|
|
712
712
|
const { line, column } = offsetToLineCol(source, hit.start ?? 0);
|
|
713
|
-
throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column,
|
|
713
|
+
throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, frame: codeFrame(source, line, column), form: 'value' });
|
|
714
714
|
}
|
|
715
715
|
function findNamespaceValueUse(node, locals) {
|
|
716
716
|
if (!node || typeof node !== 'object')
|
|
@@ -1526,7 +1526,7 @@ function processJSXElement(source, element) {
|
|
|
1526
1526
|
// A `.vsk` module's exports are flat component names, so there is no
|
|
1527
1527
|
// nested namespace object to walk into.
|
|
1528
1528
|
const { line, column } = offsetToLineCol(source, nameNode.start ?? 0);
|
|
1529
|
-
throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column,
|
|
1529
|
+
throw VeskError.vskNamespaceMember({ file: currentSourceFile, line, column, frame: codeFrame(source, line, column), form: 'nested' });
|
|
1530
1530
|
}
|
|
1531
1531
|
const { props, spreadProps, slots } = extractProps(source, element);
|
|
1532
1532
|
const children = selfClosing ? [] : processJSXChildren(source, element.children || []);
|
|
@@ -1973,7 +1973,7 @@ function processStatementModeBody(source, bodyStmts, filename) {
|
|
|
1973
1973
|
file: filename || '',
|
|
1974
1974
|
line,
|
|
1975
1975
|
column,
|
|
1976
|
-
|
|
1976
|
+
frame: codeFrame(source, line, column),
|
|
1977
1977
|
});
|
|
1978
1978
|
}
|
|
1979
1979
|
// Pure JSX block: unwrap the children directly.
|
|
@@ -2074,7 +2074,7 @@ function processStatementModeBody(source, bodyStmts, filename) {
|
|
|
2074
2074
|
}
|
|
2075
2075
|
else if (stmt.type === 'ClassDeclaration') {
|
|
2076
2076
|
const { line, column } = offsetToLineCol(source, stmt.start ?? 0);
|
|
2077
|
-
throw VeskError.classDecl({ file: filename || '', line, column,
|
|
2077
|
+
throw VeskError.classDecl({ file: filename || '', line, column, frame: codeFrame(source, line, column) });
|
|
2078
2078
|
}
|
|
2079
2079
|
else if (stmt.type === 'ContinueStatement') {
|
|
2080
2080
|
// An unconditional `continue` at the top level of a loop body: everything
|
|
@@ -2564,7 +2564,7 @@ export function generateIR(ast, source, filename) {
|
|
|
2564
2564
|
}
|
|
2565
2565
|
else if (inner.type === 'ClassDeclaration') {
|
|
2566
2566
|
const { line, column } = offsetToLineCol(source, inner.start ?? 0);
|
|
2567
|
-
throw VeskError.classDecl({ file, line, column,
|
|
2567
|
+
throw VeskError.classDecl({ file, line, column, frame: codeFrame(source, line, column) });
|
|
2568
2568
|
}
|
|
2569
2569
|
else if (inner.type === 'TSEnumDeclaration') {
|
|
2570
2570
|
const code = processEnum(inner, source, exported);
|
|
@@ -2639,7 +2639,7 @@ export function generateIR(ast, source, filename) {
|
|
|
2639
2639
|
}
|
|
2640
2640
|
else if (stmt.type === 'ClassDeclaration') {
|
|
2641
2641
|
const { line, column } = offsetToLineCol(source, stmt.start ?? 0);
|
|
2642
|
-
throw VeskError.classDecl({ file, line, column,
|
|
2642
|
+
throw VeskError.classDecl({ file, line, column, frame: codeFrame(source, line, column) });
|
|
2643
2643
|
}
|
|
2644
2644
|
else {
|
|
2645
2645
|
const raw = getSource(source, stmt);
|
|
@@ -2670,7 +2670,7 @@ export function generateIR(ast, source, filename) {
|
|
|
2670
2670
|
if (!asyncNames.has(childName))
|
|
2671
2671
|
continue;
|
|
2672
2672
|
const { line, column } = offsetToLineCol(source, start >= 0 ? start : 0);
|
|
2673
|
-
throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column,
|
|
2673
|
+
throw VeskError.asyncChildInSyncParent(comp.name, childName, { file, line, column, frame: codeFrame(source, line, column) });
|
|
2674
2674
|
}
|
|
2675
2675
|
}
|
|
2676
2676
|
const autoImportable = [
|
package/dist/parser.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface VeskAnnotation {
|
|
|
39
39
|
* tokenization pass it in; when it is unavailable the scan falls back to the
|
|
40
40
|
* plain lexical skip so mid-edit source never crashes it.
|
|
41
41
|
*/
|
|
42
|
-
export declare function preprocessForClauses(source: string, delimiters?: Set<number> | null): {
|
|
42
|
+
export declare function preprocessForClauses(source: string, delimiters?: Set<number> | null, filename?: string): {
|
|
43
43
|
code: string;
|
|
44
44
|
annotations: VeskAnnotation[];
|
|
45
45
|
};
|
package/dist/parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAOtC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0BD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM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,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CA+NzE"}
|
package/dist/parser.js
CHANGED
|
@@ -39,7 +39,7 @@ function offsetToLineCol(source, offset) {
|
|
|
39
39
|
* tokenization pass it in; when it is unavailable the scan falls back to the
|
|
40
40
|
* plain lexical skip so mid-edit source never crashes it.
|
|
41
41
|
*/
|
|
42
|
-
export function preprocessForClauses(source, delimiters) {
|
|
42
|
+
export function preprocessForClauses(source, delimiters, filename = '') {
|
|
43
43
|
const annotations = [];
|
|
44
44
|
const chars = source.split('');
|
|
45
45
|
const isString = (ch) => ch === '"' || ch === "'" || ch === '`';
|
|
@@ -219,9 +219,11 @@ export function preprocessForClauses(source, delimiters) {
|
|
|
219
219
|
// through used to emit a broken reconciliation key.
|
|
220
220
|
const { line, column } = offsetToLineCol(source, start);
|
|
221
221
|
throw new VeskError(`Invalid \`; key\` clause — write the key expression after \`key\` without a colon: \`key ${expr.slice(1).trim()}\`.`, {
|
|
222
|
+
file: filename || '',
|
|
222
223
|
line,
|
|
223
224
|
column,
|
|
224
|
-
code:
|
|
225
|
+
code: 'V0411',
|
|
226
|
+
frame: codeFrame(source, line, column),
|
|
225
227
|
nextSteps: [
|
|
226
228
|
'Use `; key <expr>` (no colon), e.g. `for (const item of items; key item.id)`.',
|
|
227
229
|
'For the iteration index use `; index <name>`, e.g. `for (const item of items; key item.id; index i)`.',
|
|
@@ -526,7 +528,8 @@ export function parse(source, options = {}) {
|
|
|
526
528
|
const delimiters = sourceTokens === null
|
|
527
529
|
? null
|
|
528
530
|
: collectStringDelimiters(source, sourceTokens);
|
|
529
|
-
const
|
|
531
|
+
const filename = options.filename || '';
|
|
532
|
+
const { code, annotations } = preprocessForClauses(blankGenericArrowTypeParams(blankComments(source)), delimiters, filename);
|
|
530
533
|
// Acorn validates that every `export { X }` names a real top-level binding.
|
|
531
534
|
// A `.vsk` component is a registry entry, not a binding, so acorn rejects
|
|
532
535
|
// `export { MyComponent }`. Remove only those specifier lists — one whose
|
|
@@ -587,7 +590,6 @@ export function parse(source, options = {}) {
|
|
|
587
590
|
}
|
|
588
591
|
}
|
|
589
592
|
}
|
|
590
|
-
const filename = options.filename || '';
|
|
591
593
|
// Strip the trailing "(line:column)" acorn appends, without regex.
|
|
592
594
|
let cleanMessage = err.message;
|
|
593
595
|
const lastParen = cleanMessage.lastIndexOf('(');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.97",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk compiler — lexer, parser, semantic analysis, IR, codegen",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@sveltejs/acorn-typescript": "^1.0.0",
|
|
23
|
-
"@vesk/types": "^0.2.
|
|
23
|
+
"@vesk/types": "^0.2.97",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|