@lokascript/framework 2.1.0 → 2.2.0
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/api/index.js +111 -24
- package/dist/api/index.js.map +1 -1
- package/dist/core/index.js +133 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/pattern-matching/index.js.map +1 -1
- package/dist/core/tokenization/index.js +133 -0
- package/dist/core/tokenization/index.js.map +1 -1
- package/dist/core/tokenization/morphology/base-normalizer.d.ts +94 -0
- package/dist/core/tokenization/morphology/base-normalizer.d.ts.map +1 -0
- package/dist/core/tokenization/morphology/index.d.ts +3 -1
- package/dist/core/tokenization/morphology/index.d.ts.map +1 -1
- package/dist/core/types.d.ts +3 -2
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/generation/index.js.map +1 -1
- package/dist/index.cjs +564 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +556 -46
- package/dist/index.js.map +1 -1
- package/dist/ir/explicit-parser.d.ts +62 -7
- package/dist/ir/explicit-parser.d.ts.map +1 -1
- package/dist/ir/explicit-renderer.d.ts +18 -1
- package/dist/ir/explicit-renderer.d.ts.map +1 -1
- package/dist/ir/index.d.ts +4 -2
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js +423 -46
- package/dist/ir/index.js.map +1 -1
- package/dist/ir/protocol-json.d.ts.map +1 -1
- package/dist/ir/to-runtime-ast.d.ts +53 -0
- package/dist/ir/to-runtime-ast.d.ts.map +1 -0
- package/dist/ir/types.d.ts +14 -4
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/parsing/index.js.map +1 -1
- package/dist/testing/index.js +8671 -8261
- package/dist/testing/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/tokenization/morphology/base-normalizer.ts +249 -0
- package/src/core/tokenization/morphology/index.ts +3 -1
- package/src/core/types.ts +4 -2
- package/src/index.ts +7 -0
- package/src/ir/conformance.test.ts +120 -0
- package/src/ir/explicit-parser.test.ts +307 -1
- package/src/ir/explicit-parser.ts +403 -29
- package/src/ir/explicit-renderer.test.ts +87 -2
- package/src/ir/explicit-renderer.ts +57 -5
- package/src/ir/index.ts +13 -2
- package/src/ir/protocol-json.test.ts +4 -2
- package/src/ir/protocol-json.ts +30 -24
- package/src/ir/to-runtime-ast.ts +203 -0
- package/src/ir/types.ts +14 -4
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
* Parses the universal [command role:value ...] bracket syntax.
|
|
5
5
|
* Domain-agnostic — schema validation is injectable via ParseExplicitOptions.
|
|
6
6
|
*
|
|
7
|
+
* Three parsing levels matching the ABNF grammar:
|
|
8
|
+
* parseDocument() → parseCompound() → parseExplicit()
|
|
9
|
+
* (multi-line) (chain ops) (single bracket)
|
|
10
|
+
*
|
|
7
11
|
* Syntax:
|
|
8
12
|
* [command role1:value1 role2:value2 ...]
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* [
|
|
12
|
-
* [put patient:"hello" destination:#output]
|
|
13
|
-
* [on event:click body:[toggle patient:.active]]
|
|
14
|
-
* [select patient:name source:users condition:age>25]
|
|
13
|
+
* [cmd1 ...] then [cmd2 ...]
|
|
14
|
+
* @annotation(value) [command ...]
|
|
15
|
+
* #!lse 1.2\n[cmd1 ...]\n[cmd2 ...]
|
|
15
16
|
*/
|
|
16
|
-
import type { SemanticNode } from '../core/types';
|
|
17
|
+
import type { SemanticNode, LSEEnvelope } from '../core/types';
|
|
17
18
|
import type { ParseExplicitOptions } from './types';
|
|
18
19
|
/** Structural role names whose bracket-enclosed values may be nested commands. */
|
|
19
20
|
export declare const STRUCTURAL_ROLES: Set<string>;
|
|
@@ -28,4 +29,58 @@ export declare function parseExplicit(input: string, options?: ParseExplicitOpti
|
|
|
28
29
|
* Check if input is explicit bracket syntax.
|
|
29
30
|
*/
|
|
30
31
|
export declare function isExplicitSyntax(input: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Parse a compound statement (one or more bracket commands chained with operators).
|
|
34
|
+
*
|
|
35
|
+
* ABNF: compound-stmt = bracket-cmd *( chain-op bracket-cmd )
|
|
36
|
+
*
|
|
37
|
+
* Single commands pass through to parseExplicit(). Multiple commands produce
|
|
38
|
+
* a CompoundSemanticNode.
|
|
39
|
+
*
|
|
40
|
+
* Also handles annotations (@name or @name(value)) before the first bracket.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Single command — passthrough
|
|
45
|
+
* parseCompound('[toggle patient:.active]')
|
|
46
|
+
*
|
|
47
|
+
* // Compound statement
|
|
48
|
+
* parseCompound('[add patient:.loading] then [fetch source:/api/data]')
|
|
49
|
+
*
|
|
50
|
+
* // With annotation
|
|
51
|
+
* parseCompound('@timeout(5s) [fetch source:/api/users]')
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseCompound(input: string, options?: ParseExplicitOptions): SemanticNode;
|
|
55
|
+
/**
|
|
56
|
+
* Parse a multi-line LSE document into an LSEEnvelope.
|
|
57
|
+
*
|
|
58
|
+
* ABNF: document = [ version-header LF ] *( line LF ) [ line ]
|
|
59
|
+
*
|
|
60
|
+
* Handles version headers (#!lse 1.2), comments (// or #), blank lines,
|
|
61
|
+
* and statement lines (one compound statement per line).
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const envelope = parseDocument(`
|
|
66
|
+
* #!lse 1.2
|
|
67
|
+
* // Toggle active state
|
|
68
|
+
* [toggle patient:.active]
|
|
69
|
+
* [add patient:.highlight]
|
|
70
|
+
* `);
|
|
71
|
+
* // envelope.lseVersion === '1.2'
|
|
72
|
+
* // envelope.nodes.length === 2
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function parseDocument(input: string, options?: ParseExplicitOptions): LSEEnvelope;
|
|
76
|
+
/**
|
|
77
|
+
* Check if input contains compound chaining (multiple bracket commands
|
|
78
|
+
* with chain operators at bracket-depth 0).
|
|
79
|
+
*/
|
|
80
|
+
export declare function isCompoundSyntax(input: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Check if input is a multi-line LSE document (contains newlines,
|
|
83
|
+
* version header, or comment lines).
|
|
84
|
+
*/
|
|
85
|
+
export declare function isDocumentSyntax(input: string): boolean;
|
|
31
86
|
//# sourceMappingURL=explicit-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explicit-parser.d.ts","sourceRoot":"","sources":["../../src/ir/explicit-parser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"explicit-parser.d.ts","sourceRoot":"","sources":["../../src/ir/explicit-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EACV,YAAY,EAMZ,WAAW,EAEZ,MAAM,eAAe,CAAC;AAavB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGpD,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,aAS3B,CAAC;AAsBH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,YAAY,CAkQ7F;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGvD;AAuFD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,YAAY,CAuBzF;AA0ED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,WAAW,CAmCxF;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQvD"}
|
|
@@ -3,15 +3,32 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Serializes SemanticNode to the universal [command role:value ...] bracket syntax.
|
|
5
5
|
* Zero dependencies beyond core types — no language-specific logic.
|
|
6
|
+
*
|
|
7
|
+
* Also renders annotations (@name(value)) and multi-line documents.
|
|
6
8
|
*/
|
|
7
|
-
import type { SemanticNode } from '../core/types';
|
|
9
|
+
import type { SemanticNode, LSEEnvelope } from '../core/types';
|
|
8
10
|
/**
|
|
9
11
|
* Render a semantic node as explicit bracket syntax.
|
|
10
12
|
*
|
|
13
|
+
* Handles annotations (v1.2) — if the node has annotations, they are
|
|
14
|
+
* prepended as @name or @name(value) before the bracket output.
|
|
15
|
+
*
|
|
11
16
|
* @example
|
|
12
17
|
* ```typescript
|
|
13
18
|
* renderExplicit(node) // "[toggle patient:.active destination:#button]"
|
|
19
|
+
* // With annotations:
|
|
20
|
+
* renderExplicit(annotatedNode) // "@timeout(5s) [fetch source:\"/api/users\"]"
|
|
14
21
|
* ```
|
|
15
22
|
*/
|
|
16
23
|
export declare function renderExplicit(node: SemanticNode): string;
|
|
24
|
+
/**
|
|
25
|
+
* Render an LSEEnvelope as a multi-line document string.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* renderDocument(envelope)
|
|
30
|
+
* // "#!lse 1.2\n[toggle patient:.active]\n[add patient:.highlight]"
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderDocument(envelope: LSEEnvelope): string;
|
|
17
34
|
//# sourceMappingURL=explicit-renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explicit-renderer.d.ts","sourceRoot":"","sources":["../../src/ir/explicit-renderer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"explicit-renderer.d.ts","sourceRoot":"","sources":["../../src/ir/explicit-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,YAAY,EAOZ,WAAW,EACZ,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAqBzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAc5D"}
|
package/dist/ir/index.d.ts
CHANGED
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
*/
|
|
21
21
|
export type { SemanticJSON, SemanticJSONValue, SchemaLookup, ParseExplicitOptions, IRDiagnostic, } from './types';
|
|
22
22
|
export { DEFAULT_REFERENCES, isValidReference } from './references';
|
|
23
|
-
export { parseExplicit, isExplicitSyntax } from './explicit-parser';
|
|
24
|
-
export { renderExplicit } from './explicit-renderer';
|
|
23
|
+
export { parseExplicit, parseCompound, parseDocument, isExplicitSyntax, isCompoundSyntax, isDocumentSyntax, } from './explicit-parser';
|
|
24
|
+
export { renderExplicit, renderDocument } from './explicit-renderer';
|
|
25
25
|
export { jsonToSemanticNode, validateSemanticJSON, semanticNodeToJSON } from './json-schema';
|
|
26
26
|
export type { ProtocolNodeJSON, ProtocolValueJSON, ProtocolNodeKind, ProtocolChainType, ProtocolDiagnosticJSON, AnnotationJSON, MatchArmJSON, LSEEnvelopeJSON, } from './types';
|
|
27
27
|
export { toProtocolJSON, fromProtocolJSON, validateProtocolJSON, toEnvelopeJSON, fromEnvelopeJSON, isEnvelope, } from './protocol-json';
|
|
28
28
|
export { fromInterchangeNode, convertValue, renderExpr } from './from-interchange';
|
|
29
|
+
export { semanticNodeToRuntimeAST, semanticValueToAST } from './to-runtime-ast';
|
|
30
|
+
export type { RuntimeASTNode, RuntimeCommandNode, RuntimeEventNode } from './to-runtime-ast';
|
|
29
31
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ir/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ir/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ir/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,YAAY,GACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrE,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG7F,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAEjB,sBAAsB,EACtB,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EAEpB,cAAc,EACd,gBAAgB,EAChB,UAAU,GACX,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGnF,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAChF,YAAY,EAAE,cAAc,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|