ranty-js 1.0.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.
Files changed (94) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -0
  3. package/dist/core/binding.d.ts +34 -0
  4. package/dist/core/binding.d.ts.map +1 -0
  5. package/dist/core/compiler/index.d.ts +5 -0
  6. package/dist/core/compiler/index.d.ts.map +1 -0
  7. package/dist/core/compiler/lexer.d.ts +30 -0
  8. package/dist/core/compiler/lexer.d.ts.map +1 -0
  9. package/dist/core/compiler/message.d.ts +4 -0
  10. package/dist/core/compiler/message.d.ts.map +1 -0
  11. package/dist/core/compiler/parser.d.ts +6 -0
  12. package/dist/core/compiler/parser.d.ts.map +1 -0
  13. package/dist/core/compiler/reader.d.ts +12 -0
  14. package/dist/core/compiler/reader.d.ts.map +1 -0
  15. package/dist/core/compiler/token-reader.d.ts +17 -0
  16. package/dist/core/compiler/token-reader.d.ts.map +1 -0
  17. package/dist/core/constants.d.ts +8 -0
  18. package/dist/core/constants.d.ts.map +1 -0
  19. package/dist/core/data-source.d.ts +6 -0
  20. package/dist/core/data-source.d.ts.map +1 -0
  21. package/dist/core/errors.d.ts +56 -0
  22. package/dist/core/errors.d.ts.map +1 -0
  23. package/dist/core/format-state.d.ts +28 -0
  24. package/dist/core/format-state.d.ts.map +1 -0
  25. package/dist/core/int64.d.ts +9 -0
  26. package/dist/core/int64.d.ts.map +1 -0
  27. package/dist/core/lang.d.ts +142 -0
  28. package/dist/core/lang.d.ts.map +1 -0
  29. package/dist/core/map-proto.d.ts +11 -0
  30. package/dist/core/map-proto.d.ts.map +1 -0
  31. package/dist/core/messages.d.ts +28 -0
  32. package/dist/core/messages.d.ts.map +1 -0
  33. package/dist/core/module-resolver.d.ts +22 -0
  34. package/dist/core/module-resolver.d.ts.map +1 -0
  35. package/dist/core/program.d.ts +14 -0
  36. package/dist/core/program.d.ts.map +1 -0
  37. package/dist/core/ranty.d.ts +70 -0
  38. package/dist/core/ranty.d.ts.map +1 -0
  39. package/dist/core/rng.d.ts +17 -0
  40. package/dist/core/rng.d.ts.map +1 -0
  41. package/dist/core/runtime/vm.d.ts +113 -0
  42. package/dist/core/runtime/vm.d.ts.map +1 -0
  43. package/dist/core/stdlib/assertion.d.ts +3 -0
  44. package/dist/core/stdlib/assertion.d.ts.map +1 -0
  45. package/dist/core/stdlib/block.d.ts +3 -0
  46. package/dist/core/stdlib/block.d.ts.map +1 -0
  47. package/dist/core/stdlib/boolean.d.ts +3 -0
  48. package/dist/core/stdlib/boolean.d.ts.map +1 -0
  49. package/dist/core/stdlib/collections.d.ts +3 -0
  50. package/dist/core/stdlib/collections.d.ts.map +1 -0
  51. package/dist/core/stdlib/compare.d.ts +3 -0
  52. package/dist/core/stdlib/compare.d.ts.map +1 -0
  53. package/dist/core/stdlib/convert.d.ts +3 -0
  54. package/dist/core/stdlib/convert.d.ts.map +1 -0
  55. package/dist/core/stdlib/format.d.ts +3 -0
  56. package/dist/core/stdlib/format.d.ts.map +1 -0
  57. package/dist/core/stdlib/general.d.ts +3 -0
  58. package/dist/core/stdlib/general.d.ts.map +1 -0
  59. package/dist/core/stdlib/generate.d.ts +3 -0
  60. package/dist/core/stdlib/generate.d.ts.map +1 -0
  61. package/dist/core/stdlib/index.d.ts +3 -0
  62. package/dist/core/stdlib/index.d.ts.map +1 -0
  63. package/dist/core/stdlib/math.d.ts +3 -0
  64. package/dist/core/stdlib/math.d.ts.map +1 -0
  65. package/dist/core/stdlib/proto.d.ts +3 -0
  66. package/dist/core/stdlib/proto.d.ts.map +1 -0
  67. package/dist/core/stdlib/shared.d.ts +24 -0
  68. package/dist/core/stdlib/shared.d.ts.map +1 -0
  69. package/dist/core/stdlib/strings.d.ts +3 -0
  70. package/dist/core/stdlib/strings.d.ts.map +1 -0
  71. package/dist/core/stdlib/verify.d.ts +3 -0
  72. package/dist/core/stdlib/verify.d.ts.map +1 -0
  73. package/dist/core/util.d.ts +9 -0
  74. package/dist/core/util.d.ts.map +1 -0
  75. package/dist/core/values.d.ts +47 -0
  76. package/dist/core/values.d.ts.map +1 -0
  77. package/dist/core/virtual-module-resolver.d.ts +14 -0
  78. package/dist/core/virtual-module-resolver.d.ts.map +1 -0
  79. package/dist/hosts/browser/index.d.ts +3 -0
  80. package/dist/hosts/browser/index.d.ts.map +1 -0
  81. package/dist/hosts/node/cli-utils.d.ts +18 -0
  82. package/dist/hosts/node/cli-utils.d.ts.map +1 -0
  83. package/dist/hosts/node/cli.d.ts +2 -0
  84. package/dist/hosts/node/cli.d.ts.map +1 -0
  85. package/dist/hosts/node/dev-repl.d.ts +2 -0
  86. package/dist/hosts/node/dev-repl.d.ts.map +1 -0
  87. package/dist/index.d.ts +15 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/ranty.js +9268 -0
  90. package/dist/ranty.js.map +1 -0
  91. package/docs/README.md +24 -0
  92. package/docs/context-system/README.md +85 -0
  93. package/docs/repo-workflow/README.md +40 -0
  94. package/package.json +90 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ranty.js contributors
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 ADDED
@@ -0,0 +1,235 @@
1
+ [![NPM](https://img.shields.io/npm/dy/ranty-js)](https://www.npmjs.com/package/ranty-js)
2
+
3
+ # Ranty.js
4
+
5
+ Ranty.js is the TypeScript port of
6
+ [Ranty](https://github.com/insanityfarm/ranty), a procedural templating
7
+ language and runtime for generating text and structured values.
8
+
9
+ This repository is intentionally downstream of the Rust implementation. Shared
10
+ language, runtime, module, stdlib, and CLI behavior is authored upstream first,
11
+ then ported here against the checked-in parity contract under
12
+ [`./upstream/ranty/`](./upstream/ranty/).
13
+
14
+ ## Documentation
15
+
16
+ - Shared Ranty reference: <https://insanityfarm.github.io/ranty/>
17
+ - Local JS-specific reference: this README
18
+
19
+ ## How To Use The Ranty Docs From Ranty.js
20
+
21
+ Use the hosted Ranty reference for:
22
+
23
+ - language syntax
24
+ - standard-library behavior
25
+ - module semantics
26
+ - runtime concepts
27
+ - CLI semantics that are shared across Rust and JS
28
+
29
+ Use this README for:
30
+
31
+ - package installation and runtime targets
32
+ - Node.js and browser embedding
33
+ - the public JS host API
34
+ - the `ranty-js` CLI package and entrypoint
35
+ - JS-specific differences from the Rust embedding surface
36
+
37
+ When the hosted docs talk about embedding Ranty in Rust, keep the shared
38
+ language and runtime concepts, but ignore the Rust API details. The equivalent
39
+ JS host surface is documented below.
40
+
41
+ ## Runtime Targets
42
+
43
+ - Node.js `>=22.0.0` for library or CLI usage
44
+ - browsers with ES2022 and `BigInt` support
45
+ - package name: `ranty-js`
46
+ - CLI command: `ranty-js`
47
+ - browser bundle: `dist/ranty.js`
48
+ - browser namespace: `globalThis.Ranty`
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ npm install ranty-js
54
+ ```
55
+
56
+ For contributors working in this repository:
57
+
58
+ ```bash
59
+ npm install
60
+ npm run context:build
61
+ npm run verify
62
+ ```
63
+
64
+ ## Node Library Use
65
+
66
+ ```ts
67
+ import { Ranty } from "ranty-js";
68
+
69
+ const ranty = new Ranty({ seed: 0xdeadbeefn });
70
+ const program = ranty.compileQuiet(`
71
+ [$greet:name] {
72
+ {Hello|Hi|Hey}, <name>!
73
+ }
74
+ [greet:world]
75
+ `);
76
+
77
+ console.log(ranty.run(program));
78
+ ```
79
+
80
+ The `Ranty` constructor accepts a partial `RantyOptions` object. The main
81
+ options are:
82
+
83
+ | Option | Meaning |
84
+ | ------------------------ | ------------------------------------------------------------------------------------------------ |
85
+ | `useStdlib` | Load the built-in globals. Disable it to supply a narrower custom prelude. |
86
+ | `debugMode` | Emit richer compiler metadata and runtime diagnostics. |
87
+ | `topLevelDefsAreGlobals` | Keep top-level definitions after a run, which is useful for REPL-like hosts. |
88
+ | `seed` | Set the initial RNG seed as a `number` or `bigint`. |
89
+ | `gcAllocationThreshold` | Reserved parity option; present on the JS API, but manual GC control does not currently do work. |
90
+
91
+ Useful host-side entrypoints include:
92
+
93
+ - `compileQuiet()`, `compileNamed()`, `compileFileQuiet()`
94
+ - `run()` and `runWith()`
95
+ - `setGlobalConst()` and `setGlobal()`
96
+ - `usingModuleResolver()`
97
+ - `addDataSource()` and `clearDataSources()`
98
+ - `Ranty.createVirtualModules()`
99
+
100
+ ## Browser Use
101
+
102
+ Ranty.js ships a UMD bundle. In browsers, the exported symbols live under the
103
+ `globalThis.Ranty` namespace object.
104
+
105
+ ```html
106
+ <script src="./node_modules/ranty-js/dist/ranty.js"></script>
107
+ <script>
108
+ const { Ranty, VirtualModuleResolver } = globalThis.Ranty;
109
+
110
+ const ranty = new Ranty().usingModuleResolver(
111
+ new VirtualModuleResolver({
112
+ "mods/greetings.ranty": '<%module = (:: hello = "browser world")><module>'
113
+ })
114
+ );
115
+
116
+ const program = ranty.compileQuiet(
117
+ '@require "mods/greetings"[greetings/hello]'
118
+ );
119
+
120
+ console.log(ranty.run(program));
121
+ </script>
122
+ ```
123
+
124
+ Browser `@require` is synchronous. The runtime does not fetch modules over the
125
+ network, walk the filesystem, or infer module contents from URLs. Provide
126
+ modules up front through `VirtualModuleResolver` or another host-controlled
127
+ resolver.
128
+
129
+ ## CLI Use
130
+
131
+ The published CLI command is `ranty-js`.
132
+
133
+ ```bash
134
+ npx ranty-js --eval '"hello from ranty-js"'
135
+ npx ranty-js --seed deadbeef --eval '[rand:1;6]'
136
+ npx ranty-js ./example.ranty
137
+ printf '"from stdin"' | npx ranty-js
138
+ ```
139
+
140
+ The Node CLI chooses its launch mode in this order:
141
+
142
+ 1. `--eval PROGRAM`
143
+ 2. `FILE`
144
+ 3. piped stdin
145
+ 4. REPL
146
+
147
+ Supported flags:
148
+
149
+ | Flag | Meaning |
150
+ | ---------------------- | --------------------------------------------------------------------------- |
151
+ | `-e`, `--eval PROGRAM` | Run an inline program string. |
152
+ | `-s`, `--seed SEED` | Set the initial RNG seed as 1 to 16 hexadecimal digits, with optional `0x`. |
153
+ | `-b`, `--bench-mode` | Print compile and execution timing to stderr. |
154
+ | `-W`, `--no-warnings` | Suppress compiler warnings. |
155
+ | `-D`, `--no-debug` | Disable debug symbol emission during compilation. |
156
+ | `-h`, `--help` | Show CLI help. |
157
+ | `-V`, `--version` | Show the build version. |
158
+
159
+ Exit codes:
160
+
161
+ | Code | Meaning |
162
+ | ---- | ------------------------------------------ |
163
+ | `0` | Success |
164
+ | `64` | Invalid CLI usage, such as an invalid seed |
165
+ | `65` | Compilation failed |
166
+ | `66` | Input file not found |
167
+ | `70` | Runtime execution failed |
168
+
169
+ ## Host Integration Example
170
+
171
+ ```ts
172
+ import { Ranty } from "ranty-js";
173
+ import type { DataSource } from "ranty-js";
174
+
175
+ const buildInfo: DataSource = {
176
+ typeId() {
177
+ return "build-info";
178
+ },
179
+
180
+ requestData(args) {
181
+ const channel = String(args[0] ?? "dev");
182
+ return `channel:${channel}`;
183
+ }
184
+ };
185
+
186
+ const ranty = new Ranty();
187
+ ranty.addDataSource(buildInfo);
188
+
189
+ console.log(
190
+ ranty.run(ranty.compileQuiet('[ds-request:"build-info";"stable"]'))
191
+ );
192
+ ```
193
+
194
+ Scripts access registered data sources through `[ds-request: ...]` and can
195
+ enumerate them through `[ds-query-sources]`.
196
+
197
+ ## JS-Specific Differences
198
+
199
+ | Topic | Ranty.js behavior |
200
+ | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
201
+ | Package and command names | The npm package is `ranty-js`, and the packaged binary is `ranty-js`. |
202
+ | Shared docs split | The hosted docs at <https://insanityfarm.github.io/ranty/> are the shared language/runtime reference. This README is the local JS-specific host guide. |
203
+ | Host API naming | The JS API uses camelCase method names such as `compileQuiet()`, `compileNamed()`, `compileFileQuiet()`, `usingModuleResolver()`, and `addDataSource()`. |
204
+ | Error model | Host-side operations throw normal JS errors such as `CompilerError`, `RuntimeError`, `ModuleResolveError`, and `DataSourceError` instead of returning Rust `Result` values. |
205
+ | Return values | `run()` returns native JS values. Text output is a `string`; exact integers may be `bigint`; maps are `Map<string, unknown>`; list and tuple values are arrays; functions are JS callables. |
206
+ | Exact integers and seeds | Integer-heavy APIs accept `number` or `bigint`. `RantyInt` preserves signed i64 semantics, and `toApiValue()` returns a `number` only when the value stays inside the safe integer range. |
207
+ | Node module resolution | `DefaultModuleResolver` checks the dependant file directory first, then `localModulesPath` or `process.cwd()`, then `RANTY_MODULES_PATH` when global modules are enabled. When no extension is supplied, `.ranty` is preferred before `.rant`. |
208
+ | Browser module loading | In browsers, `@require` only works through host-supplied resolvers such as `VirtualModuleResolver`. The runtime does not perform ambient filesystem or network lookup. |
209
+ | Data sources | Implement the `DataSource` interface and register it with `addDataSource()`. Scripts consume these integrations through `[ds-request: ...]` and `[ds-query-sources]`. |
210
+ | Bundle shape | `dist/ranty.js` is a UMD bundle. Browser consumers read exports from `globalThis.Ranty`, for example `globalThis.Ranty.Ranty` and `globalThis.Ranty.VirtualModuleResolver`. |
211
+ | GC and ownership notes | Rust ownership and borrowing guidance does not apply directly. `gcAllocationThreshold` remains part of the options surface for parity, and `collectGarbage()` is currently a no-op in the JS runtime. |
212
+
213
+ ## Upstream Parity
214
+
215
+ - The Rust repo at [insanityfarm/ranty](https://github.com/insanityfarm/ranty)
216
+ is authoritative for shared language and runtime behavior.
217
+ - The vendored upstream bundle lives under [`./upstream/ranty/`](./upstream/ranty/).
218
+ - Refresh it with `npm run upstream:sync -- --ref=<rust-sha-or-branch>`.
219
+ - CI runs `npm run upstream:check-freshness` and only blocks pull requests that
220
+ touch core, public API, or build-sensitive surfaces while the local parity
221
+ lock is behind upstream Rust `main`.
222
+
223
+ ## Contributor Workflow
224
+
225
+ - Read [`./spec/README.md`](./spec/README.md).
226
+ - Read [`./glossary/README.md`](./glossary/README.md).
227
+ - Read [`./AGENTS.md`](./AGENTS.md).
228
+ - Run `npm run context:task -- "<task>"` before editing.
229
+ - Run `npm run context:build` after changing glossary terms, subsystem records,
230
+ or ADRs.
231
+ - Run `npm run verify` before treating a change as done.
232
+
233
+ ## License
234
+
235
+ MIT. See [`./LICENSE`](./LICENSE).
@@ -0,0 +1,34 @@
1
+ import type { Sequence } from "./lang";
2
+ import type { RantyValue } from "./values";
3
+ export interface LazyThunk {
4
+ readonly name: string | null;
5
+ readonly expr: Sequence;
6
+ readonly scopes: readonly Map<string, RantyBinding>[];
7
+ }
8
+ export interface PendingLazyState {
9
+ readonly kind: "pending";
10
+ readonly thunk: LazyThunk;
11
+ }
12
+ export interface EvaluatingLazyState {
13
+ readonly kind: "evaluating";
14
+ readonly thunk: LazyThunk;
15
+ }
16
+ export interface ReadyLazyState {
17
+ readonly kind: "ready";
18
+ readonly value: RantyValue;
19
+ }
20
+ export type LazyState = PendingLazyState | EvaluatingLazyState | ReadyLazyState;
21
+ export interface ValueBinding {
22
+ kind: "value";
23
+ value: RantyValue;
24
+ readonly const: boolean;
25
+ }
26
+ export interface LazyBinding {
27
+ kind: "lazy";
28
+ state: LazyState;
29
+ readonly const: boolean;
30
+ }
31
+ export type RantyBinding = ValueBinding | LazyBinding;
32
+ export declare function valueBinding(value: RantyValue, isConst?: boolean): RantyBinding;
33
+ export declare function lazyBinding(thunk: LazyThunk, isConst?: boolean): RantyBinding;
34
+ //# sourceMappingURL=binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/core/binding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;CACvD;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,cAAc,CAAC;AAEhF,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,WAAW,CAAC;AAEtD,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,UAAQ,GAAG,YAAY,CAM7E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,UAAQ,GAAG,YAAY,CAS3E"}
@@ -0,0 +1,5 @@
1
+ import type { Reporter } from "../messages";
2
+ import { RantyProgram, type RantyProgramInfo } from "../program";
3
+ export declare function compileString(source: string, reporter: Reporter, _debugEnabled: boolean, info?: RantyProgramInfo): RantyProgram;
4
+ export declare function compileFile(path: string, reporter: Reporter, debugEnabled: boolean): RantyProgram;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/compiler/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMjE,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,OAAO,EACtB,IAAI,GAAE,gBAAqB,GAC1B,YAAY,CAId;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,OAAO,GACpB,YAAY,CAyCd"}
@@ -0,0 +1,30 @@
1
+ import type { Reporter } from "../messages";
2
+ interface TokenBase {
3
+ readonly start: number;
4
+ readonly end: number;
5
+ }
6
+ export type RantyToken = (TokenBase & {
7
+ readonly type: "whitespace";
8
+ readonly value: string;
9
+ }) | (TokenBase & {
10
+ readonly type: "comment";
11
+ readonly value: string;
12
+ }) | (TokenBase & {
13
+ readonly type: "string";
14
+ readonly value: string;
15
+ readonly raw: string;
16
+ }) | (TokenBase & {
17
+ readonly type: "number";
18
+ readonly value: string;
19
+ }) | (TokenBase & {
20
+ readonly type: "identifier";
21
+ readonly value: string;
22
+ }) | (TokenBase & {
23
+ readonly type: "symbol";
24
+ readonly value: string;
25
+ }) | (TokenBase & {
26
+ readonly type: "eof";
27
+ });
28
+ export declare function lex(source: string, reporter: Reporter): RantyToken[];
29
+ export {};
30
+ //# sourceMappingURL=lexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../../src/core/compiler/lexer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,UAAU,SAAS;IACjB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAClB,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC,GACF,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC,GACF,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC,GACF,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC,GACF,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC,GACF,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC,GACF,CAAC,SAAS,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;CACtB,CAAC,CAAC;AAmFP,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,UAAU,EAAE,CA6JpE"}
@@ -0,0 +1,4 @@
1
+ import { type Reporter, type Severity } from "../messages";
2
+ export declare function reportCompilerMessage(reporter: Reporter, code: string, message: string, severity: Severity, start: number, end: number, inlineMessage?: string): void;
3
+ export declare function nullReporter(): Reporter;
4
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/core/compiler/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,aAAa,CAAC,EAAE,MAAM,GACrB,IAAI,CAmBN;AAED,wBAAgB,YAAY,IAAI,QAAQ,CAIvC"}
@@ -0,0 +1,6 @@
1
+ import type { Sequence } from "../lang";
2
+ import type { Reporter } from "../messages";
3
+ import { type RantyToken } from "./lexer";
4
+ export declare function parse(source: string, reporter: Reporter): Sequence;
5
+ export declare function parseTokens(tokens: readonly RantyToken[], source: string, reporter: Reporter): Sequence;
6
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/core/compiler/parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAiBV,QAAQ,EAOT,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAO,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AA+yG/C,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAElE;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CAEV"}
@@ -0,0 +1,12 @@
1
+ export declare class SourceReader {
2
+ #private;
3
+ readonly source: string;
4
+ constructor(source: string);
5
+ index(): number;
6
+ setIndex(index: number): void;
7
+ isEof(): boolean;
8
+ peek(offset?: number): string | undefined;
9
+ next(): string | undefined;
10
+ consumeWhile(predicate: (char: string) => boolean): string;
11
+ }
12
+ //# sourceMappingURL=reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/core/compiler/reader.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGZ,MAAM,EAAE,MAAM;IAI1B,KAAK,IAAI,MAAM;IAIf,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B,KAAK,IAAI,OAAO;IAIhB,IAAI,CAAC,MAAM,SAAI,GAAG,MAAM,GAAG,SAAS;IAIpC,IAAI,IAAI,MAAM,GAAG,SAAS;IAQ1B,YAAY,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM;CAW3D"}
@@ -0,0 +1,17 @@
1
+ import type { RantyToken } from "./lexer";
2
+ export declare class TokenReader {
3
+ #private;
4
+ readonly source: string;
5
+ readonly tokens: readonly RantyToken[];
6
+ constructor(tokens: readonly RantyToken[], source: string);
7
+ mark(): number;
8
+ reset(mark: number): void;
9
+ index(): number;
10
+ isEof(): boolean;
11
+ peek(offset?: number): RantyToken | undefined;
12
+ peekRaw(offset?: number): RantyToken | undefined;
13
+ next(): RantyToken | undefined;
14
+ consumeTrivia(): void;
15
+ currentToken(): RantyToken | undefined;
16
+ }
17
+ //# sourceMappingURL=token-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-reader.d.ts","sourceRoot":"","sources":["../../../src/core/compiler/token-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAM1C,qBAAa,WAAW;;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,CAAC;gBAG3B,MAAM,EAAE,SAAS,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM;IAKzD,IAAI,IAAI,MAAM;IAId,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIzB,KAAK,IAAI,MAAM;IAIf,KAAK,IAAI,OAAO;IAIhB,IAAI,CAAC,MAAM,SAAI,GAAG,UAAU,GAAG,SAAS;IAOxC,OAAO,CAAC,MAAM,SAAI,GAAG,UAAU,GAAG,SAAS;IAI3C,IAAI,IAAI,UAAU,GAAG,SAAS;IAQ9B,aAAa,IAAI,IAAI;IAMrB,YAAY,IAAI,UAAU,GAAG,SAAS;CAGvC"}
@@ -0,0 +1,8 @@
1
+ export declare const BUILD_VERSION = "1.0.0";
2
+ export declare const RANTY_LANG_VERSION = "1.0.0";
3
+ export declare const DEFAULT_PROGRAM_NAME = "program";
4
+ export declare const RANTY_FILE_EXTENSION = "ranty";
5
+ export declare const RANTY_COMPAT_FILE_EXTENSION = "rant";
6
+ export declare const RANTY_SUPPORTED_FILE_EXTENSIONS: readonly ["ranty", "rant"];
7
+ export declare const MODULES_CACHE_KEY = "__MODULES";
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAC1C,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,oBAAoB,UAAU,CAAC;AAC5C,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAClD,eAAO,MAAM,+BAA+B,4BAGlC,CAAC;AACX,eAAO,MAAM,iBAAiB,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { RantyValue } from "./values";
2
+ export interface DataSource {
3
+ typeId(): string;
4
+ requestData(args: readonly RantyValue[]): RantyValue;
5
+ }
6
+ //# sourceMappingURL=data-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-source.d.ts","sourceRoot":"","sources":["../../src/core/data-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,MAAM,IAAI,MAAM,CAAC;IACjB,WAAW,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAAC;CACtD"}
@@ -0,0 +1,56 @@
1
+ import type { CompilerMessage } from "./messages";
2
+ export type CompilerErrorKind = "syntax" | "io";
3
+ export declare class CompilerError extends Error {
4
+ readonly kind: CompilerErrorKind;
5
+ constructor(kind: CompilerErrorKind, message?: string);
6
+ }
7
+ export type ModuleResolveErrorReason = {
8
+ readonly kind: "not_found";
9
+ } | {
10
+ readonly kind: "compile_failed";
11
+ readonly messages: readonly CompilerMessage[];
12
+ } | {
13
+ readonly kind: "file_io_error";
14
+ readonly error: unknown;
15
+ };
16
+ export declare class ModuleResolveError extends Error {
17
+ readonly moduleName: string;
18
+ readonly reason: ModuleResolveErrorReason;
19
+ constructor(moduleName: string, reason: ModuleResolveErrorReason);
20
+ }
21
+ export declare class ModuleLoadError extends Error {
22
+ constructor(message: string);
23
+ }
24
+ export declare class DataSourceError extends Error {
25
+ readonly type: "user" | "internal";
26
+ constructor(type: "user" | "internal", message: string);
27
+ }
28
+ export declare enum RuntimeErrorType {
29
+ StackOverflow = "STACK_OVERFLOW_ERROR",
30
+ StackUnderflow = "STACK_UNDERFLOW_ERROR",
31
+ InvalidAccess = "INVALID_ACCESS_ERROR",
32
+ InvalidOperation = "INVALID_OP_ERROR",
33
+ LazyBindingCycle = "LAZY_BINDING_CYCLE_ERROR",
34
+ InternalError = "INTERNAL_ERROR",
35
+ ArgumentMismatch = "ARG_MISMATCH_ERROR",
36
+ ArgumentError = "ARG_ERROR",
37
+ CannotInvokeValue = "INVOKE_ERROR",
38
+ AssertError = "ASSERT_ERROR",
39
+ TypeError = "TYPE_ERROR",
40
+ ValueError = "VALUE_ERROR",
41
+ IndexError = "INDEX_ERROR",
42
+ KeyError = "KEY_ERROR",
43
+ SliceError = "SLICE_ERROR",
44
+ SelectorError = "SELECTOR_ERROR",
45
+ ModuleError = "MODULE_ERROR",
46
+ UserError = "USER_ERROR",
47
+ ControlFlowError = "CONTROL_FLOW_ERROR",
48
+ DataSourceError = "DATA_SOURCE_ERROR"
49
+ }
50
+ export declare class RuntimeError extends Error {
51
+ readonly errorType: RuntimeErrorType;
52
+ readonly description: string | undefined;
53
+ readonly stackTrace: string | undefined;
54
+ constructor(errorType: RuntimeErrorType, description?: string, stackTrace?: string);
55
+ }
56
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,IAAI,CAAC;AAEhD,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;gBAErB,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM;CAKtD;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAC9B;IACE,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;CAC/C,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;gBAE9B,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB;CAYjE;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;gBAEvB,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,EAAE,MAAM;CAKvD;AAED,oBAAY,gBAAgB;IAC1B,aAAa,yBAAyB;IACtC,cAAc,0BAA0B;IACxC,aAAa,yBAAyB;IACtC,gBAAgB,qBAAqB;IACrC,gBAAgB,6BAA6B;IAC7C,aAAa,mBAAmB;IAChC,gBAAgB,uBAAuB;IACvC,aAAa,cAAc;IAC3B,iBAAiB,iBAAiB;IAClC,WAAW,iBAAiB;IAC5B,SAAS,eAAe;IACxB,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,UAAU,gBAAgB;IAC1B,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;IAC5B,SAAS,eAAe;IACxB,gBAAgB,uBAAuB;IACvC,eAAe,sBAAsB;CACtC;AAED,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAGtC,SAAS,EAAE,gBAAgB,EAC3B,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM;CAQtB"}
@@ -0,0 +1,28 @@
1
+ import type { RantyValue } from "./values";
2
+ export type WhitespaceFormatMode = "default" | "ignore-all" | "verbatim" | "custom";
3
+ export type NumeralSystem = "west-arabic" | "east-arabic" | "persian" | "roman" | "babylonian" | "hex" | "octal" | "binary" | "alpha";
4
+ export type Endianness = "big" | "little";
5
+ export type SignStyle = "negative-only" | "explicit" | "explicit-non-zero";
6
+ export type InfinityStyle = "keyword" | "symbol";
7
+ export interface WhitespaceFormatState {
8
+ mode: WhitespaceFormatMode;
9
+ customValue: RantyValue;
10
+ }
11
+ export interface NumberFormatState {
12
+ system: NumeralSystem;
13
+ alt: boolean;
14
+ precision: number | null;
15
+ padding: number;
16
+ upper: boolean;
17
+ endian: Endianness;
18
+ sign: SignStyle;
19
+ infinity: InfinityStyle;
20
+ groupSep: string;
21
+ decimalSep: string;
22
+ }
23
+ export interface OutputFormatState {
24
+ whitespace: WhitespaceFormatState;
25
+ number: NumberFormatState;
26
+ }
27
+ export declare function defaultOutputFormatState(): OutputFormatState;
28
+ //# sourceMappingURL=format-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-state.d.ts","sourceRoot":"","sources":["../../src/core/format-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,MAAM,oBAAoB,GAC5B,SAAS,GACT,YAAY,GACZ,UAAU,GACV,QAAQ,CAAC;AACb,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,aAAa,GACb,SAAS,GACT,OAAO,GACP,YAAY,GACZ,KAAK,GACL,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AACZ,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;AAC1C,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,UAAU,GAAG,mBAAmB,CAAC;AAC3E,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,WAAW,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,aAAa,CAAC;IACtB,GAAG,EAAE,OAAO,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,qBAAqB,CAAC;IAClC,MAAM,EAAE,iBAAiB,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,IAAI,iBAAiB,CAmB5D"}
@@ -0,0 +1,9 @@
1
+ export declare class RantyInt {
2
+ readonly value: bigint;
3
+ private constructor();
4
+ static from(value: bigint | number | string | RantyInt): RantyInt;
5
+ toApiValue(): bigint | number;
6
+ toString(): string;
7
+ }
8
+ export declare function toExactInt(value: bigint | number | string | RantyInt): bigint;
9
+ //# sourceMappingURL=int64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"int64.d.ts","sourceRoot":"","sources":["../../src/core/int64.ts"],"names":[],"mappings":"AAaA,qBAAa,QAAQ;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,OAAO;IAIP,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ;IAoBjE,UAAU,IAAI,MAAM,GAAG,MAAM;IAQ7B,QAAQ,IAAI,MAAM;CAGnB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAE7E"}