@rcrsr/rill 0.1.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/LICENSE +21 -0
- package/README.md +187 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +69 -0
- package/dist/cli.js.map +1 -0
- package/dist/demo.d.ts +6 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/demo.js +121 -0
- package/dist/demo.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/errors.d.ts +9 -0
- package/dist/lexer/errors.d.ts.map +1 -0
- package/dist/lexer/errors.js +12 -0
- package/dist/lexer/errors.js.map +1 -0
- package/dist/lexer/helpers.d.ts +14 -0
- package/dist/lexer/helpers.d.ts.map +1 -0
- package/dist/lexer/helpers.js +30 -0
- package/dist/lexer/helpers.js.map +1 -0
- package/dist/lexer/index.d.ts +8 -0
- package/dist/lexer/index.d.ts.map +1 -0
- package/dist/lexer/index.js +8 -0
- package/dist/lexer/index.js.map +1 -0
- package/dist/lexer/operators.d.ts +11 -0
- package/dist/lexer/operators.d.ts.map +1 -0
- package/dist/lexer/operators.js +58 -0
- package/dist/lexer/operators.js.map +1 -0
- package/dist/lexer/readers.d.ts +12 -0
- package/dist/lexer/readers.d.ts.map +1 -0
- package/dist/lexer/readers.js +144 -0
- package/dist/lexer/readers.js.map +1 -0
- package/dist/lexer/state.d.ts +18 -0
- package/dist/lexer/state.d.ts.map +1 -0
- package/dist/lexer/state.js +37 -0
- package/dist/lexer/state.js.map +1 -0
- package/dist/lexer/tokenizer.d.ts +9 -0
- package/dist/lexer/tokenizer.d.ts.map +1 -0
- package/dist/lexer/tokenizer.js +100 -0
- package/dist/lexer/tokenizer.js.map +1 -0
- package/dist/lexer.d.ts +19 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +344 -0
- package/dist/lexer.js.map +1 -0
- package/dist/parser/arithmetic.d.ts +16 -0
- package/dist/parser/arithmetic.d.ts.map +1 -0
- package/dist/parser/arithmetic.js +128 -0
- package/dist/parser/arithmetic.js.map +1 -0
- package/dist/parser/boolean.d.ts +15 -0
- package/dist/parser/boolean.d.ts.map +1 -0
- package/dist/parser/boolean.js +20 -0
- package/dist/parser/boolean.js.map +1 -0
- package/dist/parser/control-flow.d.ts +56 -0
- package/dist/parser/control-flow.d.ts.map +1 -0
- package/dist/parser/control-flow.js +167 -0
- package/dist/parser/control-flow.js.map +1 -0
- package/dist/parser/expressions.d.ts +23 -0
- package/dist/parser/expressions.d.ts.map +1 -0
- package/dist/parser/expressions.js +950 -0
- package/dist/parser/expressions.js.map +1 -0
- package/dist/parser/extraction.d.ts +48 -0
- package/dist/parser/extraction.d.ts.map +1 -0
- package/dist/parser/extraction.js +279 -0
- package/dist/parser/extraction.js.map +1 -0
- package/dist/parser/functions.d.ts +20 -0
- package/dist/parser/functions.d.ts.map +1 -0
- package/dist/parser/functions.js +96 -0
- package/dist/parser/functions.js.map +1 -0
- package/dist/parser/helpers.d.ts +94 -0
- package/dist/parser/helpers.d.ts.map +1 -0
- package/dist/parser/helpers.js +225 -0
- package/dist/parser/helpers.js.map +1 -0
- package/dist/parser/index.d.ts +49 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +73 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/literals.d.ts +37 -0
- package/dist/parser/literals.d.ts.map +1 -0
- package/dist/parser/literals.js +373 -0
- package/dist/parser/literals.js.map +1 -0
- package/dist/parser/parser-collect.d.ts +16 -0
- package/dist/parser/parser-collect.d.ts.map +1 -0
- package/dist/parser/parser-collect.js +125 -0
- package/dist/parser/parser-collect.js.map +1 -0
- package/dist/parser/parser-control.d.ts +20 -0
- package/dist/parser/parser-control.d.ts.map +1 -0
- package/dist/parser/parser-control.js +120 -0
- package/dist/parser/parser-control.js.map +1 -0
- package/dist/parser/parser-expr.d.ts +37 -0
- package/dist/parser/parser-expr.d.ts.map +1 -0
- package/dist/parser/parser-expr.js +639 -0
- package/dist/parser/parser-expr.js.map +1 -0
- package/dist/parser/parser-extract.d.ts +17 -0
- package/dist/parser/parser-extract.d.ts.map +1 -0
- package/dist/parser/parser-extract.js +222 -0
- package/dist/parser/parser-extract.js.map +1 -0
- package/dist/parser/parser-functions.d.ts +21 -0
- package/dist/parser/parser-functions.d.ts.map +1 -0
- package/dist/parser/parser-functions.js +155 -0
- package/dist/parser/parser-functions.js.map +1 -0
- package/dist/parser/parser-literals.d.ts +22 -0
- package/dist/parser/parser-literals.d.ts.map +1 -0
- package/dist/parser/parser-literals.js +288 -0
- package/dist/parser/parser-literals.js.map +1 -0
- package/dist/parser/parser-script.d.ts +21 -0
- package/dist/parser/parser-script.d.ts.map +1 -0
- package/dist/parser/parser-script.js +174 -0
- package/dist/parser/parser-script.js.map +1 -0
- package/dist/parser/parser-variables.d.ts +20 -0
- package/dist/parser/parser-variables.d.ts.map +1 -0
- package/dist/parser/parser-variables.js +146 -0
- package/dist/parser/parser-variables.js.map +1 -0
- package/dist/parser/parser.d.ts +49 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +54 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/parser/script.d.ts +14 -0
- package/dist/parser/script.d.ts.map +1 -0
- package/dist/parser/script.js +196 -0
- package/dist/parser/script.js.map +1 -0
- package/dist/parser/state.d.ts +40 -0
- package/dist/parser/state.d.ts.map +1 -0
- package/dist/parser/state.js +129 -0
- package/dist/parser/state.js.map +1 -0
- package/dist/parser/variables.d.ts +10 -0
- package/dist/parser/variables.d.ts.map +1 -0
- package/dist/parser/variables.js +215 -0
- package/dist/parser/variables.js.map +1 -0
- package/dist/runtime/ast-equals.d.ts +13 -0
- package/dist/runtime/ast-equals.d.ts.map +1 -0
- package/dist/runtime/ast-equals.js +447 -0
- package/dist/runtime/ast-equals.js.map +1 -0
- package/dist/runtime/builtins.d.ts +13 -0
- package/dist/runtime/builtins.d.ts.map +1 -0
- package/dist/runtime/builtins.js +180 -0
- package/dist/runtime/builtins.js.map +1 -0
- package/dist/runtime/callable.d.ts +88 -0
- package/dist/runtime/callable.d.ts.map +1 -0
- package/dist/runtime/callable.js +98 -0
- package/dist/runtime/callable.js.map +1 -0
- package/dist/runtime/context.d.ts +13 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +73 -0
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/core/callable.d.ts +171 -0
- package/dist/runtime/core/callable.d.ts.map +1 -0
- package/dist/runtime/core/callable.js +246 -0
- package/dist/runtime/core/callable.js.map +1 -0
- package/dist/runtime/core/context.d.ts +29 -0
- package/dist/runtime/core/context.d.ts.map +1 -0
- package/dist/runtime/core/context.js +154 -0
- package/dist/runtime/core/context.js.map +1 -0
- package/dist/runtime/core/equals.d.ts +9 -0
- package/dist/runtime/core/equals.d.ts.map +1 -0
- package/dist/runtime/core/equals.js +381 -0
- package/dist/runtime/core/equals.js.map +1 -0
- package/dist/runtime/core/eval/base.d.ts +65 -0
- package/dist/runtime/core/eval/base.d.ts.map +1 -0
- package/dist/runtime/core/eval/base.js +112 -0
- package/dist/runtime/core/eval/base.js.map +1 -0
- package/dist/runtime/core/eval/evaluator.d.ts +47 -0
- package/dist/runtime/core/eval/evaluator.d.ts.map +1 -0
- package/dist/runtime/core/eval/evaluator.js +73 -0
- package/dist/runtime/core/eval/evaluator.js.map +1 -0
- package/dist/runtime/core/eval/index.d.ts +57 -0
- package/dist/runtime/core/eval/index.d.ts.map +1 -0
- package/dist/runtime/core/eval/index.js +95 -0
- package/dist/runtime/core/eval/index.js.map +1 -0
- package/dist/runtime/core/eval/mixins/annotations.d.ts +19 -0
- package/dist/runtime/core/eval/mixins/annotations.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/annotations.js +146 -0
- package/dist/runtime/core/eval/mixins/annotations.js.map +1 -0
- package/dist/runtime/core/eval/mixins/closures.d.ts +49 -0
- package/dist/runtime/core/eval/mixins/closures.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/closures.js +479 -0
- package/dist/runtime/core/eval/mixins/closures.js.map +1 -0
- package/dist/runtime/core/eval/mixins/collections.d.ts +24 -0
- package/dist/runtime/core/eval/mixins/collections.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/collections.js +466 -0
- package/dist/runtime/core/eval/mixins/collections.js.map +1 -0
- package/dist/runtime/core/eval/mixins/control-flow.d.ts +27 -0
- package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/control-flow.js +369 -0
- package/dist/runtime/core/eval/mixins/control-flow.js.map +1 -0
- package/dist/runtime/core/eval/mixins/core.d.ts +24 -0
- package/dist/runtime/core/eval/mixins/core.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/core.js +335 -0
- package/dist/runtime/core/eval/mixins/core.js.map +1 -0
- package/dist/runtime/core/eval/mixins/expressions.d.ts +19 -0
- package/dist/runtime/core/eval/mixins/expressions.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/expressions.js +202 -0
- package/dist/runtime/core/eval/mixins/expressions.js.map +1 -0
- package/dist/runtime/core/eval/mixins/extraction.d.ts +10 -0
- package/dist/runtime/core/eval/mixins/extraction.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/extraction.js +250 -0
- package/dist/runtime/core/eval/mixins/extraction.js.map +1 -0
- package/dist/runtime/core/eval/mixins/literals.d.ts +23 -0
- package/dist/runtime/core/eval/mixins/literals.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/literals.js +180 -0
- package/dist/runtime/core/eval/mixins/literals.js.map +1 -0
- package/dist/runtime/core/eval/mixins/types.d.ts +20 -0
- package/dist/runtime/core/eval/mixins/types.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/types.js +109 -0
- package/dist/runtime/core/eval/mixins/types.js.map +1 -0
- package/dist/runtime/core/eval/mixins/variables.d.ts +34 -0
- package/dist/runtime/core/eval/mixins/variables.d.ts.map +1 -0
- package/dist/runtime/core/eval/mixins/variables.js +247 -0
- package/dist/runtime/core/eval/mixins/variables.js.map +1 -0
- package/dist/runtime/core/eval/types.d.ts +41 -0
- package/dist/runtime/core/eval/types.d.ts.map +1 -0
- package/dist/runtime/core/eval/types.js +10 -0
- package/dist/runtime/core/eval/types.js.map +1 -0
- package/dist/runtime/core/evaluate.d.ts +42 -0
- package/dist/runtime/core/evaluate.d.ts.map +1 -0
- package/dist/runtime/core/evaluate.debug.js +1251 -0
- package/dist/runtime/core/evaluate.js +1913 -0
- package/dist/runtime/core/evaluate.js.map +1 -0
- package/dist/runtime/core/execute.d.ts +26 -0
- package/dist/runtime/core/execute.d.ts.map +1 -0
- package/dist/runtime/core/execute.js +177 -0
- package/dist/runtime/core/execute.js.map +1 -0
- package/dist/runtime/core/signals.d.ts +19 -0
- package/dist/runtime/core/signals.d.ts.map +1 -0
- package/dist/runtime/core/signals.js +26 -0
- package/dist/runtime/core/signals.js.map +1 -0
- package/dist/runtime/core/types.d.ts +177 -0
- package/dist/runtime/core/types.d.ts.map +1 -0
- package/dist/runtime/core/types.js +50 -0
- package/dist/runtime/core/types.js.map +1 -0
- package/dist/runtime/core/values.d.ts +66 -0
- package/dist/runtime/core/values.d.ts.map +1 -0
- package/dist/runtime/core/values.js +240 -0
- package/dist/runtime/core/values.js.map +1 -0
- package/dist/runtime/evaluate.d.ts +32 -0
- package/dist/runtime/evaluate.d.ts.map +1 -0
- package/dist/runtime/evaluate.js +1111 -0
- package/dist/runtime/evaluate.js.map +1 -0
- package/dist/runtime/execute.d.ts +26 -0
- package/dist/runtime/execute.d.ts.map +1 -0
- package/dist/runtime/execute.js +121 -0
- package/dist/runtime/execute.js.map +1 -0
- package/dist/runtime/ext/builtins.d.ts +16 -0
- package/dist/runtime/ext/builtins.d.ts.map +1 -0
- package/dist/runtime/ext/builtins.js +528 -0
- package/dist/runtime/ext/builtins.js.map +1 -0
- package/dist/runtime/ext/content-parser.d.ts +83 -0
- package/dist/runtime/ext/content-parser.d.ts.map +1 -0
- package/dist/runtime/ext/content-parser.js +536 -0
- package/dist/runtime/ext/content-parser.js.map +1 -0
- package/dist/runtime/index.d.ts +28 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +34 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/signals.d.ts +19 -0
- package/dist/runtime/signals.d.ts.map +1 -0
- package/dist/runtime/signals.js +26 -0
- package/dist/runtime/signals.js.map +1 -0
- package/dist/runtime/types.d.ts +169 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +50 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/values.d.ts +50 -0
- package/dist/runtime/values.d.ts.map +1 -0
- package/dist/runtime/values.js +209 -0
- package/dist/runtime/values.js.map +1 -0
- package/dist/runtime.d.ts +254 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +2014 -0
- package/dist/runtime.js.map +1 -0
- package/dist/types.d.ts +752 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +189 -0
- package/dist/types.js.map +1 -0
- package/docs/00_INDEX.md +65 -0
- package/docs/01_guide.md +390 -0
- package/docs/02_types.md +399 -0
- package/docs/03_variables.md +314 -0
- package/docs/04_operators.md +551 -0
- package/docs/05_control-flow.md +350 -0
- package/docs/06_closures.md +353 -0
- package/docs/07_collections.md +686 -0
- package/docs/08_iterators.md +330 -0
- package/docs/09_strings.md +205 -0
- package/docs/10_parsing.md +366 -0
- package/docs/11_reference.md +350 -0
- package/docs/12_examples.md +771 -0
- package/docs/13_modules.md +519 -0
- package/docs/14_host-integration.md +826 -0
- package/docs/15_grammar.ebnf +693 -0
- package/docs/16_conventions.md +696 -0
- package/docs/99_llm-reference.txt +300 -0
- package/docs/assets/logo.png +0 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andre Bremer
|
|
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,187 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/assets/logo.png" alt="rill logo" width="280">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
*Embeddable workflow language for LLM orchestration*
|
|
6
|
+
|
|
7
|
+
> [!WARNING]
|
|
8
|
+
> **This language is experimental.** While usable, there may be significant bugs. Breaking changes will occur until v1.0.
|
|
9
|
+
|
|
10
|
+
## Why rill?
|
|
11
|
+
|
|
12
|
+
rill enables platform builders to make their apps scriptable without exposing arbitrary code execution.
|
|
13
|
+
|
|
14
|
+
rill solves for AI platforms what Lua solves for game engines and Liquid solves for e-commerce: safe, user-authored logic.
|
|
15
|
+
|
|
16
|
+
- **Embeddable.** Zero dependencies. Runs in browser or backend. [Integration](docs/14_host-integration.md) only requires a few lines of code.
|
|
17
|
+
- **Sandboxed.** Users can only call functions you explicitly provide. No filesystem, no network, no `eval()` disasters.
|
|
18
|
+
- **Bounded execution.** Retry limits prevent exhausting LLM usage limits because of runaway loops.
|
|
19
|
+
- **Consistent, clean syntax.** Ships with [EBNF grammar](docs/15_grammar.ebnf). LLMs can write rill scripts for your users.
|
|
20
|
+
- **Built-in LLM output parsing.** [Auto-detect](docs/10_parsing.md) JSON, XML, YAML, checklists.
|
|
21
|
+
|
|
22
|
+
## Who is this for?
|
|
23
|
+
|
|
24
|
+
**Platform builders** who want power users to define custom LLM workflows without hand-coding each one.
|
|
25
|
+
|
|
26
|
+
rill is not a general-purpose language and it's intentionally constrained. For general application development, you'll want TypeScript, Python, or Go.
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { parse, execute, createRuntimeContext } from '@rcrsr/rill';
|
|
32
|
+
|
|
33
|
+
const script = `
|
|
34
|
+
prompt("Analyze this code for issues")
|
|
35
|
+
-> .contains("ERROR") ? error($) ! "Analysis complete"
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const ctx = createRuntimeContext({
|
|
39
|
+
functions: {
|
|
40
|
+
prompt: async (args) => await callYourLLM(args[0]),
|
|
41
|
+
error: (args) => { throw new Error(String(args[0])); },
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const result = await execute(parse(script), ctx);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Language Overview
|
|
49
|
+
|
|
50
|
+
### Pipes
|
|
51
|
+
|
|
52
|
+
Data flows forward through pipes (`app::*` denotes an application-specific host function call).
|
|
53
|
+
|
|
54
|
+
```rill
|
|
55
|
+
app::prompt("analyze this code") -> .trim -> log
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Pattern-Driven Conditionals
|
|
59
|
+
|
|
60
|
+
Branch based on content patterns. Ideal for parsing LLM output.
|
|
61
|
+
|
|
62
|
+
```rill
|
|
63
|
+
app::prompt("analyze code")
|
|
64
|
+
-> .contains("ERROR") ? app::error() ! app::process()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Bounded Loops
|
|
68
|
+
|
|
69
|
+
Retry with limits. Prevents runaway execution.
|
|
70
|
+
|
|
71
|
+
```rill
|
|
72
|
+
# While loop: condition @ body
|
|
73
|
+
0 -> ($ < 3) @ { $ + 1 } # Result: 3
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```rill
|
|
77
|
+
# Iteration with each
|
|
78
|
+
["a.txt", "b.txt"] -> each { "Processing: {$}" -> log }
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Closures
|
|
82
|
+
|
|
83
|
+
First-class functions with captured environment.
|
|
84
|
+
|
|
85
|
+
```rill
|
|
86
|
+
|x| ($x * 2) :> $double
|
|
87
|
+
[1, 2, 3] -> map $double # [2, 4, 6]
|
|
88
|
+
5 -> $double # 10
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Parallel Execution
|
|
92
|
+
|
|
93
|
+
Fan out work concurrently. Results preserve order.
|
|
94
|
+
|
|
95
|
+
```rill
|
|
96
|
+
# Parallel map with closure
|
|
97
|
+
["security", "performance", "style"] -> map |aspect| {
|
|
98
|
+
app::prompt("Review for {$aspect} issues")
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```rill
|
|
103
|
+
# Parallel filter with method
|
|
104
|
+
["critical bug", "minor note", "critical fix"] -> filter .contains("critical")
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### LLM Output Parsing
|
|
108
|
+
|
|
109
|
+
Built-in functions for extracting structured data from LLM responses.
|
|
110
|
+
|
|
111
|
+
```rill
|
|
112
|
+
# Auto-detect format (JSON, XML, YAML, checklist)
|
|
113
|
+
"[1, 2, 3]" -> parse_auto -> .data # [1, 2, 3]
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
```rill
|
|
117
|
+
# Extract fenced code blocks
|
|
118
|
+
"```json\n[1,2]\n```" -> parse_fence("json") -> parse_json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```rill
|
|
122
|
+
# Extract XML tags
|
|
123
|
+
"<answer>42</answer>" -> parse_xml("answer") # "42"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### String Interpolation
|
|
127
|
+
|
|
128
|
+
Embed expressions in strings. Heredoc for multi-line.
|
|
129
|
+
|
|
130
|
+
```rill
|
|
131
|
+
"world" -> "Hello, {$}!" -> log # Hello, world!
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```rill
|
|
135
|
+
"x + 1" :> $code
|
|
136
|
+
<<EOF
|
|
137
|
+
Analyze: {$code}
|
|
138
|
+
Return: PASS or FAIL
|
|
139
|
+
EOF
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Core Syntax
|
|
143
|
+
|
|
144
|
+
| Syntax | Description |
|
|
145
|
+
|--------|-------------|
|
|
146
|
+
| `->` | Pipe data forward |
|
|
147
|
+
| `:>` | Capture and continue |
|
|
148
|
+
| `$` | Current pipe value |
|
|
149
|
+
| `.field` | Property access on `$` |
|
|
150
|
+
| `cond ? a ! b` | Conditional |
|
|
151
|
+
| `cond @ { }` | While loop |
|
|
152
|
+
| `@ { } ? cond` | Do-while loop |
|
|
153
|
+
| `each`, `map`, `filter` | Collection operators |
|
|
154
|
+
| `fold(init)` | Reduction |
|
|
155
|
+
| `\|args\| { }` | Closure |
|
|
156
|
+
|
|
157
|
+
## Language Characteristics
|
|
158
|
+
|
|
159
|
+
- **Value-based.** No references. Deep copy, value comparison.
|
|
160
|
+
- **No null/undefined.** Empty values valid, "no value" doesn't exist.
|
|
161
|
+
- **No exceptions.** Singular control flow. Explicit error handling.
|
|
162
|
+
- **Immutable types.** Variables lock type on first assignment.
|
|
163
|
+
- **Transparently async.** No async/await. Parallel execution automatic.
|
|
164
|
+
|
|
165
|
+
## Use Cases
|
|
166
|
+
|
|
167
|
+
- **User-defined workflows.** Let power users script automation in your app.
|
|
168
|
+
- **Multi-phase pipelines.** Chain steps with review gates.
|
|
169
|
+
- **Parallel agent fan-out.** Launch specialists concurrently.
|
|
170
|
+
- **Edit-Review loops.** Iterate until approval or max attempts.
|
|
171
|
+
|
|
172
|
+
See [Examples](docs/12_examples.md) for complete workflow patterns.
|
|
173
|
+
|
|
174
|
+
## Documentation
|
|
175
|
+
|
|
176
|
+
See [docs/00_INDEX.md](docs/00_INDEX.md) for full navigation.
|
|
177
|
+
|
|
178
|
+
| Document | Description |
|
|
179
|
+
|----------|-------------|
|
|
180
|
+
| [Guide](docs/01_guide.md) | Beginner introduction |
|
|
181
|
+
| [Reference](docs/11_reference.md) | Language specification |
|
|
182
|
+
| [Examples](docs/12_examples.md) | Workflow patterns |
|
|
183
|
+
| [Host Integration](docs/14_host-integration.md) | Embedding API |
|
|
184
|
+
|
|
185
|
+
## License
|
|
186
|
+
|
|
187
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Rill CLI - Run rill scripts from the command line
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* npx tsx src/cli.ts <script.rill>
|
|
7
|
+
* npx tsx src/cli.ts -e "code"
|
|
8
|
+
* echo "code" | npx tsx src/cli.ts -
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Rill CLI - Run rill scripts from the command line
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* npx tsx src/cli.ts <script.rill>
|
|
7
|
+
* npx tsx src/cli.ts -e "code"
|
|
8
|
+
* echo "code" | npx tsx src/cli.ts -
|
|
9
|
+
*/
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import { createRuntimeContext, execute, parse, } from './index.js';
|
|
12
|
+
function formatOutput(value) {
|
|
13
|
+
if (value === null)
|
|
14
|
+
return 'null';
|
|
15
|
+
if (typeof value === 'string')
|
|
16
|
+
return value;
|
|
17
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
18
|
+
return String(value);
|
|
19
|
+
}
|
|
20
|
+
return JSON.stringify(value, null, 2);
|
|
21
|
+
}
|
|
22
|
+
async function run(source) {
|
|
23
|
+
const ctx = createRuntimeContext({
|
|
24
|
+
callbacks: {
|
|
25
|
+
onLog: (value) => console.log(formatOutput(value)),
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
const ast = parse(source);
|
|
30
|
+
const result = await execute(ast, ctx);
|
|
31
|
+
console.log(formatOutput(result.value));
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function main() {
|
|
39
|
+
const args = process.argv.slice(2);
|
|
40
|
+
if (args.length === 0) {
|
|
41
|
+
console.error('Usage: rill <script.rill> | rill -e "code" | rill -');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
let source;
|
|
45
|
+
const arg0 = args[0];
|
|
46
|
+
if (arg0 === '-e') {
|
|
47
|
+
// Inline code: rill -e "code"
|
|
48
|
+
if (!args[1]) {
|
|
49
|
+
console.error('Missing code after -e');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
source = args[1];
|
|
53
|
+
}
|
|
54
|
+
else if (arg0 === '-') {
|
|
55
|
+
// Stdin: echo "code" | rill -
|
|
56
|
+
source = fs.readFileSync(0, 'utf-8');
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// File: rill script.rill
|
|
60
|
+
if (!fs.existsSync(arg0)) {
|
|
61
|
+
console.error(`File not found: ${arg0}`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
source = fs.readFileSync(arg0, 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
await run(source);
|
|
67
|
+
}
|
|
68
|
+
main();
|
|
69
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,KAAK,GAEN,MAAM,YAAY,CAAC;AAEpB,SAAS,YAAY,CAAC,KAAgB;IACpC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,KAAK,UAAU,GAAG,CAAC,MAAc;IAC/B,MAAM,GAAG,GAAG,oBAAoB,CAAC;QAC/B,SAAS,EAAE;YACT,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,K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,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,yBAAyB;QACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/demo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/demo.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rill Runtime Demo
|
|
3
|
+
* Simple test to verify parser + runtime integration
|
|
4
|
+
*/
|
|
5
|
+
import { createRuntimeContext, execute, parse, } from './index.js';
|
|
6
|
+
/** Safely stringify a RillValue */
|
|
7
|
+
function fmt(value) {
|
|
8
|
+
if (value === null)
|
|
9
|
+
return 'null';
|
|
10
|
+
if (typeof value === 'string')
|
|
11
|
+
return value;
|
|
12
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
13
|
+
return String(value);
|
|
14
|
+
}
|
|
15
|
+
return JSON.stringify(value);
|
|
16
|
+
}
|
|
17
|
+
const logs = [];
|
|
18
|
+
const ctx = createRuntimeContext({
|
|
19
|
+
variables: {
|
|
20
|
+
name: 'World',
|
|
21
|
+
items: ['apple', 'banana', 'cherry'],
|
|
22
|
+
count: 3,
|
|
23
|
+
},
|
|
24
|
+
functions: {
|
|
25
|
+
greet: (args) => {
|
|
26
|
+
const name = args[0];
|
|
27
|
+
const str = typeof name === 'string' ? name : JSON.stringify(name);
|
|
28
|
+
return `Hello, ${str}!`;
|
|
29
|
+
},
|
|
30
|
+
double: (args) => (typeof args[0] === 'number' ? args[0] * 2 : 0),
|
|
31
|
+
},
|
|
32
|
+
callbacks: {
|
|
33
|
+
onLog: (value) => {
|
|
34
|
+
logs.push(fmt(value));
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
async function runDemo() {
|
|
39
|
+
console.log('=== Rill Runtime Demo ===\n');
|
|
40
|
+
// Test 1: Simple pipe chain with function (bare name, no parens)
|
|
41
|
+
console.log('Test 1: Pipe chain with bare function name');
|
|
42
|
+
const script1 = parse('"World" -> greet');
|
|
43
|
+
const result1 = await execute(script1, ctx);
|
|
44
|
+
console.log(` Result: ${fmt(result1.value)}\n`);
|
|
45
|
+
// Test 2: Variable access (bare function name)
|
|
46
|
+
console.log('Test 2: Variable access with bare function');
|
|
47
|
+
const script2 = parse('$name -> greet');
|
|
48
|
+
const result2 = await execute(script2, ctx);
|
|
49
|
+
console.log(` Result: ${fmt(result2.value)}\n`);
|
|
50
|
+
// Test 3: Function calls (log)
|
|
51
|
+
console.log('Test 3: Function calls');
|
|
52
|
+
logs.length = 0;
|
|
53
|
+
const script3 = parse('"Hello" -> log');
|
|
54
|
+
await execute(script3, ctx);
|
|
55
|
+
console.log(` Logged: ${logs.join(', ')}\n`);
|
|
56
|
+
// Test 4: Conditional with .empty
|
|
57
|
+
console.log('Test 4: Conditional with .empty check');
|
|
58
|
+
const script4 = parse(`
|
|
59
|
+
"" -> .empty ? "was empty" ! "was not empty"
|
|
60
|
+
`);
|
|
61
|
+
const result4 = await execute(script4, ctx);
|
|
62
|
+
console.log(` Result: ${fmt(result4.value)}\n`);
|
|
63
|
+
// Test 5: Conditional - non-empty case
|
|
64
|
+
console.log('Test 5: Conditional - non-empty case');
|
|
65
|
+
const script5 = parse(`
|
|
66
|
+
"hello" -> .empty ? "was empty" ! "was not empty"
|
|
67
|
+
`);
|
|
68
|
+
const result5 = await execute(script5, ctx);
|
|
69
|
+
console.log(` Result: ${fmt(result5.value)}\n`);
|
|
70
|
+
// Test 6: For loop
|
|
71
|
+
console.log('Test 6: For loop over array');
|
|
72
|
+
const script6 = parse(`
|
|
73
|
+
$items -> @{
|
|
74
|
+
$ -> log
|
|
75
|
+
}
|
|
76
|
+
`);
|
|
77
|
+
logs.length = 0;
|
|
78
|
+
await execute(script6, ctx);
|
|
79
|
+
console.log(` Logged: ${logs.join(', ')}\n`);
|
|
80
|
+
// Test 7: While loop (new syntax: cond @ body)
|
|
81
|
+
console.log('Test 7: While loop');
|
|
82
|
+
const script7 = parse(`
|
|
83
|
+
1 -> $x
|
|
84
|
+
($x < 100) @ {
|
|
85
|
+
$x -> log
|
|
86
|
+
$x -> double -> $x
|
|
87
|
+
}
|
|
88
|
+
$x
|
|
89
|
+
`);
|
|
90
|
+
logs.length = 0;
|
|
91
|
+
const result7 = await execute(script7, ctx);
|
|
92
|
+
console.log(` Logged: ${logs.join(', ')}`);
|
|
93
|
+
console.log(` Final: ${fmt(result7.value)}\n`);
|
|
94
|
+
// Test 8: Variable capture (bare function name)
|
|
95
|
+
console.log('Test 8: Variable capture with bare function');
|
|
96
|
+
const script8 = parse(`
|
|
97
|
+
"captured value" -> $myVar
|
|
98
|
+
$myVar -> greet
|
|
99
|
+
`);
|
|
100
|
+
const result8 = await execute(script8, ctx);
|
|
101
|
+
console.log(` Result: ${fmt(result8.value)}`);
|
|
102
|
+
console.log(` Captured vars: ${JSON.stringify(result8.variables)}\n`);
|
|
103
|
+
// Test 9: Tuple and dict literals
|
|
104
|
+
console.log('Test 9: Tuple and dict literals');
|
|
105
|
+
const script9 = parse('[1, 2, 3]');
|
|
106
|
+
const result9 = await execute(script9, ctx);
|
|
107
|
+
console.log(` Tuple: ${fmt(result9.value)}\n`);
|
|
108
|
+
// Test 10: String interpolation
|
|
109
|
+
console.log('Test 10: String interpolation');
|
|
110
|
+
const script10 = parse('"Hello, {$name}!"');
|
|
111
|
+
const result10 = await execute(script10, ctx);
|
|
112
|
+
console.log(` Result: ${fmt(result10.value)}\n`);
|
|
113
|
+
// Test 11: Pipe var interpolation
|
|
114
|
+
console.log('Test 11: Pipe var interpolation');
|
|
115
|
+
const script11 = parse('"Hello" -> { "Greeting: {$}" }');
|
|
116
|
+
const result11 = await execute(script11, ctx);
|
|
117
|
+
console.log(` Result: ${fmt(result11.value)}\n`);
|
|
118
|
+
console.log('=== All tests complete ===');
|
|
119
|
+
}
|
|
120
|
+
runDemo().catch(console.error);
|
|
121
|
+
//# sourceMappingURL=demo.js.map
|
package/dist/demo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.js","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,KAAK,GAEN,MAAM,YAAY,CAAC;AAEpB,mCAAmC;AACnC,SAAS,GAAG,CAAC,KAAgB;IAC3B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QAC5D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,IAAI,GAAa,EAAE,CAAC;AAE1B,MAAM,GAAG,GAAG,oBAAoB,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC;QACpC,KAAK,EAAE,CAAC;KACT;IACD,SAAS,EAAE;QACT,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YACd,MAAM,IAAI,GAAG,IAAI,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AC;IAC9C,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElD,kCAAkC;IAClC,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC5C,CAAC;AAED,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rill Module
|
|
3
|
+
* Exports lexer, parser, runtime, and AST types
|
|
4
|
+
*/
|
|
5
|
+
export { LexerError, tokenize } from './lexer/index.js';
|
|
6
|
+
export { parse, parseWithRecovery } from './parser/index.js';
|
|
7
|
+
export type { ParseResult, ErrorNode } from './types.js';
|
|
8
|
+
export { type ApplicationCallable, BreakSignal, callable, type CallableFn, type CaptureEvent, createRuntimeContext, createStepper, type ErrorEvent, execute, type ExecutionResult, type ExecutionStepper, type HostCallEvent, type HostFunctionDefinition, type HostFunctionParam, type FunctionReturnEvent, isApplicationCallable, isTuple, isCallable, isDict, isReservedMethod, isRuntimeCallable, isScriptCallable, type ObservabilityCallbacks, RESERVED_DICT_METHODS, ReturnSignal, type RillTuple, type RillCallable, type RillValue, type RuntimeCallable, type RuntimeCallbacks, type RuntimeContext, type RuntimeOptions, type ScriptCallable, type StepEndEvent, type StepResult, type StepStartEvent, validateHostFunctionArgs, } from './runtime/index.js';
|
|
9
|
+
export * from './types.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EACxB,WAAW,EACX,QAAQ,EACR,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,oBAAoB,EACpB,aAAa,EACb,KAAK,UAAU,EACf,OAAO,EACP,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,sBAAsB,EAC3B,qBAAqB,EACrB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rill Module
|
|
3
|
+
* Exports lexer, parser, runtime, and AST types
|
|
4
|
+
*/
|
|
5
|
+
export { LexerError, tokenize } from './lexer/index.js';
|
|
6
|
+
export { parse, parseWithRecovery } from './parser/index.js';
|
|
7
|
+
export { BreakSignal, callable, createRuntimeContext, createStepper, execute, isApplicationCallable, isTuple, isCallable, isDict, isReservedMethod, isRuntimeCallable, isScriptCallable, RESERVED_DICT_METHODS, ReturnSignal, validateHostFunctionArgs, } from './runtime/index.js';
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAEL,WAAW,EACX,QAAQ,EAGR,oBAAoB,EACpB,aAAa,EAEb,OAAO,EAOP,qBAAqB,EACrB,OAAO,EACP,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAEhB,qBAAqB,EACrB,YAAY,EAYZ,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexer Errors
|
|
3
|
+
*/
|
|
4
|
+
import type { SourceLocation } from '../types.js';
|
|
5
|
+
export declare class LexerError extends Error {
|
|
6
|
+
readonly location: SourceLocation;
|
|
7
|
+
constructor(message: string, location: SourceLocation);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/lexer/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,UAAW,SAAQ,KAAK;aAGjB,QAAQ,EAAE,cAAc;gBADxC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,cAAc;CAK3C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexer Errors
|
|
3
|
+
*/
|
|
4
|
+
export class LexerError extends Error {
|
|
5
|
+
location;
|
|
6
|
+
constructor(message, location) {
|
|
7
|
+
super(`${message} at line ${location.line}, column ${location.column}`);
|
|
8
|
+
this.location = location;
|
|
9
|
+
this.name = 'LexerError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lexer/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAGjB;IAFlB,YACE,OAAe,EACC,QAAwB;QAExC,KAAK,CAAC,GAAG,OAAO,YAAY,QAAQ,CAAC,IAAI,YAAY,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAFxD,aAAQ,GAAR,QAAQ,CAAgB;QAGxC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexer Helper Functions
|
|
3
|
+
* Character classification and token construction
|
|
4
|
+
*/
|
|
5
|
+
import type { SourceLocation, Token, TokenType } from '../types.js';
|
|
6
|
+
import { type LexerState } from './state.js';
|
|
7
|
+
export declare function isDigit(ch: string): boolean;
|
|
8
|
+
export declare function isIdentifierStart(ch: string): boolean;
|
|
9
|
+
export declare function isIdentifierChar(ch: string): boolean;
|
|
10
|
+
export declare function isWhitespace(ch: string): boolean;
|
|
11
|
+
export declare function makeToken(type: TokenType, value: string, start: SourceLocation, end: SourceLocation): Token;
|
|
12
|
+
/** Advance n times and return a token */
|
|
13
|
+
export declare function advanceAndMakeToken(state: LexerState, n: number, type: TokenType, value: string, start: SourceLocation): Token;
|
|
14
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/lexer/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvE,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE3C;AAMD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,EACrB,GAAG,EAAE,cAAc,GAClB,KAAK,CAEP;AAED,yCAAyC;AACzC,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,UAAU,EACjB,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,GACpB,KAAK,CAGP"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexer Helper Functions
|
|
3
|
+
* Character classification and token construction
|
|
4
|
+
*/
|
|
5
|
+
import { advance, currentLocation } from './state.js';
|
|
6
|
+
export function isDigit(ch) {
|
|
7
|
+
return ch >= '0' && ch <= '9';
|
|
8
|
+
}
|
|
9
|
+
function isLetter(ch) {
|
|
10
|
+
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
|
|
11
|
+
}
|
|
12
|
+
export function isIdentifierStart(ch) {
|
|
13
|
+
return isLetter(ch) || ch === '_';
|
|
14
|
+
}
|
|
15
|
+
export function isIdentifierChar(ch) {
|
|
16
|
+
return isIdentifierStart(ch) || isDigit(ch);
|
|
17
|
+
}
|
|
18
|
+
export function isWhitespace(ch) {
|
|
19
|
+
return ch === ' ' || ch === '\t' || ch === '\r';
|
|
20
|
+
}
|
|
21
|
+
export function makeToken(type, value, start, end) {
|
|
22
|
+
return { type, value, span: { start, end } };
|
|
23
|
+
}
|
|
24
|
+
/** Advance n times and return a token */
|
|
25
|
+
export function advanceAndMakeToken(state, n, type, value, start) {
|
|
26
|
+
for (let i = 0; i < n; i++)
|
|
27
|
+
advance(state);
|
|
28
|
+
return makeToken(type, value, start, currentLocation(state));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/lexer/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,OAAO,EAAE,eAAe,EAAmB,MAAM,YAAY,CAAC;AAEvE,MAAM,UAAU,OAAO,CAAC,EAAU;IAChC,OAAO,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,CAAC;AAChC,CAAC;AAED,SAAS,QAAQ,CAAC,EAAU;IAC1B,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,OAAO,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAU;IACzC,OAAO,iBAAiB,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,EAAU;IACrC,OAAO,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,IAAe,EACf,KAAa,EACb,KAAqB,EACrB,GAAmB;IAEnB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC;AAC/C,CAAC;AAED,yCAAyC;AACzC,MAAM,UAAU,mBAAmB,CACjC,KAAiB,EACjB,CAAS,EACT,IAAe,EACf,KAAa,EACb,KAAqB;IAErB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lexer Module
|
|
3
|
+
* Converts source text into tokens
|
|
4
|
+
*/
|
|
5
|
+
export { LexerError } from './errors.js';
|
|
6
|
+
export { createLexerState, type LexerState } from './state.js';
|
|
7
|
+
export { nextToken, tokenize } from './tokenizer.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lexer/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lexer/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator Lookup Tables
|
|
3
|
+
*/
|
|
4
|
+
import type { TokenType } from '../types.js';
|
|
5
|
+
/** Two-character operator lookup table */
|
|
6
|
+
export declare const TWO_CHAR_OPERATORS: Record<string, TokenType>;
|
|
7
|
+
/** Single-character operator lookup table */
|
|
8
|
+
export declare const SINGLE_CHAR_OPERATORS: Record<string, TokenType>;
|
|
9
|
+
/** Keyword lookup table */
|
|
10
|
+
export declare const KEYWORDS: Record<string, TokenType>;
|
|
11
|
+
//# sourceMappingURL=operators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operators.d.ts","sourceRoot":"","sources":["../../src/lexer/operators.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,0CAA0C;AAC1C,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAcxD,CAAC;AAEF,6CAA6C;AAC7C,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAwB3D,CAAC;AAEF,2BAA2B;AAC3B,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAS9C,CAAC"}
|