@kernlang/core 3.1.5 → 3.1.6
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/LICENSE +17 -0
- package/README.md +5 -2
- package/dist/codegen/data-layer.d.ts +12 -0
- package/dist/codegen/data-layer.js +292 -0
- package/dist/codegen/data-layer.js.map +1 -0
- package/dist/codegen/events.d.ts +9 -0
- package/dist/codegen/events.js +158 -0
- package/dist/codegen/events.js.map +1 -0
- package/dist/codegen/functions.d.ts +8 -0
- package/dist/codegen/functions.js +147 -0
- package/dist/codegen/functions.js.map +1 -0
- package/dist/codegen/ground-layer.d.ts +22 -0
- package/dist/codegen/ground-layer.js +317 -0
- package/dist/codegen/ground-layer.js.map +1 -0
- package/dist/codegen/machines.d.ts +9 -0
- package/dist/codegen/machines.js +127 -0
- package/dist/codegen/machines.js.map +1 -0
- package/dist/codegen/modules.d.ts +10 -0
- package/dist/codegen/modules.js +40 -0
- package/dist/codegen/modules.js.map +1 -0
- package/dist/codegen/semantic-types.d.ts +14 -0
- package/dist/codegen/semantic-types.js +31 -0
- package/dist/codegen/semantic-types.js.map +1 -0
- package/dist/codegen/test-gen.d.ts +7 -0
- package/dist/codegen/test-gen.js +56 -0
- package/dist/codegen/test-gen.js.map +1 -0
- package/dist/codegen/type-system.d.ts +11 -0
- package/dist/codegen/type-system.js +162 -0
- package/dist/codegen/type-system.js.map +1 -0
- package/dist/codegen-core.d.ts +26 -33
- package/dist/codegen-core.js +58 -1367
- package/dist/codegen-core.js.map +1 -1
- package/dist/config.d.ts +20 -1
- package/dist/config.js +23 -3
- package/dist/config.js.map +1 -1
- package/dist/coverage-gap.js +6 -2
- package/dist/coverage-gap.js.map +1 -1
- package/dist/decompiler.d.ts +9 -0
- package/dist/decompiler.js +17 -2
- package/dist/decompiler.js.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +10 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/node-props.d.ts +253 -0
- package/dist/node-props.js +35 -0
- package/dist/node-props.js.map +1 -0
- package/dist/parser-core.d.ts +5 -0
- package/dist/parser-core.js +363 -0
- package/dist/parser-core.js.map +1 -0
- package/dist/parser-diagnostics.d.ts +14 -0
- package/dist/parser-diagnostics.js +31 -0
- package/dist/parser-diagnostics.js.map +1 -0
- package/dist/parser-keywords.d.ts +5 -0
- package/dist/parser-keywords.js +135 -0
- package/dist/parser-keywords.js.map +1 -0
- package/dist/parser-style.d.ts +3 -0
- package/dist/parser-style.js +73 -0
- package/dist/parser-style.js.map +1 -0
- package/dist/parser-token-stream.d.ts +27 -0
- package/dist/parser-token-stream.js +69 -0
- package/dist/parser-token-stream.js.map +1 -0
- package/dist/parser-tokenizer.d.ts +11 -0
- package/dist/parser-tokenizer.js +188 -0
- package/dist/parser-tokenizer.js.map +1 -0
- package/dist/parser.d.ts +59 -12
- package/dist/parser.js +51 -862
- package/dist/parser.js.map +1 -1
- package/dist/schema.d.ts +7 -2
- package/dist/schema.js +7 -2
- package/dist/schema.js.map +1 -1
- package/dist/source-map.d.ts +27 -0
- package/dist/source-map.js +82 -0
- package/dist/source-map.js.map +1 -0
- package/dist/spec.d.ts +1 -1
- package/dist/spec.js +2 -0
- package/dist/spec.js.map +1 -1
- package/dist/styles-tailwind.d.ts +10 -0
- package/dist/styles-tailwind.js +10 -0
- package/dist/styles-tailwind.js.map +1 -1
- package/dist/template-engine.d.ts +10 -5
- package/dist/template-engine.js +10 -5
- package/dist/template-engine.js.map +1 -1
- package/dist/types.d.ts +8 -3
- package/dist/utils.d.ts +20 -0
- package/dist/utils.js +20 -0
- package/dist/utils.js.map +1 -1
- package/dist/walk.d.ts +40 -0
- package/dist/walk.js +107 -0
- package/dist/walk.js.map +1 -0
- package/package.json +2 -2
package/dist/parser.d.ts
CHANGED
|
@@ -1,21 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KERN Parser — public API surface.
|
|
3
|
+
*
|
|
4
|
+
* Implementation is split across sibling modules:
|
|
5
|
+
* - parser-diagnostics.ts — diagnostic infrastructure
|
|
6
|
+
* - parser-tokenizer.ts — character-level tokenizer
|
|
7
|
+
* - parser-token-stream.ts — token cursor
|
|
8
|
+
* - parser-style.ts — style block parsing
|
|
9
|
+
* - parser-keywords.ts — keyword-specific handlers
|
|
10
|
+
* - parser-core.ts — line parsing, tree building, orchestration
|
|
11
|
+
*/
|
|
1
12
|
import type { IRNode, ParseDiagnostic, ParseResult } from './types.js';
|
|
2
13
|
import { type KernRuntime } from './runtime.js';
|
|
3
14
|
import type { ParserHintsConfig } from './runtime.js';
|
|
4
|
-
export type TokenKind
|
|
5
|
-
export
|
|
6
|
-
kind: TokenKind;
|
|
7
|
-
value: string;
|
|
8
|
-
pos: number;
|
|
9
|
-
}
|
|
10
|
-
export declare function tokenizeLine(line: string): Token[];
|
|
15
|
+
export type { TokenKind, Token } from './parser-tokenizer.js';
|
|
16
|
+
export { tokenizeLine } from './parser-tokenizer.js';
|
|
11
17
|
/** Register parser hints for an evolved node type. */
|
|
12
18
|
export declare function registerParserHints(keyword: string, hints: ParserHintsConfig): void;
|
|
13
19
|
/** Unregister parser hints (for rollback/testing). */
|
|
14
20
|
export declare function unregisterParserHints(keyword: string): void;
|
|
15
21
|
/** Clear all parser hints (for test isolation). */
|
|
16
22
|
export declare function clearParserHints(): void;
|
|
17
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Get diagnostic messages from the last parse() call as plain strings.
|
|
25
|
+
*
|
|
26
|
+
* @remarks Returns messages for all severities (error, warning, info).
|
|
27
|
+
* For structured diagnostics with severity filtering, use {@link getParseDiagnostics}.
|
|
28
|
+
*/
|
|
18
29
|
export declare function getParseWarnings(): string[];
|
|
30
|
+
/** Get structured diagnostics from the last parse() call. */
|
|
31
|
+
export declare function getParseDiagnostics(runtime?: KernRuntime): ParseDiagnostic[];
|
|
32
|
+
/**
|
|
33
|
+
* Parse KERN source into an IR node tree.
|
|
34
|
+
*
|
|
35
|
+
* Recovers from errors gracefully — malformed lines produce `DROPPED_LINE`
|
|
36
|
+
* diagnostics but never throw. Use {@link parseStrict} if you want errors to throw.
|
|
37
|
+
*
|
|
38
|
+
* @param source - KERN indentation-based source text
|
|
39
|
+
* @param runtime - Optional KernRuntime instance for isolation (defaults to shared singleton)
|
|
40
|
+
* @returns Root IRNode of the parsed tree
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const root = parse('page "Home"\n text "Hello"');
|
|
45
|
+
* // root.type === 'page', root.children[0].type === 'text'
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see {@link parseWithDiagnostics} to also receive parse diagnostics
|
|
49
|
+
* @see {@link parseStrict} to throw on errors
|
|
50
|
+
*/
|
|
19
51
|
export declare function parse(source: string, runtime?: KernRuntime): IRNode;
|
|
20
52
|
/**
|
|
21
53
|
* Parse KERN source into a document-wrapped IR tree.
|
|
@@ -23,13 +55,28 @@ export declare function parse(source: string, runtime?: KernRuntime): IRNode;
|
|
|
23
55
|
* top-level nodes (e.g., multiple `rule` definitions) are siblings.
|
|
24
56
|
*/
|
|
25
57
|
export declare function parseDocument(source: string, runtime?: KernRuntime): IRNode;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Parse KERN source and return both the IR tree and structured diagnostics.
|
|
60
|
+
*
|
|
61
|
+
* Unlike {@link parse}, this returns a {@link ParseResult} containing the full
|
|
62
|
+
* diagnostics array, useful for editor integrations and lint-style reporting.
|
|
63
|
+
*
|
|
64
|
+
* @param source - KERN indentation-based source text
|
|
65
|
+
* @param runtime - Optional KernRuntime instance for isolation
|
|
66
|
+
* @returns `{ root: IRNode, diagnostics: ParseDiagnostic[] }`
|
|
67
|
+
*/
|
|
29
68
|
export declare function parseWithDiagnostics(source: string, runtime?: KernRuntime): ParseResult;
|
|
30
69
|
/** Parse with diagnostics (document mode). */
|
|
31
70
|
export declare function parseDocumentWithDiagnostics(source: string, runtime?: KernRuntime): ParseResult;
|
|
32
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Strict parse — throws if any diagnostic has severity `'error'` or a schema violation is found.
|
|
73
|
+
*
|
|
74
|
+
* @param source - KERN indentation-based source text
|
|
75
|
+
* @param runtime - Optional KernRuntime instance for isolation
|
|
76
|
+
* @returns Root IRNode of the parsed tree
|
|
77
|
+
* @throws {KernParseError} When the source contains errors or schema violations.
|
|
78
|
+
* The error includes a code frame and the full diagnostics array.
|
|
79
|
+
*/
|
|
33
80
|
export declare function parseStrict(source: string, runtime?: KernRuntime): IRNode;
|
|
34
81
|
/** Strict document parse — throws KernParseError if any diagnostic has severity=error or schema violation. */
|
|
35
82
|
export declare function parseDocumentStrict(source: string, runtime?: KernRuntime): IRNode;
|