@jondotsoy/don 0.0.4 → 0.0.5

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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -22
  3. package/lib/esm/don.d.ts +10 -0
  4. package/lib/esm/don.d.ts.map +1 -0
  5. package/lib/esm/don.js +27 -0
  6. package/lib/esm/don.js.map +1 -0
  7. package/lib/esm/index.d.ts +1 -2
  8. package/lib/esm/index.d.ts.map +1 -1
  9. package/lib/esm/index.js +2 -2
  10. package/lib/esm/index.js.map +1 -1
  11. package/lib/esm/v1/__utils__/key-syntax-kind.d.ts +2 -0
  12. package/lib/esm/v1/__utils__/key-syntax-kind.d.ts.map +1 -0
  13. package/lib/esm/v1/__utils__/key-syntax-kind.js +23 -0
  14. package/lib/esm/v1/__utils__/key-syntax-kind.js.map +1 -0
  15. package/lib/esm/v1/__utils__/normalize.d.ts +3 -0
  16. package/lib/esm/v1/__utils__/normalize.d.ts.map +1 -0
  17. package/lib/esm/v1/__utils__/normalize.js +10 -0
  18. package/lib/esm/v1/__utils__/normalize.js.map +1 -0
  19. package/lib/esm/v1/__utils__/t.d.ts +15 -0
  20. package/lib/esm/v1/__utils__/t.d.ts.map +1 -0
  21. package/lib/esm/v1/__utils__/t.js +32 -0
  22. package/lib/esm/v1/__utils__/t.js.map +1 -0
  23. package/lib/esm/v1/__utils__/to-token-snapshot.d.ts +7 -0
  24. package/lib/esm/v1/__utils__/to-token-snapshot.d.ts.map +1 -0
  25. package/lib/esm/v1/__utils__/to-token-snapshot.js +162 -0
  26. package/lib/esm/v1/__utils__/to-token-snapshot.js.map +1 -0
  27. package/lib/esm/v1/compiler/directive-node.d.ts +26 -0
  28. package/lib/esm/v1/compiler/directive-node.d.ts.map +1 -0
  29. package/lib/esm/v1/compiler/directive-node.js +48 -0
  30. package/lib/esm/v1/compiler/directive-node.js.map +1 -0
  31. package/lib/esm/v1/compiler/lexema-encode.d.ts +15 -0
  32. package/lib/esm/v1/compiler/lexema-encode.d.ts.map +1 -0
  33. package/lib/esm/v1/compiler/lexema-encode.js +22 -0
  34. package/lib/esm/v1/compiler/lexema-encode.js.map +1 -0
  35. package/lib/esm/v1/compiler/lexema.d.ts +10 -0
  36. package/lib/esm/v1/compiler/lexema.d.ts.map +1 -0
  37. package/lib/esm/v1/compiler/lexema.js +26 -0
  38. package/lib/esm/v1/compiler/lexema.js.map +1 -0
  39. package/lib/esm/v1/compiler/part-set-encode.d.ts +6 -0
  40. package/lib/esm/v1/compiler/part-set-encode.d.ts.map +1 -0
  41. package/lib/esm/v1/compiler/part-set-encode.js +15 -0
  42. package/lib/esm/v1/compiler/part-set-encode.js.map +1 -0
  43. package/lib/esm/v1/compiler/part-set.d.ts +6 -0
  44. package/lib/esm/v1/compiler/part-set.d.ts.map +1 -0
  45. package/lib/esm/v1/compiler/part-set.js +7 -0
  46. package/lib/esm/v1/compiler/part-set.js.map +1 -0
  47. package/lib/esm/v1/compiler/part.d.ts +31 -0
  48. package/lib/esm/v1/compiler/part.d.ts.map +1 -0
  49. package/lib/esm/v1/compiler/part.js +109 -0
  50. package/lib/esm/v1/compiler/part.js.map +1 -0
  51. package/lib/esm/v1/compiler/partial-span.d.ts +6 -0
  52. package/lib/esm/v1/compiler/partial-span.d.ts.map +1 -0
  53. package/lib/esm/v1/compiler/partial-span.js +9 -0
  54. package/lib/esm/v1/compiler/partial-span.js.map +1 -0
  55. package/lib/esm/v1/compiler/span.d.ts +9 -0
  56. package/lib/esm/v1/compiler/span.d.ts.map +1 -0
  57. package/lib/esm/v1/compiler/span.js +13 -0
  58. package/lib/esm/v1/compiler/span.js.map +1 -0
  59. package/lib/esm/v1/compiler/syntax-encode.d.ts +9 -0
  60. package/lib/esm/v1/compiler/syntax-encode.d.ts.map +1 -0
  61. package/lib/esm/v1/compiler/syntax-encode.js +160 -0
  62. package/lib/esm/v1/compiler/syntax-encode.js.map +1 -0
  63. package/lib/esm/v1/compiler/token.d.ts +59 -0
  64. package/lib/esm/v1/compiler/token.d.ts.map +1 -0
  65. package/lib/esm/v1/compiler/token.js +320 -0
  66. package/lib/esm/v1/compiler/token.js.map +1 -0
  67. package/lib/esm/v1/types/location.d.ts +6 -0
  68. package/lib/esm/v1/types/location.d.ts.map +1 -0
  69. package/lib/esm/v1/types/location.js +2 -0
  70. package/lib/esm/v1/types/location.js.map +1 -0
  71. package/lib/esm/v1/types/u8.d.ts +2 -0
  72. package/lib/esm/v1/types/u8.d.ts.map +1 -0
  73. package/lib/esm/v1/types/u8.js +2 -0
  74. package/lib/esm/v1/types/u8.js.map +1 -0
  75. package/lib/esm/v1/utils/build-logger.d.ts +11 -0
  76. package/lib/esm/v1/utils/build-logger.d.ts.map +1 -0
  77. package/lib/esm/v1/utils/build-logger.js +20 -0
  78. package/lib/esm/v1/utils/build-logger.js.map +1 -0
  79. package/lib/esm/v1/utils/charset-tools.d.ts +15 -0
  80. package/lib/esm/v1/utils/charset-tools.d.ts.map +1 -0
  81. package/lib/esm/v1/utils/charset-tools.js +37 -0
  82. package/lib/esm/v1/utils/charset-tools.js.map +1 -0
  83. package/lib/esm/v1/utils/charset.d.ts +34 -0
  84. package/lib/esm/v1/utils/charset.d.ts.map +1 -0
  85. package/lib/esm/v1/utils/charset.js +52 -0
  86. package/lib/esm/v1/utils/charset.js.map +1 -0
  87. package/lib/esm/v1/utils/parts-match.d.ts +12 -0
  88. package/lib/esm/v1/utils/parts-match.d.ts.map +1 -0
  89. package/lib/esm/v1/utils/parts-match.js +30 -0
  90. package/lib/esm/v1/utils/parts-match.js.map +1 -0
  91. package/lib/esm/v1/utils/syntax-kind.d.ts +22 -0
  92. package/lib/esm/v1/utils/syntax-kind.d.ts.map +1 -0
  93. package/lib/esm/v1/utils/syntax-kind.js +28 -0
  94. package/lib/esm/v1/utils/syntax-kind.js.map +1 -0
  95. package/lib/esm/v1/utils/take-while.d.ts +53 -0
  96. package/lib/esm/v1/utils/take-while.d.ts.map +1 -0
  97. package/lib/esm/v1/utils/take-while.js +69 -0
  98. package/lib/esm/v1/utils/take-while.js.map +1 -0
  99. package/package.json +1 -1
  100. package/lib/esm/chunk.d.ts +0 -28
  101. package/lib/esm/chunk.d.ts.map +0 -1
  102. package/lib/esm/chunk.js +0 -84
  103. package/lib/esm/chunk.js.map +0 -1
  104. package/lib/esm/document.d.ts +0 -20
  105. package/lib/esm/document.d.ts.map +0 -1
  106. package/lib/esm/document.js +0 -138
  107. package/lib/esm/document.js.map +0 -1
  108. package/lib/esm/lexer.d.ts +0 -38
  109. package/lib/esm/lexer.d.ts.map +0 -1
  110. package/lib/esm/lexer.js +0 -600
  111. package/lib/esm/lexer.js.map +0 -1
  112. package/lib/esm/utils/inspect.d.ts +0 -7
  113. package/lib/esm/utils/inspect.d.ts.map +0 -1
  114. package/lib/esm/utils/inspect.js +0 -39
  115. package/lib/esm/utils/inspect.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jonathan Delgado <hi@jon.soy> (https://jon.soy)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -28,46 +28,75 @@ bun add @jondotsoy/don
28
28
 
29
29
  ## Usage
30
30
 
31
- ### Basic Example
31
+ ### Deserialization (DON → JavaScript)
32
+
33
+ Parse DON format strings into JavaScript objects using `DocumentDecoder`:
32
34
 
33
35
  ```typescript
34
- import { DocumentEncoder, LexerEncoder } from "@jondotsoy/don";
36
+ import { DocumentDecoder } from "@jondotsoy/don";
35
37
 
36
- // Parse a DON document
37
- const source = `
38
+ const donPayload = `
38
39
  name "my-app"
39
- version 1.0.0
40
+ version "1.0.0"
40
41
  container {
41
42
  image "nginx"
42
43
  port 8080
43
44
  }
44
45
  `;
45
46
 
46
- const document = new DocumentEncoder();
47
- const directives = document.encode(source);
47
+ const decoder = new DocumentDecoder();
48
+ const result = decoder.decode(donPayload);
48
49
 
49
- console.log(directives);
50
+ console.log(result);
51
+ // Output: { name: "my-app", version: "1.0.0", container: { image: "nginx", port: 8080 } }
50
52
  ```
51
53
 
52
- ### Using the Inspect Utility
54
+ ### Serialization (JavaScript DON)
55
+
56
+ Convert JavaScript objects into DON format strings using `DocumentEncoder`:
53
57
 
54
58
  ```typescript
55
- import { DocumentEncoder, LexerEncoder } from "@jondotsoy/don";
56
- import { inspect } from "@jondotsoy/don/utils";
57
-
58
- const source = `
59
- service "web" replicas 3 {
60
- container "nginx" {
61
- port 80
62
- image "nginx:latest"
63
- }
64
- }
59
+ import { DocumentEncoder } from "@jondotsoy/don";
60
+
61
+ const data = {
62
+ name: "my-app",
63
+ version: "1.0.0",
64
+ container: {
65
+ image: "nginx",
66
+ port: 8080,
67
+ },
68
+ };
69
+
70
+ const encoder = new DocumentEncoder();
71
+ const donString = encoder.encode(data);
72
+
73
+ console.log(donString);
74
+ // Output:
75
+ // name "my-app"
76
+ // version "1.0.0"
77
+ // container {
78
+ // image "nginx"
79
+ // port 8080
80
+ // }
81
+ ```
82
+
83
+ ### Working with Heredocs
84
+
85
+ ```typescript
86
+ import { DocumentDecoder } from "@jondotsoy/don";
87
+
88
+ const donPayload = `
89
+ name "deployment-script"
90
+ script <<<
91
+ #!/bin/bash
92
+ echo "Deploying application..."
93
+ npm run build
65
94
  `;
66
95
 
67
- const doc = new DocumentEncoder().encode(source);
96
+ const result = new DocumentDecoder().decode(donPayload);
68
97
 
69
- // Pretty-print the parsed document structure
70
- console.log(inspect(doc));
98
+ console.log(result.script);
99
+ // Output: "#!/bin/bash\necho \"Deploying application...\"\nnpm run build"
71
100
  ```
72
101
 
73
102
  ## Documentation
@@ -0,0 +1,10 @@
1
+ export declare class Directive {
2
+ readonly name: string;
3
+ readonly args: (number | string | boolean)[];
4
+ readonly children: Directive[];
5
+ constructor(name: string, args: (number | string | boolean)[], children?: Directive[]);
6
+ }
7
+ export declare class DON {
8
+ static parse(text: string): Directive[];
9
+ }
10
+ //# sourceMappingURL=don.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"don.d.ts","sourceRoot":"","sources":["../../src/don.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;IAElB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE;IAC5C,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE;gBAFrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE,EACnC,QAAQ,GAAE,SAAS,EAAO;CAEtC;AAsBD,qBAAa,GAAG;IACd,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM;CAK1B"}
package/lib/esm/don.js ADDED
@@ -0,0 +1,27 @@
1
+ import { SyntaxEncode } from "./v1/compiler/syntax-encode";
2
+ export class Directive {
3
+ name;
4
+ args;
5
+ children;
6
+ constructor(name, args, children = []) {
7
+ this.name = name;
8
+ this.args = args;
9
+ this.children = children;
10
+ }
11
+ }
12
+ const toDirective = (node) => {
13
+ return new Directive(node.name.text(), node.args.map((token) => token.toJS()), node.children.map((child) => toDirective(child)).flat());
14
+ };
15
+ const docToDirective = (node) => {
16
+ const directives = node.children.map((node) => {
17
+ return new Directive(node.name.text(), node.args.map((token) => token.toJS()), node.children.map((child) => toDirective(child)).flat());
18
+ });
19
+ return directives;
20
+ };
21
+ export class DON {
22
+ static parse(text) {
23
+ const documentNode = new SyntaxEncode().encode(text);
24
+ return docToDirective(documentNode);
25
+ }
26
+ }
27
+ //# sourceMappingURL=don.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"don.js","sourceRoot":"","sources":["../../src/don.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,MAAM,OAAO,SAAS;IAET;IACA;IACA;IAHX,YACW,IAAY,EACZ,IAAmC,EACnC,WAAwB,EAAE;QAF1B,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAA+B;QACnC,aAAQ,GAAR,QAAQ,CAAkB;IAClC,CAAC;CACL;AAED,MAAM,WAAW,GAAG,CAAC,IAAmB,EAAa,EAAE;IACrD,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CACxD,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAkB,EAAe,EAAE;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5C,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CACxD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG;IACd,MAAM,CAAC,KAAK,CAAC,IAAY;QACvB,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAErD,OAAO,cAAc,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -1,3 +1,2 @@
1
- export { LexerEncoder, Lexema, Token, TokenExpression } from "./lexer.js";
2
- export { Directive, Document, DocumentEncoder } from "./document.js";
1
+ export { SyntaxEncode } from "./v1/compiler/syntax-encode.js";
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC"}
package/lib/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { LexerEncoder, Lexema, Token, TokenExpression } from "./lexer.js";
2
- export { Directive, Document, DocumentEncoder } from "./document.js";
1
+ export { SyntaxEncode } from "./v1/compiler/syntax-encode.js";
2
+ // TODO: preparar package.json
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,8BAA8B"}
@@ -0,0 +1,2 @@
1
+ export declare const KeySyntaxKind: Record<number | string, string>;
2
+ //# sourceMappingURL=key-syntax-kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-syntax-kind.d.ts","sourceRoot":"","sources":["../../../../src/v1/__utils__/key-syntax-kind.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,CAoBzD,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { SyntaxKind } from "../utils/syntax-kind.js";
2
+ export const KeySyntaxKind = {
3
+ [SyntaxKind.unknown]: "Unknown",
4
+ [SyntaxKind.alphabet]: "Alphabet",
5
+ [SyntaxKind.integer]: "Int",
6
+ [SyntaxKind.whitespace]: "Whitespace",
7
+ [SyntaxKind.newline]: "Newline",
8
+ [SyntaxKind.dot]: "Dot",
9
+ [SyntaxKind.underscore]: "underscore",
10
+ [SyntaxKind.openCurlyBrace]: "OpenCurlyBrace",
11
+ [SyntaxKind.closeCurlyBrace]: "CloseCurlyBrace",
12
+ [SyntaxKind.keyword]: "Keyword",
13
+ [SyntaxKind.numeric]: "Numeric",
14
+ [SyntaxKind.boolean]: "Boolean",
15
+ [SyntaxKind.null]: "Null",
16
+ [SyntaxKind.comment]: "Comment",
17
+ [SyntaxKind.indent]: "Indent",
18
+ [SyntaxKind.heredoc]: "Heredoc",
19
+ [SyntaxKind.singleQuote]: "SingleQuote",
20
+ [SyntaxKind.doubleQuote]: "DoubleQuote",
21
+ [SyntaxKind.string]: "String",
22
+ };
23
+ //# sourceMappingURL=key-syntax-kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key-syntax-kind.js","sourceRoot":"","sources":["../../../../src/v1/__utils__/key-syntax-kind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,CAAC,MAAM,aAAa,GAAoC;IAC5D,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU;IACjC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,KAAK;IAC3B,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,YAAY;IACrC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK;IACvB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,YAAY;IACrC,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,gBAAgB;IAC7C,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,iBAAiB;IAC/C,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM;IACzB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ;IAC7B,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,SAAS;IAC/B,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,aAAa;IACvC,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,aAAa;IACvC,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ;CAC9B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { u8 } from "../types/u8.js";
2
+ export declare const normalize: (input: string | Uint8Array | number[]) => u8;
3
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../src/v1/__utils__/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEzC,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,GAAG,UAAU,GAAG,MAAM,EAAE,KAAG,EAMjE,CAAC"}
@@ -0,0 +1,10 @@
1
+ export const normalize = (input) => {
2
+ if (typeof input === "string")
3
+ return [...new TextEncoder().encode(input)];
4
+ if (input instanceof Uint8Array)
5
+ return [...input];
6
+ if (Array.isArray(input) && input.every((value) => typeof value === "number"))
7
+ return input;
8
+ throw new Error("not implemented");
9
+ };
10
+ //# sourceMappingURL=normalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../../../src/v1/__utils__/normalize.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAqC,EAAM,EAAE;IACrE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,IAAI,KAAK,YAAY,UAAU;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;QAC3E,OAAO,KAAK,CAAC;IACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ type Candidate = Result<any, any, any> | (() => any);
2
+ export declare class Result<O, E, V> {
3
+ readonly ok: O;
4
+ readonly error: E;
5
+ readonly value: V;
6
+ constructor(ok: O, error: E, value: V);
7
+ [Symbol.iterator](): Generator<O | E | V, void, unknown>;
8
+ static ok: <V_1>(value: V_1) => Result<true, undefined, V_1>;
9
+ static error: <E_1>(error: E_1) => Result<false, E_1, undefined>;
10
+ }
11
+ type ResultType<O, E, V> = Result<O, E, V> & [O, E, V];
12
+ type R<T> = T extends Result<infer O, infer E, infer V> ? ResultType<O, E, V> : T extends () => infer V ? ResultType<true, unknown, V> | Result<false, unknown, null> : ResultType<false, unknown, never>;
13
+ export declare const t: <T extends Candidate>(candidate: T) => R<T>;
14
+ export {};
15
+ //# sourceMappingURL=t.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"t.d.ts","sourceRoot":"","sources":["../../../../src/v1/__utils__/t.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC;AAErD,qBAAa,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IAEvB,QAAQ,CAAC,EAAE,EAAE,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,QAAQ,CAAC,KAAK,EAAE,CAAC;gBAFR,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,CAAC;IAGlB,CAAC,MAAM,CAAC,QAAQ,CAAC;IAMlB,MAAM,CAAC,EAAE,GAAI,GAAC,EAAE,OAAO,GAAC,kCAAiD;IACzE,MAAM,CAAC,KAAK,GAAI,GAAC,EAAE,OAAO,GAAC,mCAAkD;CAC9E;AAED,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEvD,KAAK,CAAC,CAAC,CAAC,IACN,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACvC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACnB,CAAC,SAAS,MAAM,MAAM,CAAC,GACrB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,GAC3D,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE1C,eAAO,MAAM,CAAC,GAAI,CAAC,SAAS,SAAS,EAAE,WAAW,CAAC,KAAG,CAAC,CAAC,CAAC,CAYxD,CAAC"}
@@ -0,0 +1,32 @@
1
+ export class Result {
2
+ ok;
3
+ error;
4
+ value;
5
+ constructor(ok, error, value) {
6
+ this.ok = ok;
7
+ this.error = error;
8
+ this.value = value;
9
+ }
10
+ *[Symbol.iterator]() {
11
+ yield this.ok;
12
+ yield this.error;
13
+ yield this.value;
14
+ }
15
+ static ok = (value) => new Result(true, undefined, value);
16
+ static error = (error) => new Result(false, error, undefined);
17
+ }
18
+ export const t = (candidate) => {
19
+ if (candidate instanceof Result) {
20
+ return candidate;
21
+ }
22
+ if (typeof candidate === "function") {
23
+ try {
24
+ return Result.ok(candidate());
25
+ }
26
+ catch (ex) {
27
+ return Result.error(ex);
28
+ }
29
+ }
30
+ return Result.error(new Error("invalid candidate"));
31
+ };
32
+ //# sourceMappingURL=t.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"t.js","sourceRoot":"","sources":["../../../../src/v1/__utils__/t.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,MAAM;IAEN;IACA;IACA;IAHX,YACW,EAAK,EACL,KAAQ,EACR,KAAQ;QAFR,OAAE,GAAF,EAAE,CAAG;QACL,UAAK,GAAL,KAAK,CAAG;QACR,UAAK,GAAL,KAAK,CAAG;IAChB,CAAC;IAEJ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;QAChB,MAAM,IAAI,CAAC,EAAE,CAAC;QACd,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,MAAM,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,EAAE,GAAG,CAAI,KAAQ,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAa,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACzE,MAAM,CAAC,KAAK,GAAG,CAAI,KAAQ,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,KAAc,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;;AAY/E,MAAM,CAAC,MAAM,CAAC,GAAG,CAAsB,SAAY,EAAQ,EAAE;IAC3D,IAAI,SAAS,YAAY,MAAM,EAAE,CAAC;QAChC,OAAO,SAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,OAAO,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,CAAQ,CAAC;QACvC,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,CAAQ,CAAC;QACjC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAQ,CAAC;AAC7D,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ declare module "bun:test" {
2
+ interface Matchers<T> {
3
+ toTokenSnapshot(snapName: string): T;
4
+ }
5
+ }
6
+ export {};
7
+ //# sourceMappingURL=to-token-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-token-snapshot.d.ts","sourceRoot":"","sources":["../../../../src/v1/__utils__/to-token-snapshot.ts"],"names":[],"mappings":"AAyEA,OAAO,QAAQ,UAAU,CAAC;IACxB,UAAU,QAAQ,CAAC,CAAC;QAClB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC;KACtC;CACF"}
@@ -0,0 +1,162 @@
1
+ import { expect } from "bun:test";
2
+ import * as fs from "node:fs";
3
+ import { Lexema } from "../compiler/lexema.js";
4
+ import { Token } from "../compiler/token.js";
5
+ import { Part } from "../compiler/part.js";
6
+ import { KeySyntaxKind } from "./key-syntax-kind.js";
7
+ import { PartSet } from "../compiler/part-set.js";
8
+ import { DirectiveNode, DocumentNode } from "../compiler/directive-node.js";
9
+ import { t } from "./t.js";
10
+ import { SyntaxEncode } from "../compiler/syntax-encode.js";
11
+ const isObject = (value) => typeof value === "object" && value !== null;
12
+ const isLexema = (value) => isObject(value) && value instanceof Lexema;
13
+ const isToken = (value) => isObject(value) && value instanceof Token;
14
+ const isPartSet = (value) => isObject(value) && value instanceof PartSet;
15
+ const isPart = (value) => isObject(value) && value instanceof Part;
16
+ const isTokenArray = (received) => typeof received === "object" &&
17
+ Array.isArray(received) &&
18
+ received.every(isToken);
19
+ const isNode = (value) => isObject(value) && value instanceof DirectiveNode;
20
+ const isDocumentNode = (value) => isObject(value) && value instanceof DocumentNode;
21
+ const isDirectiveArray = (value) => isObject(value) && Array.isArray(value) && value.every(isNode);
22
+ const toSpanStr = (span) => {
23
+ const posStr = `Offset ${span.index} Len ${span.length}`;
24
+ const i = span.startLocation && span.endLocation
25
+ ? `; Ln ${span.startLocation.line + 1}, Col ${span.startLocation.column + 1} (Padding ${span.startLocation.paddingLine}) -> Ln ${span.endLocation.line + 1}, Col ${span.endLocation.column + 1} (Padding ${span.startLocation.paddingLine})`
26
+ : "";
27
+ return `${posStr}${i}`;
28
+ };
29
+ const toHex = function* (value) {
30
+ const buff = typeof value === "string"
31
+ ? new Uint8Array(new TextEncoder().encode(value))
32
+ : value;
33
+ const e = 16;
34
+ const hexParts = Array.from(buff).reduce((list, n8, index) => {
35
+ const col = Math.floor(index / e);
36
+ const set = list.get(col) ?? new Set();
37
+ set.add([n8, n8.toString(16).padStart(2, "0").toUpperCase()]);
38
+ list.set(col, set);
39
+ return list;
40
+ }, new Map());
41
+ let colIndex = -1;
42
+ for (const col of hexParts.values()) {
43
+ const i = (++colIndex).toString().padStart(4, " ");
44
+ const hexLine = Array.from(col, ([u8, char]) => char)
45
+ .join(" ")
46
+ .padEnd(e * 3 - 1, " ");
47
+ const asciiRepresentation = new TextDecoder().decode(new Uint8Array(Array.from(col, ([u8]) => (u8 === 0x0a ? [92, 110] : [u8])).flat()));
48
+ yield `${i}: ${hexLine} [${asciiRepresentation}]`;
49
+ }
50
+ };
51
+ expect.extend({
52
+ // to-token-snapshot
53
+ toTokenSnapshot(received, spanName) {
54
+ const lexema = isLexema(received) ? received : null;
55
+ const document = lexema ? Lexema.debugGetDocument(lexema) : null;
56
+ const snapPath = new URL(`${spanName}.snap`, new URL("../__tokens_snapshots__/", import.meta.url));
57
+ const jsonPath = new URL(`${spanName}.snap.json`, new URL("../__tokens_snapshots__/", import.meta.url));
58
+ fs.mkdirSync(new URL("./", snapPath), { recursive: true });
59
+ const inspectTokens = (value) => {
60
+ const spaces = 2;
61
+ const margin = typeof spaces === "number" ? " ".repeat(spaces) : spaces;
62
+ function* lines(input, depth = 0) {
63
+ const lineMargin = margin.repeat(depth);
64
+ const nextLineMargin = margin.repeat(depth + 1);
65
+ if (isLexema(input)) {
66
+ if (document) {
67
+ yield new TextDecoder().decode(document);
68
+ yield "";
69
+ yield "-".repeat(60);
70
+ yield "";
71
+ yield* toHex(document);
72
+ yield "";
73
+ yield "-".repeat(60);
74
+ yield "";
75
+ }
76
+ for (const token of input.tokens) {
77
+ yield* lines(token, depth);
78
+ }
79
+ }
80
+ if (isToken(input)) {
81
+ const token = input;
82
+ const typeStr = KeySyntaxKind[token.type] ?? `Token<${token.type}>`;
83
+ const span = token.span;
84
+ const payload = document
85
+ ? new TextDecoder().decode(document.subarray(span.index, span.index + span.length))
86
+ : null;
87
+ const errorStr = input.getErrors().length
88
+ ? ` - SyntaxError: ${input.getErrors().join(` `)}`
89
+ : ``;
90
+ yield `${lineMargin}Token: [${toSpanStr(span)}] ${typeStr} ${payload ? JSON.stringify(payload) : ""}${errorStr}`;
91
+ for (const part of token.parts) {
92
+ yield* lines(part, depth + 1);
93
+ }
94
+ }
95
+ if (isPart(input)) {
96
+ const part = input;
97
+ const typeStr = KeySyntaxKind[part.type] ?? `Part<${part.type}>`;
98
+ const span = part.span;
99
+ const payload = new TextDecoder().decode(new Uint8Array(part.buffer));
100
+ const payloadHex = Array.from(new Uint8Array(part.buffer), (e) => e.toString(16).padStart(2, "0").toUpperCase()).join(" ");
101
+ yield `${lineMargin}Part#${part.id}: [${toSpanStr(span)}] ${typeStr} [${payloadHex}] ${JSON.stringify(payload)}`;
102
+ }
103
+ if (isPartSet(input)) {
104
+ const buff = new Uint8Array(input.parts.map((part) => part.buffer).flat());
105
+ yield new TextDecoder().decode(buff);
106
+ yield "";
107
+ yield `-`.repeat(60);
108
+ yield "";
109
+ yield* toHex(buff);
110
+ yield "";
111
+ yield `-`.repeat(60);
112
+ yield "";
113
+ const partSet = input;
114
+ for (const part of partSet.parts) {
115
+ yield* lines(part, depth);
116
+ }
117
+ }
118
+ if (isDirectiveArray(input)) {
119
+ for (const directive of input) {
120
+ yield* lines(directive, depth);
121
+ }
122
+ }
123
+ if (isNode(input)) {
124
+ const directiveNode = input;
125
+ const name = directiveNode.name;
126
+ yield `${lineMargin}Directive#${directiveNode.id}: ${name.text() ?? "<unnamed>"} [${toSpanStr(directiveNode.span)}]`;
127
+ yield `${lineMargin}Name: [${toSpanStr(name.span)}] ${name.text()}`;
128
+ if (directiveNode.args.length) {
129
+ yield `${lineMargin}Args:`;
130
+ for (const arg of directiveNode.args) {
131
+ yield `${nextLineMargin}Arg: [${toSpanStr(arg.span)}] ${arg.text()}`;
132
+ }
133
+ }
134
+ for (const child of directiveNode.children) {
135
+ yield* lines(child, depth + 1);
136
+ }
137
+ }
138
+ if (isDocumentNode(input)) {
139
+ const payload = SyntaxEncode.raw.get(input);
140
+ if (typeof payload === "string") {
141
+ yield payload;
142
+ yield "-".repeat(60);
143
+ yield ``;
144
+ yield* toHex(payload);
145
+ yield ``;
146
+ yield "-".repeat(60);
147
+ yield ``;
148
+ }
149
+ yield `Document: [${toSpanStr(input.span)}]`;
150
+ yield* lines(input.children, depth + 1);
151
+ }
152
+ }
153
+ return Array.from(lines(value)).join("\n") + "\n";
154
+ };
155
+ t(() => fs.writeFileSync(snapPath, inspectTokens(received)));
156
+ t(() => fs.writeFileSync(jsonPath, JSON.stringify(received, null, 2)));
157
+ return {
158
+ pass: true,
159
+ };
160
+ },
161
+ });
162
+ //# sourceMappingURL=to-token-snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-token-snapshot.js","sourceRoot":"","sources":["../../../../src/v1/__utils__/to-token-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAE,EAAE,CAClC,OAAO,KAAK,KAAK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+ export declare class DocumentNode {
4
+ readonly children: DirectiveNode[];
5
+ readonly span: Span;
6
+ constructor(children: DirectiveNode[], span: Span);
7
+ static fromNodes(nodes: DirectiveNode[]): DocumentNode;
8
+ }
9
+ export declare class DirectiveNode {
10
+ #private;
11
+ get id(): number;
12
+ readonly name: Token;
13
+ readonly args: Token[];
14
+ readonly children: DirectiveNode[];
15
+ readonly span: Span;
16
+ constructor(name: Token, args: Token[], children: DirectiveNode[]);
17
+ private lastToken;
18
+ toJSON(): {
19
+ id: number;
20
+ name: string;
21
+ args: string[];
22
+ span: Span;
23
+ children: DirectiveNode[];
24
+ };
25
+ }
26
+ //# sourceMappingURL=directive-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive-node.d.ts","sourceRoot":"","sources":["../../../../src/v1/compiler/directive-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAKxC,qBAAa,YAAY;IAErB,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE;IAClC,QAAQ,CAAC,IAAI,EAAE,IAAI;gBADV,QAAQ,EAAE,aAAa,EAAE,EACzB,IAAI,EAAE,IAAI;IAGrB,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE;CAgBxC;AAED,qBAAa,aAAa;;IAGxB,IAAI,EAAE,WAEL;IAED,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;gBAER,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,aAAa,EAAE;IAajE,OAAO,CAAC,SAAS;IAIjB,MAAM;;;;;;;CASP"}
@@ -0,0 +1,48 @@
1
+ import { Span } from "./span.js";
2
+ const cursorIndex = { current: -1 };
3
+ const uid = () => ++cursorIndex.current;
4
+ export class DocumentNode {
5
+ children;
6
+ span;
7
+ constructor(children, span) {
8
+ this.children = children;
9
+ this.span = span;
10
+ }
11
+ static fromNodes(nodes) {
12
+ const first = nodes.at(0);
13
+ const last = nodes.at(-1);
14
+ if (!first || !last)
15
+ throw new Error("nodes cannot be empty");
16
+ return new DocumentNode(nodes, new Span(first.span.index, last.span.index + last.span.length, first.span.startLocation, last.span.endLocation));
17
+ }
18
+ }
19
+ export class DirectiveNode {
20
+ #id = uid();
21
+ get id() {
22
+ return this.#id;
23
+ }
24
+ name;
25
+ args;
26
+ children;
27
+ span;
28
+ constructor(name, args, children) {
29
+ this.name = name;
30
+ this.args = args;
31
+ this.children = children;
32
+ const lastToken = this.lastToken();
33
+ this.span = new Span(this.name.span.index, lastToken.span.index + lastToken.span.length, this.name.span.startLocation, lastToken.span.endLocation);
34
+ }
35
+ lastToken() {
36
+ return this.children.at(-1)?.lastToken() ?? this.args.at(-1) ?? this.name;
37
+ }
38
+ toJSON() {
39
+ return {
40
+ id: this.id,
41
+ name: this.name.text(),
42
+ args: this.args.map((arg) => arg.text()),
43
+ span: this.span,
44
+ children: this.children,
45
+ };
46
+ }
47
+ }
48
+ //# sourceMappingURL=directive-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive-node.js","sourceRoot":"","sources":["../../../../src/v1/compiler/directive-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,WAAW,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC;AACpC,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC;AAExC,MAAM,OAAO,YAAY;IAEZ;IACA;IAFX,YACW,QAAyB,EACzB,IAAU;QADV,aAAQ,GAAR,QAAQ,CAAiB;QACzB,SAAI,GAAJ,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CAAC,WAAW,CAC3B,CAAC;IACJ,CAAC;IAEO,SAAS;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;IAC5E,CAAC;IAED,MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;YACxC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import { PartSet } from "./part-set.js";
2
+ import { Lexema } from "./lexema.js";
3
+ export type LexemaEncodeOptions = {
4
+ /**
5
+ * Enable debug info in output
6
+ */
7
+ debug?: boolean;
8
+ allowDebugDocument?: boolean;
9
+ };
10
+ export declare class LexemaEncode {
11
+ #private;
12
+ constructor(options?: LexemaEncodeOptions);
13
+ encode(input: string | Uint8Array | Iterable<number> | PartSet): Lexema;
14
+ }
15
+ //# sourceMappingURL=lexema-encode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexema-encode.d.ts","sourceRoot":"","sources":["../../../../src/v1/compiler/lexema-encode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,qBAAa,YAAY;;gBAIX,OAAO,CAAC,EAAE,mBAAmB;IAMzC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO;CAc/D"}
@@ -0,0 +1,22 @@
1
+ import { PartSetEncode } from "./part-set-encode.js";
2
+ import { PartSet } from "./part-set.js";
3
+ import { Token } from "./token.js";
4
+ import { Lexema } from "./lexema.js";
5
+ export class LexemaEncode {
6
+ #storeDocument;
7
+ #showInvisibleTokens;
8
+ constructor(options) {
9
+ this.#storeDocument =
10
+ options?.allowDebugDocument ?? options?.debug ?? false;
11
+ this.#showInvisibleTokens = options?.debug ?? false;
12
+ }
13
+ encode(input) {
14
+ const partSet = input instanceof PartSet ? input : new PartSetEncode().encode(input);
15
+ const lexema = new Lexema(Token.scan(partSet, { showInvisibleTokens: this.#showInvisibleTokens }));
16
+ if (this.#storeDocument) {
17
+ Lexema.debugSetDocument(lexema, input);
18
+ }
19
+ return lexema;
20
+ }
21
+ }
22
+ //# sourceMappingURL=lexema-encode.js.map