@mylasertools/kerfscript 0.4.0 → 0.5.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/CHANGELOG.md +96 -0
- package/LANGUAGE.md +26 -11
- package/README.md +65 -2
- package/dist/ast.d.cts +13 -1
- package/dist/ast.d.ts +13 -1
- package/dist/cli.js +4734 -1405
- package/dist/diagnostics.d.cts +6 -0
- package/dist/diagnostics.d.ts +6 -0
- package/dist/evaluator.d.cts +12 -0
- package/dist/evaluator.d.ts +12 -0
- package/dist/format.d.cts +4 -0
- package/dist/format.d.ts +4 -0
- package/dist/highlight.cjs +151 -0
- package/dist/highlight.d.cts +13 -0
- package/dist/highlight.d.ts +13 -0
- package/dist/highlight.js +131 -0
- package/dist/index.cjs +357 -13
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +357 -13
- package/dist/language.cjs +417 -0
- package/dist/language.d.cts +143 -0
- package/dist/language.d.ts +143 -0
- package/dist/language.js +417 -0
- package/dist/lexer.d.cts +17 -0
- package/dist/lexer.d.ts +17 -0
- package/dist/libraries.cjs +380 -0
- package/dist/libraries.d.cts +112 -0
- package/dist/libraries.d.ts +112 -0
- package/dist/libraries.js +380 -0
- package/dist/lsp.d.cts +12 -0
- package/dist/lsp.d.ts +12 -0
- package/dist/signatures.cjs +675 -0
- package/dist/signatures.d.cts +20 -0
- package/dist/signatures.d.ts +20 -0
- package/dist/signatures.js +655 -0
- package/docs/cli.md +45 -2
- package/docs/desktop.md +5 -0
- package/docs/editors.md +121 -0
- package/docs/javascript.md +146 -10
- package/docs/kerf.md +10 -0
- package/docs/library/box.svg +11 -0
- package/docs/library/calibration.svg +11 -0
- package/docs/library/dividers.svg +11 -0
- package/docs/library/enclosure.svg +11 -0
- package/docs/library/hanging.svg +11 -0
- package/docs/library/hinge.svg +11 -0
- package/docs/library/tabs.svg +11 -0
- package/docs/library.md +339 -0
- package/docs/openscad.md +1 -1
- package/docs/shared-libraries.md +229 -0
- package/docs/specification.md +529 -0
- package/docs/versions.md +2 -2
- package/package.json +51 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,101 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 (2026-10-31)
|
|
4
|
+
|
|
5
|
+
Language version 0.2. Programs for 0.1 run as before, except where noted
|
|
6
|
+
below: `echo()` keeps the order of its arguments, built-in modules warn
|
|
7
|
+
about arguments they do not take, and `[(for ...)]` parses. The six new
|
|
8
|
+
standard libraries need 0.2, so a shared library that uses them can say so
|
|
9
|
+
with `"language": "0.2"` in its `kerf.json`.
|
|
10
|
+
|
|
11
|
+
- `@mylasertools/kerfscript/highlight`: syntax colouring as its own small
|
|
12
|
+
module (4 KB), for editors and pages that show KerfScript code. The site,
|
|
13
|
+
the playground and the desktop app use it. It also colours module and
|
|
14
|
+
function names where they are defined, layer modules, `true`, `false`,
|
|
15
|
+
`undef` and `PI`, the `* # %` modifiers, and customizer group headers
|
|
16
|
+
and controls.
|
|
17
|
+
- The playground keeps a block comment coloured across all its lines.
|
|
18
|
+
- [Specification](docs/specification.md): the formal grammar and the exact
|
|
19
|
+
rules for values, operators, scope, calls, libraries and errors.
|
|
20
|
+
- A conformance suite in `conformance/`: 92 small programs with their
|
|
21
|
+
expected output, errors, parts and layers. Every example's output is also
|
|
22
|
+
stored, so a change that alters a saved design fails a test.
|
|
23
|
+
- A library that uses or includes itself, directly or through others, is an
|
|
24
|
+
error naming the loop, where it used to fail with "Recursion too deep".
|
|
25
|
+
- A comprehension in parentheses can be the first item of a list:
|
|
26
|
+
`[(for (i = [0:2]) i)]`.
|
|
27
|
+
- `SIGNATURES` (also `@mylasertools/kerfscript/signatures`): every built-in
|
|
28
|
+
module and function with its parameters, defaults and a line of
|
|
29
|
+
documentation, for editors and help text. Tests keep it in step with the
|
|
30
|
+
interpreter, the highlighter, the VS Code grammar and the reference.
|
|
31
|
+
- Built-in modules and `assert`, `text_width`, `text_metrics` and
|
|
32
|
+
`finger_count` warn about named arguments they do not take, as user
|
|
33
|
+
modules and functions already did: `rect(10, radius = 2)` warns that
|
|
34
|
+
`radius` is unknown.
|
|
35
|
+
- [integrations/](integrations): four working laser-cutting generators, a
|
|
36
|
+
batch script, a web service, a web page and a Python script, each run by
|
|
37
|
+
the tests.
|
|
38
|
+
- Errors show where they are: `formatError()` and the command line print
|
|
39
|
+
the source line with the problem underlined, the module and function calls
|
|
40
|
+
it happened inside, and what a built-in takes when it was given an
|
|
41
|
+
unusable argument. The playground and the desktop app show the same.
|
|
42
|
+
`KerfError` has `reason`, `trace` and `call` for applications that show
|
|
43
|
+
errors their own way.
|
|
44
|
+
- Unknown variables, functions, modules and named arguments suggest a close
|
|
45
|
+
known name: `Unknown variable "widht". Did you mean "width"?`
|
|
46
|
+
- A function that calls itself without end reports the call and its line
|
|
47
|
+
instead of a message with no position.
|
|
48
|
+
- Positional arguments past a module's or function's parameters, built-in or
|
|
49
|
+
not, give a warning; they used to be dropped silently.
|
|
50
|
+
- `echo()` writes named and positional arguments in the order they are
|
|
51
|
+
given; named ones used to come last.
|
|
52
|
+
- Errors in calls point at the name called, and a missing comma says what
|
|
53
|
+
else could come next: `Expected "," or ")"`.
|
|
54
|
+
- `kerf fmt` and `format()`: the official formatter. It sets indentation,
|
|
55
|
+
spacing, blank lines and line endings, keeps line breaks and every comment
|
|
56
|
+
where it is, and checks that its output has the same tokens as the input.
|
|
57
|
+
`kerf fmt --check` lists unformatted files for CI, and `kerf fmt -` reads
|
|
58
|
+
standard input for editors. The examples and the standard library are
|
|
59
|
+
formatted with it; their output is unchanged.
|
|
60
|
+
- A VS Code extension in `editors/vscode` with a TextMate grammar, snippets
|
|
61
|
+
and file icons. A test checks that it colours every example the same way
|
|
62
|
+
as the highlighter.
|
|
63
|
+
- `kerf lsp`, the KerfScript language server, for VS Code (the extension
|
|
64
|
+
bundles it) and any editor with a Language Server Protocol client:
|
|
65
|
+
problems while you type, hover, completion, parameter hints, go to
|
|
66
|
+
definition, find references, rename, outline, links on library paths and
|
|
67
|
+
formatting. Designs run in a worker thread and stop after 10 seconds. See
|
|
68
|
+
[Editors](docs/editors.md).
|
|
69
|
+
- `@mylasertools/kerfscript/language`: the language server's answers as
|
|
70
|
+
functions, for editors in a browser or your own tools.
|
|
71
|
+
- `KerfError` has `warnings`, the warnings before the error.
|
|
72
|
+
- Standard library: six new libraries, each with a picture, an example and
|
|
73
|
+
tests, described in [Standard library](docs/library.md). `kerf/tabs`:
|
|
74
|
+
tab and slot joints. `kerf/hinge`: living hinge panels, `bend_length()`
|
|
75
|
+
and `flex_box()`, a box with round corners. `kerf/dividers`: egg-crate
|
|
76
|
+
dividers. `kerf/hanging`: keyholes, holes and hanging loops.
|
|
77
|
+
`kerf/enclosure`: boxes with a lid held by screws and nuts, with cutouts
|
|
78
|
+
and vents. `kerf/calibration`: a kerf gauge, a slot gauge and finger
|
|
79
|
+
joint test pairs.
|
|
80
|
+
- New examples built on them: a spice shelf, a flex box, a wall sign, a
|
|
81
|
+
project enclosure and a calibration set. The drawer organizer, the kerf
|
|
82
|
+
test and the hinge card now use the libraries; their output is unchanged,
|
|
83
|
+
except that the drawer organizer's dividers are named `long divider` and
|
|
84
|
+
`cross divider`.
|
|
85
|
+
- The editors colour the new library modules like `box()` and `divider()`.
|
|
86
|
+
- [Shared libraries](docs/shared-libraries.md): `kerf add`, `kerf remove`,
|
|
87
|
+
`kerf install` and `kerf pack`. A project's `kerf.json` names the
|
|
88
|
+
libraries it uses, from a GitHub tag, an https `.tar.gz` or a folder;
|
|
89
|
+
`kerf install` copies them into `kerf_libraries/` and pins each in
|
|
90
|
+
`kerf.lock` by its commit and a sha256 hash of its files. `--frozen`
|
|
91
|
+
and `--check` keep CI to exactly what is pinned. Designs load them with
|
|
92
|
+
`use <name/file>` in `kerf render`, the desktop app and the language
|
|
93
|
+
server, which also completes their paths. `kerf pack` checks a library's
|
|
94
|
+
files and `use` paths before it is published.
|
|
95
|
+
- `@mylasertools/kerfscript/libraries`: the same for Node.js, including
|
|
96
|
+
`resolver(file)`, a `resolve` option that finds libraries as the command
|
|
97
|
+
line does.
|
|
98
|
+
|
|
3
99
|
## 0.4.0 (2026-10-30)
|
|
4
100
|
|
|
5
101
|
- Assembly: `part()` takes `at` and `rotate` to place a part in 3D, rotated
|
package/LANGUAGE.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# KerfScript language reference
|
|
2
2
|
|
|
3
|
-
Language version 0.
|
|
3
|
+
Language version 0.2. Copyright (c) 2026 MyLaserTools. This document is
|
|
4
4
|
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
|
|
5
5
|
"KerfScript" is a trademark of MyLaserTools, see [TRADEMARKS.md](TRADEMARKS.md).
|
|
6
6
|
|
|
7
7
|
This reference covers KerfScript syntax, built-in modules and functions.
|
|
8
|
-
For a first project, follow [Getting started](docs/getting-started.md).
|
|
8
|
+
For a first project, follow [Getting started](docs/getting-started.md). The
|
|
9
|
+
[specification](docs/specification.md) gives the formal grammar and the
|
|
10
|
+
exact rules for scope, evaluation, libraries and errors.
|
|
9
11
|
|
|
10
12
|
Programs build 2D shapes, assign them to cut, score or engrave layers, and
|
|
11
13
|
group them into parts. Rendering applies kerf compensation, arranges the
|
|
@@ -64,7 +66,7 @@ to change the order of evaluation.
|
|
|
64
66
|
| `<` `<=` `>` `>=` | compare numbers or strings |
|
|
65
67
|
| `+` `-` | add or subtract numbers or equal length lists; `+` joins strings |
|
|
66
68
|
| `*` `/` `%` | multiply, divide, remainder; list times number scales; list times list is the dot product; matrix times vector |
|
|
67
|
-
| `-x` `!x`
|
|
69
|
+
| `-x` `+x` `!x` | negate, same, not |
|
|
68
70
|
| `a ^ b` | power, right associative and tighter than unary minus |
|
|
69
71
|
| `f(x)` `a[i]` `a.x` | call, index, member |
|
|
70
72
|
|
|
@@ -126,12 +128,12 @@ Arguments can be positional or named: `rect([20, 10], r = 2)`.
|
|
|
126
128
|
|
|
127
129
|
Place `*` before a module call to disable it. Use `#` or `%` to move its
|
|
128
130
|
geometry to the guide layer. Guides are included only when requested in
|
|
129
|
-
the render options.
|
|
131
|
+
the render options. `!` is accepted for OpenSCAD files and has no effect.
|
|
130
132
|
|
|
131
133
|
### children()
|
|
132
134
|
|
|
133
135
|
Inside a module, `children()` renders all child statements passed by the
|
|
134
|
-
caller. `children(
|
|
136
|
+
caller. `children(index)` selects one child by its position from 0, or several with a list of positions.
|
|
135
137
|
`$children` is the number of children.
|
|
136
138
|
|
|
137
139
|
```kerf
|
|
@@ -380,12 +382,25 @@ to inspect the settings in a file.
|
|
|
380
382
|
|
|
381
383
|
## Standard library
|
|
382
384
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
385
|
+
Every renderer has these libraries built in. Load one with `use`, as
|
|
386
|
+
`use <kerf/box>`; [Standard library](docs/library.md) describes each
|
|
387
|
+
module and its parameters. Libraries others publish are installed with
|
|
388
|
+
`kerf add` and loaded by their name, as `use <feet/feet>`; see
|
|
389
|
+
[Shared libraries](docs/shared-libraries.md).
|
|
390
|
+
|
|
391
|
+
| Library | Modules and functions |
|
|
392
|
+
| ------------------ | --------------------------------------------------------------------------- |
|
|
393
|
+
| `kerf/box` | `box([w, d, h], lid = false, finger)`, `divider([w, h], finger)` |
|
|
394
|
+
| `kerf/tabs` | `tabs()`, `slots()`, `tab_rect()`, `tab_positions()`: tab and slot joints |
|
|
395
|
+
| `kerf/hinge` | `flex_rect()`, `flex_box()`, `flex_panel()`, `bend_length()`: living hinges |
|
|
396
|
+
| `kerf/dividers` | `grid_dividers()`, `slotted_divider()`: egg-crate dividers |
|
|
397
|
+
| `kerf/hanging` | `keyhole()`, `keyholes()`, `hanging_hole()`, `hanging_loop()` |
|
|
398
|
+
| `kerf/enclosure` | `enclosure()`, `enclosure_cutouts()`, `vents()`: boxes with a screwed lid |
|
|
399
|
+
| `kerf/calibration` | `kerf_gauge()`, `slot_gauge()`, `joint_test()`: test pieces |
|
|
400
|
+
|
|
401
|
+
`box()` makes the six (or five) panels of a finger-jointed box as parts
|
|
402
|
+
`bottom`, `lid`, `front`, `back`, `left`, `right`, from the outer size.
|
|
403
|
+
`divider()` makes a divider with finger tabs on both sides.
|
|
389
404
|
|
|
390
405
|
## Output
|
|
391
406
|
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<p align="center">
|
|
6
6
|
<a href="https://www.npmjs.com/package/@mylasertools/kerfscript"><img src="https://img.shields.io/npm/v/@mylasertools/kerfscript?color=d8361f&label=npm" alt="npm version"></a>
|
|
7
7
|
<a href="COMMERCIAL-LICENSE.md"><img src="https://img.shields.io/badge/licence-AGPL--3.0%20or%20free%20commercial-1f1a17" alt="Licence: AGPL-3.0 or free commercial"></a>
|
|
8
|
-
<a href="LANGUAGE.md"><img src="https://img.shields.io/badge/language-0.
|
|
8
|
+
<a href="LANGUAGE.md"><img src="https://img.shields.io/badge/language-0.2-e3c69a" alt="Language version 0.2"></a>
|
|
9
9
|
<a href="https://kerfscript.mylasertools.com/playground/"><img src="https://img.shields.io/badge/try%20it-playground-5a3519" alt="Try it in the playground"></a>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
@@ -22,6 +22,13 @@ is to laser cutters what OpenSCAD is to 3D printers, except it was designed for
|
|
|
22
22
|
flat parts from the start: cut, score and engrave layers, kerf compensation,
|
|
23
23
|
finger joints, living hinges, parts and sheets are part of the language.
|
|
24
24
|
|
|
25
|
+
It is also a library for building **laser-cutting generators**: a web page,
|
|
26
|
+
web service, app or script that takes a few settings (a size, a name, a number
|
|
27
|
+
of slots) and returns SVG or DXF files ready to cut. The design is a `.kerf`
|
|
28
|
+
file; your code passes settings in and takes cut files out, in Node.js, the
|
|
29
|
+
browser, or any language that runs WebAssembly. See
|
|
30
|
+
[Build a generator](#build-a-generator).
|
|
31
|
+
|
|
25
32
|
<p align="center">
|
|
26
33
|
<a href="https://kerfscript.mylasertools.com/playground/?model=fractal-tree"><img src=".github/readme/playground.gif" alt="Moving a slider in the playground changes the number in the code and redraws the fractal tree" width="840"></a>
|
|
27
34
|
<br><sub>The <a href="https://kerfscript.mylasertools.com/playground/">playground</a> runs the interpreter in your browser. A comment after a number turns it into a slider.</sub>
|
|
@@ -65,6 +72,51 @@ millimetre SVG with one layer per operation. Output is checked automatically
|
|
|
65
72
|
in Inkscape; see [docs/compatibility.md](docs/compatibility.md) for what has
|
|
66
73
|
and has not been tested in other laser software.
|
|
67
74
|
|
|
75
|
+
`kerf/box` is one of the libraries in the
|
|
76
|
+
[standard library](docs/library.md), built into every renderer:
|
|
77
|
+
[tabs and slots](docs/library.md#tabs-and-slots),
|
|
78
|
+
[living hinges](docs/library.md#living-hinges) and a box with round corners,
|
|
79
|
+
[egg-crate dividers](docs/library.md#dividers),
|
|
80
|
+
[keyholes and hanging loops](docs/library.md#hanging),
|
|
81
|
+
[enclosures](docs/library.md#enclosures) with a screwed-on lid, and
|
|
82
|
+
[test pieces](docs/library.md#calibration) that measure your laser's
|
|
83
|
+
kerf and how your sheet fits.
|
|
84
|
+
|
|
85
|
+
## Build a generator
|
|
86
|
+
|
|
87
|
+
`parameters()` reads a design's settings, with their captions, ranges and
|
|
88
|
+
choices, so you can build a form or an API from them. `render()` turns
|
|
89
|
+
settings into cut files:
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
import { readFile } from 'node:fs/promises';
|
|
93
|
+
import { parameters, render } from '@mylasertools/kerfscript';
|
|
94
|
+
|
|
95
|
+
const design = await readFile('box.kerf', 'utf8'); // integrations/http-api/box.kerf
|
|
96
|
+
parameters(design).parameters; // width: number from 40 to 400, lid: boolean, ...
|
|
97
|
+
|
|
98
|
+
const { sheets, parts, warnings } = render(design, { params: { width: 200, lid: false } });
|
|
99
|
+
sheets[0].svg; // or sheets[0].dxf, one per sheet of material
|
|
100
|
+
parts; // [{ name: 'bottom', width: 200, height: 80, cutLength: 740, ... }]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Working generators, each tested on every change, are in
|
|
104
|
+
[integrations/](integrations):
|
|
105
|
+
|
|
106
|
+
| Example | What it makes |
|
|
107
|
+
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| [Batch in Node.js](integrations/node-batch) | A name tag for every name in a list, as SVG and DXF, and all of them packed on one sheet |
|
|
109
|
+
| [Web service](integrations/http-api) | A box generator over HTTP: settings as JSON, cut files by URL, each render in a worker with a time limit |
|
|
110
|
+
| [Web page](integrations/browser) | A form built from the design's settings, a live preview and downloads, with no build step |
|
|
111
|
+
| [Python](integrations/python) | Boxes in several sizes from Python through `kerfscript.wasm`, without Node.js |
|
|
112
|
+
|
|
113
|
+
The [playground](https://kerfscript.mylasertools.com/playground/), the
|
|
114
|
+
[desktop app](docs/desktop.md) and the
|
|
115
|
+
[KerfScript Playground on MyLaserTools](https://www.mylasertools.com/kerfscript-playground)
|
|
116
|
+
are generators built the same way. Programs written by other people should
|
|
117
|
+
run in a worker you can stop; see
|
|
118
|
+
[Running untrusted code](docs/javascript.md#running-untrusted-code).
|
|
119
|
+
|
|
68
120
|
## Made with KerfScript
|
|
69
121
|
|
|
70
122
|
Every model is a file in [examples/](examples). Open one on the website to
|
|
@@ -136,8 +188,15 @@ kerf render design.kerf -D width=200 -D 'label="Oak"' --font Inter.ttf
|
|
|
136
188
|
kerf render design.kerf --sheet 400x300 --kerf 0.1 --split
|
|
137
189
|
kerf params design.kerf # customizer parameters as JSON
|
|
138
190
|
kerf check design.kerf # parts, sizes, cut length, warnings
|
|
191
|
+
kerf fmt designs/ # format .kerf files; --check for CI
|
|
192
|
+
kerf lsp # language server for editors
|
|
139
193
|
```
|
|
140
194
|
|
|
195
|
+
The VS Code extension in [editors/vscode](editors/vscode) underlines
|
|
196
|
+
problems as you type and has hover, completion, parameter hints, go to
|
|
197
|
+
definition, references, rename and formatting on save. Other editors run
|
|
198
|
+
`kerf lsp`: see [Editors](docs/editors.md).
|
|
199
|
+
|
|
141
200
|
## Library
|
|
142
201
|
|
|
143
202
|
```js
|
|
@@ -168,12 +227,16 @@ Errors are thrown as `KerfError` with `line` and `col`.
|
|
|
168
227
|
the [desktop app](docs/desktop.md), the [command line](docs/cli.md), the
|
|
169
228
|
[JavaScript API](docs/javascript.md)
|
|
170
229
|
and [WebAssembly](docs/webassembly.md) for other languages
|
|
230
|
+
- [Standard library](docs/library.md): joints, hinges, dividers, hanging
|
|
231
|
+
holes, enclosures and test pieces, with a picture and an example of each
|
|
232
|
+
- [Shared libraries](docs/shared-libraries.md): use and publish `.kerf`
|
|
233
|
+
libraries, pinned in `kerf.lock` so a design cuts the same everywhere
|
|
171
234
|
- [Coming from OpenSCAD](docs/openscad.md): what is the same and what is not
|
|
172
235
|
- [LANGUAGE.md](LANGUAGE.md): the full language reference
|
|
173
236
|
- [Versions](docs/versions.md): language and package versions, and what stays
|
|
174
237
|
stable before 1.0
|
|
175
238
|
- [examples/](examples): every model on the website, including a
|
|
176
|
-
calibration square and a kerf test
|
|
239
|
+
calibration set, a calibration square and a kerf test
|
|
177
240
|
|
|
178
241
|
## Community
|
|
179
242
|
|
package/dist/ast.d.cts
CHANGED
|
@@ -65,11 +65,13 @@ export type Expr = {
|
|
|
65
65
|
params: Param[];
|
|
66
66
|
body: Expr;
|
|
67
67
|
pos: Pos;
|
|
68
|
+
end?: number;
|
|
68
69
|
} | {
|
|
69
70
|
kind: 'let';
|
|
70
71
|
assigns: Assign[];
|
|
71
72
|
body: Expr;
|
|
72
73
|
pos: Pos;
|
|
74
|
+
end?: number;
|
|
73
75
|
};
|
|
74
76
|
export type ListItem = {
|
|
75
77
|
kind: 'item';
|
|
@@ -81,6 +83,8 @@ export type ListItem = {
|
|
|
81
83
|
kind: 'for';
|
|
82
84
|
assigns: Assign[];
|
|
83
85
|
body: ListItem;
|
|
86
|
+
pos?: Pos;
|
|
87
|
+
end?: number;
|
|
84
88
|
} | {
|
|
85
89
|
kind: 'if';
|
|
86
90
|
cond: Expr;
|
|
@@ -90,21 +94,25 @@ export type ListItem = {
|
|
|
90
94
|
kind: 'let';
|
|
91
95
|
assigns: Assign[];
|
|
92
96
|
body: ListItem;
|
|
97
|
+
pos?: Pos;
|
|
98
|
+
end?: number;
|
|
93
99
|
};
|
|
94
100
|
export interface Arg {
|
|
95
101
|
name: string | null;
|
|
96
102
|
value: Expr;
|
|
103
|
+
pos?: Pos;
|
|
97
104
|
}
|
|
98
105
|
export interface Param {
|
|
99
106
|
name: string;
|
|
100
107
|
default: Expr | null;
|
|
108
|
+
pos?: Pos;
|
|
101
109
|
}
|
|
102
110
|
export interface Assign {
|
|
103
111
|
name: string;
|
|
104
112
|
value: Expr;
|
|
105
113
|
pos: Pos;
|
|
106
114
|
}
|
|
107
|
-
export type Stmt = {
|
|
115
|
+
export type Stmt = ({
|
|
108
116
|
kind: 'assign';
|
|
109
117
|
name: string;
|
|
110
118
|
value: Expr;
|
|
@@ -116,12 +124,14 @@ export type Stmt = {
|
|
|
116
124
|
params: Param[];
|
|
117
125
|
body: Stmt[];
|
|
118
126
|
pos: Pos;
|
|
127
|
+
namePos?: Pos;
|
|
119
128
|
} | {
|
|
120
129
|
kind: 'function';
|
|
121
130
|
name: string;
|
|
122
131
|
params: Param[];
|
|
123
132
|
body: Expr;
|
|
124
133
|
pos: Pos;
|
|
134
|
+
namePos?: Pos;
|
|
125
135
|
} | {
|
|
126
136
|
kind: 'call';
|
|
127
137
|
name: string;
|
|
@@ -154,6 +164,8 @@ export type Stmt = {
|
|
|
154
164
|
path: string;
|
|
155
165
|
include: boolean;
|
|
156
166
|
pos: Pos;
|
|
167
|
+
}) & {
|
|
168
|
+
end?: number;
|
|
157
169
|
};
|
|
158
170
|
export interface Program {
|
|
159
171
|
body: Stmt[];
|
package/dist/ast.d.ts
CHANGED
|
@@ -65,11 +65,13 @@ export type Expr = {
|
|
|
65
65
|
params: Param[];
|
|
66
66
|
body: Expr;
|
|
67
67
|
pos: Pos;
|
|
68
|
+
end?: number;
|
|
68
69
|
} | {
|
|
69
70
|
kind: 'let';
|
|
70
71
|
assigns: Assign[];
|
|
71
72
|
body: Expr;
|
|
72
73
|
pos: Pos;
|
|
74
|
+
end?: number;
|
|
73
75
|
};
|
|
74
76
|
export type ListItem = {
|
|
75
77
|
kind: 'item';
|
|
@@ -81,6 +83,8 @@ export type ListItem = {
|
|
|
81
83
|
kind: 'for';
|
|
82
84
|
assigns: Assign[];
|
|
83
85
|
body: ListItem;
|
|
86
|
+
pos?: Pos;
|
|
87
|
+
end?: number;
|
|
84
88
|
} | {
|
|
85
89
|
kind: 'if';
|
|
86
90
|
cond: Expr;
|
|
@@ -90,21 +94,25 @@ export type ListItem = {
|
|
|
90
94
|
kind: 'let';
|
|
91
95
|
assigns: Assign[];
|
|
92
96
|
body: ListItem;
|
|
97
|
+
pos?: Pos;
|
|
98
|
+
end?: number;
|
|
93
99
|
};
|
|
94
100
|
export interface Arg {
|
|
95
101
|
name: string | null;
|
|
96
102
|
value: Expr;
|
|
103
|
+
pos?: Pos;
|
|
97
104
|
}
|
|
98
105
|
export interface Param {
|
|
99
106
|
name: string;
|
|
100
107
|
default: Expr | null;
|
|
108
|
+
pos?: Pos;
|
|
101
109
|
}
|
|
102
110
|
export interface Assign {
|
|
103
111
|
name: string;
|
|
104
112
|
value: Expr;
|
|
105
113
|
pos: Pos;
|
|
106
114
|
}
|
|
107
|
-
export type Stmt = {
|
|
115
|
+
export type Stmt = ({
|
|
108
116
|
kind: 'assign';
|
|
109
117
|
name: string;
|
|
110
118
|
value: Expr;
|
|
@@ -116,12 +124,14 @@ export type Stmt = {
|
|
|
116
124
|
params: Param[];
|
|
117
125
|
body: Stmt[];
|
|
118
126
|
pos: Pos;
|
|
127
|
+
namePos?: Pos;
|
|
119
128
|
} | {
|
|
120
129
|
kind: 'function';
|
|
121
130
|
name: string;
|
|
122
131
|
params: Param[];
|
|
123
132
|
body: Expr;
|
|
124
133
|
pos: Pos;
|
|
134
|
+
namePos?: Pos;
|
|
125
135
|
} | {
|
|
126
136
|
kind: 'call';
|
|
127
137
|
name: string;
|
|
@@ -154,6 +164,8 @@ export type Stmt = {
|
|
|
154
164
|
path: string;
|
|
155
165
|
include: boolean;
|
|
156
166
|
pos: Pos;
|
|
167
|
+
}) & {
|
|
168
|
+
end?: number;
|
|
157
169
|
};
|
|
158
170
|
export interface Program {
|
|
159
171
|
body: Stmt[];
|