@plylang/plylang 1.0.26 → 1.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/README.md CHANGED
@@ -6,7 +6,7 @@ The compiler translates a module into JavaScript. There is no separate virtual m
6
6
 
7
7
  This text walks through the language once, with a short example of each feature.
8
8
 
9
- The repository contains the `plylang` compiler and the `plylang-ls` server. Words that work on ready-made values are not built into the compiler: they are imported. The neighboring package `@plylang/prelude` is one such place, and it has its own documentation. The import lines below name that package. They check in a package that depends on it.
9
+ The repository contains the `plylang` compiler and the `plylang-ls` server. They are separate npm packages. `@plylang/plylang` is the compiler. `@plylang/language-server` is the server. The server command remains `plylang-ls`. A library depends on the compiler. The server is installed by the editor. Words that work on ready-made values are not built into the compiler: they are imported. The neighboring package `@plylang/prelude` is one such place, and it has its own documentation. The import lines below name that package. They check in a package that depends on it.
10
10
 
11
11
  ## Stack
12
12
 
@@ -309,13 +309,13 @@ A module names what it publishes with one `@` list. The list may stand anywhere
309
309
  @ Maybe, Nothing, Just, fromMaybe
310
310
  ```
311
311
 
312
- Imports stay together and come before the first `:`, `;`, `-`, `&`, `#`, or `=`. A path inside this package is written from the source directory. A path into another package is a package specifier. The names after the path are what this file uses. `: Alias` brings every published name as `Alias:name`, and a call is `Alias:send`. `send : busSend` brings `send` as `busSend`. A bare path brings instances and no names. Writing the local name again in the `@` list publishes it. A colon in column 0 still starts a word.
312
+ Imports stay together and come before the first `:`, `;`, `-`, `&`, `#`, `?`, or `=`. A path inside this package is written from the source directory. A path into another package is a package specifier. The names after the path are what this file uses. `: Alias` brings every published name as `Alias:name`, and a call is `Alias:send`. `send : busSend` brings `send` as `busSend`. A bare path brings instances and no names. Writing the local name again in the `@` list publishes it. A colon in column 0 still starts a word.
313
313
 
314
- A test entry, a word `( -- Verdict )` or `suite`, is not a module and has no list. A utility under `test/` is a module and has one. A word `main` with scheme `( -- Unit )` may stay off the list. Node still runs it when it starts that file.
314
+ A word `main` with scheme `( -- Unit )` may stay off the list. Node still runs it when it starts that file.
315
315
 
316
- A comment runs from `.` to the end of the line, when the dot is not inside `()`. `..` in column 0, directly above `:`, `;`, `-`, `&`, or `=`, is the text of that declaration. One space after `..` is not part of the text. A type has one text for all of its constructors. A class has one text for its name and for all of its methods. A `..` line above `#` does not attach to the declaration.
316
+ A comment runs from `.` to the end of the line, when the dot is not inside `()`. `..` in column 0, directly above `:`, `;`, `-`, `&`, `?`, or `=`, is the text of that declaration. One space after `..` is not part of the text. A line that is only `..` keeps a paragraph break. A type has one text for all of its constructors. The lines above `&` are the text of the class. A `..` line at the start of an indented line, directly above a method, is the text of that method. A method without that line keeps the class text in the hover. A `..` line above `#` does not attach to the declaration.
317
317
 
318
- A declaration stands in column 0 and starts with `@`, `:`, `;`, `-`, `&`, `#`, `~`, or `=`.
318
+ A declaration stands in column 0 and starts with `@`, `:`, `;`, `-`, `&`, `#`, `?`, `~`, or `=`.
319
319
 
320
320
  A place is one value the module keeps off the stack. `= base Num` declares it. The program under that line has scheme `( -- Num )` and runs once, when the module loads. After that, `base` reads the current frame `( -- Num )`. `=base` writes the top value `( Num -- )`. `=>base` runs the quotation under a new frame and restores the previous frame afterwards, including when the quotation throws: `( ..s Num ( ..s -- ..t ) -- ..t )`. The stored type is monomorphic. Importing `base` also opens `=base` and `=>base`. The program that fills the place does not read or write it.
321
321
 
@@ -345,7 +345,7 @@ The foreign directory is `foreign` when that directory exists, or the string `pl
345
345
 
346
346
  ```text
347
347
  plylang check [dir]
348
- plylang build [dir] [--exports] [--entry <module>] [--out <dir>] [--foreign <dir>]
348
+ plylang build [dir] [--exports [--all] [--check] [<module>...]] [--watch] [--entry <module>] [--out <dir>] [--foreign <dir>]
349
349
  plylang compile [dir] [--entry <module>] [--out <file>] [--foreign <dir>]
350
350
  plylang test [pattern]
351
351
  plylang docs [dir] [--out <file>]
@@ -353,13 +353,26 @@ plylang check --parse <file>
353
353
  plylang check --js <file>
354
354
  ```
355
355
 
356
- `plylang check` checks a package the same way `build` does: every file under the source directory, the imports, and `foreign`. It writes no files and does not walk `test/`. The default directory is the current one. After the same check, `plylang build` writes a `.js` file and a `.d.ply` interface into the output directory. It does not change `exports`. `plylang build --exports` aligns `exports` with those modules. A key is `./` followed by the module path. When `ply.entry` is set, `.` points at that module too. `--entry` names that module for this run. `--out` names the output directory for this run, and the written keys use that directory. `--foreign` names the foreign directory for this run. None of those three flags is written back into `package.json`. `ply` points at the `.d.ply`, and `import` points at the `.js`. A key this tool does not own stays, and so does a hand-written `.` when `ply.entry` is absent. The other fields of the file stay as they were. A module of this package is imported by its path under the source directory, whether or not `exports` lists it. Another package finds the module through the `exports` entry.
356
+ `plylang check` checks every file under the source directory, the imports, `foreign`, and each `?` check. It writes no files. The default directory is the current one. `plylang build` checks the modules and writes them into the output directory. It leaves each `?` check out of that typecheck and out of both files. An import is written when the built program uses that name, or when `@` re-exports it. A `.js` file is written when the module has a JavaScript export, `main`, a place, or is `ply.entry`. A `.d.ply` file is written when `@` names something. A file with an empty `@` and no `main`, place, or entry writes nothing, and a file already at that path is removed. `build` does not change `exports`. `plylang build --exports` refreshes the `ply` and `import` paths of modules already listed in `exports`. A source file is added when its name is passed, as in `plylang build --exports Data/Sheet`, or when `--all` is passed. `--all` adds each source module whose `@` names something. Several names may follow `--exports`. A name that is not a source file is an error, and this run writes nothing. Names that stay out of the list are printed under `not exported`. `plylang build --exports --check` prints that report and leaves `package.json` unchanged. The modules are still written. The exit code is 1 when a path would change, an entry names a module that is gone, or `--all` would add a module whose `@` names something. `not exported` by itself leaves the exit code at 0. `--all` together with a module name is rejected. `--watch` cannot be combined with `--exports`. A module whose file is gone is removed when its entry has a `ply` field. A key that does not name a module of this package stays as written. On a module that stays, the `ply` and `import` strings are updated and the other fields stay. A module with no `.js` keeps `ply` and has no `import`. `.` follows `ply.entry` from the file on disk when that module is listed or is being added. With no `ply.entry`, a hand-written `.` stays. Each written path uses `ply.out` from that file. `--entry`, `--out`, and `--foreign` apply to this run and stay out of `package.json`. A module of this package is imported by its path under the source directory, whether or not `exports` lists it. Another package finds the module through the `exports` entry.
357
357
 
358
- `plylang test` builds the package, then compiles and runs the files that match one pattern. The pattern is relative to the package root. The default is `test/**/*.ply`. `*` matches inside one path segment. `**` matches across directories. Quote the pattern so the shell does not expand `*`. A test is a word `( -- Verdict )`. The runner calls each one in source order and uses the word as its name. `expect` compares two values. `pass` and `differ` build a verdict when those values have no `Showable` instance. The words live in `@plylang/test`. A file with no such word may export `suite` with scheme `( -- (Array Verdict) )` instead. A file under `test/` with neither is a utility. A test imports it by its path under `test/`, and a source file cannot. The runner does not run a utility. A source file cannot import a package that is only a `devDependency`. A test can. A file under the source directory stays where `build` wrote it. Any other test file is compiled in that package, written under the output directory for the run, and deleted afterwards. The report names each file and each check. A check also prints `file:line` of its word. A failing check prints its text under the name. One check that throws still lets the other checks run. A file that does not compile or does not run prints the diagnostic, and the other files still run. A failed check, a compile error, or a thrown suite exits 1. No file matched exits 1 with `no tests matched`. Color is used when stdout is a terminal and `NO_COLOR` is unset.
358
+ A check stands in column 0.
359
+
360
+ ```ply
361
+ ? "seed stays" < 0 > [
362
+ < 2 10 Occurrence > streamFrom
363
+ 0 stepper
364
+ 0 runAt
365
+ 1 valueAt
366
+ ]
367
+ ```
368
+
369
+ The name is a string literal. The picture is the stack from the bottom upward. The quotation is the program, and it starts from an empty stack. `< 1 2 >` is two values. `<>` is an empty stack. The quotation calls words of this file, including a word that stays off the `@` list. A word the check alone needs is written inside the quotation. The check is not a published name.
370
+
371
+ `plylang test` builds the package, then finds `?` in source files that match one pattern. The pattern is relative to the source directory. The default is `**/*.ply`. `*` matches inside one path segment. `**` matches across directories. Quote the pattern so the shell does not expand `*`. A file with no `?` is left out. The runner typechecks each check and runs it. The comparison is structural. A failure prints the name, `file:line`, and both stack pictures. One failed check still lets the other checks in that file run. A throw is a failure of that named check. One file that does not compile still lets the other files run. The runner writes the check into a temporary directory inside the package and deletes that directory when the run ends, including when a check fails to compile. The modules in the output directory stay, and they contain no check. A source file cannot import a package that is only a `devDependency`. A failed check, a compile error, or a throw exits 1. No file matched exits 1 with `no tests matched`. Color is used when stdout is a terminal and `NO_COLOR` is unset.
359
372
 
360
373
  A word named `main` whose scheme is `( -- Unit )` is the program of that module. It may stay off the `@` list. `build` calls it at the bottom of that module's `.js`, and only when Node started that file. `node dist/App.js` runs the program. An import of the module does not. A `package.json` script can name that file. Several modules may each have a `main`. A module without one is a library. Any other scheme on the name `main` is an error. `plylang compile` also writes those modules, then the page script. `--out` names that file. Otherwise it is `script.js` beside the modules. `--entry` names the module for this run, instead of `ply.entry`. The root is `main` when that module defines `main` of scheme `( -- Unit )`, and the script calls `main()`. A module with no `main` and at least one place roots the script at those places, and the script does not call `main`. A module with neither is an error. A binding is inlined when the root can call it. The modules themselves still carry the Node guard. `compile` does not rewrite `exports`. `--foreign` names the foreign directory for this run. A relative `--out` or `--foreign` stays inside the package.
361
374
 
362
- `plylang docs` writes `DOCS.md` at the package root. `--out` names another file. A module heading is the string used to import it: the package name and the path, or only the path when there is no name. The prose comes from `..`. Inside a module the sections are `Types`, `Classes`, `Instances`, and `Words`. An empty section is left out. The name of a type, a class, or a word is a heading under its section. `Instances` is a list of `#` heads, with no comment and no method bindings. A head whose type is defined in another module of this package is listed there too.
375
+ `plylang docs` writes `DOCS.md` at the package root. `--out` names another file. A module heading is the string used to import it: the package name and the path, or only the path when there is no name. The prose comes from `..`. Inside a module the sections are `Types`, `Classes`, `Instances`, and `Words`. An empty section is left out. The name of a type, a class, or a word is a heading under its section. A method is a heading after its class. The class heading carries the class text. The method heading carries that method's text. `Instances` is a list of `#` heads, with no comment and no method bindings. A head whose type is defined in another module of this package is listed there too.
363
376
 
364
377
  `plylang check --parse` prints how one file was parsed, and it does not check types. `plylang check --js` prints the JavaScript that `build` would write for that file. Outside a package that is the JavaScript of the one file, and imports are not resolved.
365
378
 
@@ -377,8 +390,10 @@ cargo build --release
377
390
 
378
391
  `target/release/plylang` and `target/release/plylang-ls` are the compiler and the server. The server speaks LSP over stdio. In a package with a `ply` field it resolves imports the same way `plylang build` does.
379
392
 
380
- The npm package is named `@plylang/plylang` and installs the same two commands. Version `1.x` of that package is language `1`. A minor or a patch of the compiler does not change the language number. `PLYLANG_BIN` and `PLYLANG_LS_BIN` supply a binary of their own.
393
+ `@plylang/plylang` installs the `plylang` command. `@plylang/language-server` installs `plylang-ls` and depends on the same version of the compiler. Publish the compiler and its six platform packages before the server package and its six platform packages. `.github/workflows/publish.yml` does that when a GitHub release is published. Version `1.x` is language `1`. A minor or a patch of the compiler does not change the language number. `PLYLANG_BIN` and `PLYLANG_LS_BIN` supply a binary of their own.
394
+
395
+ `node script/stage-native.js <platform> <binary-dir> <out-dir> plylang` writes one compiler platform package. The same command with `plylang-ls` writes `@plylang/language-server-<os>-<arch>`. Each archive holds one binary.
381
396
 
382
- Highlighting is the [tree-sitter-ply](https://github.com/algosail/tree-sitter-ply) grammar. The Zed extension is the neighboring repository `zed-ply`: install it as a dev extension after `cargo build -p plylang-ls`.
397
+ Highlighting is the [tree-sitter-ply](https://github.com/algosail/tree-sitter-ply) grammar. The Zed extension is the neighboring repository `zed-ply`. It installs `@plylang/language-server` for the editor. In this repository, `cargo build -p plylang-ls` is what the extension runs.
383
398
 
384
399
  The license is MIT.
package/bin/native.js CHANGED
@@ -1,6 +1,9 @@
1
- // The npm commands `plylang` and `plylang-ls` start here and run the Rust
2
- // binary. An installed optional package `@plylang/plylang-<os>-<arch>` wins.
3
- // A checkout of this repository uses `target/release`, then `target/debug`.
1
+ // The npm commands start here and run the Rust binary. `plylang` looks for
2
+ // `@plylang/plylang-<os>-<arch>`. `plylang-ls` looks for
3
+ // `@plylang/language-server-<os>-<arch>`. The command name and the package
4
+ // name differ on purpose. A caller can pass `resolvePackage` so the lookup
5
+ // starts from its own package. A checkout of this repository uses
6
+ // `target/release`, then `target/debug`.
4
7
 
5
8
  import { spawnSync } from "node:child_process";
6
9
  import { accessSync, constants, statSync } from "node:fs";
@@ -24,6 +27,20 @@ export function platformId(platform = process.platform, arch = process.arch) {
24
27
  return PLATFORMS.has(id) ? id : null;
25
28
  }
26
29
 
30
+ export function npmPackage(command) {
31
+ if (command === "plylang") {
32
+ return "@plylang/plylang";
33
+ }
34
+ if (command === "plylang-ls") {
35
+ return "@plylang/language-server";
36
+ }
37
+ throw new Error(`unknown command ${command}`);
38
+ }
39
+
40
+ export function platformPackage(command, id) {
41
+ return `${npmPackage(command)}-${id}`;
42
+ }
43
+
27
44
  export function resolveBinary(command, options = {}) {
28
45
  if (command !== "plylang" && command !== "plylang-ls") {
29
46
  throw new Error(`unknown command ${command}`);
@@ -44,7 +61,7 @@ export function resolveBinary(command, options = {}) {
44
61
 
45
62
  const id = platformId(platform, arch);
46
63
  if (id) {
47
- const pkgName = `@plylang/plylang-${id}`;
64
+ const pkgName = platformPackage(command, id);
48
65
  const pkgJson = resolvePackage(pkgName);
49
66
  if (pkgJson) {
50
67
  const name = fileName(command, platform);
@@ -70,7 +87,7 @@ function missing(command, id) {
70
87
  throw new Error(
71
88
  `${command} was not found for ${id}.\n` +
72
89
  "From a checkout, run `cargo build --release -p plylang -p plylang-ls`.\n" +
73
- `From npm, install the optional package @plylang/plylang-${id}.`,
90
+ `From npm, install the optional package ${platformPackage(command, id)}.`,
74
91
  );
75
92
  }
76
93
 
@@ -97,10 +114,10 @@ function defaultResolvePackage(name) {
97
114
  }
98
115
  }
99
116
 
100
- export function run(command) {
117
+ export function run(command, options = {}) {
101
118
  let bin;
102
119
  try {
103
- bin = resolveBinary(command);
120
+ bin = resolveBinary(command, options);
104
121
  } catch (error) {
105
122
  console.error(error.message);
106
123
  process.exit(1);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@plylang/plylang",
3
- "version": "1.0.26",
4
- "description": "Ply compiler and language server",
3
+ "version": "1.1.0",
4
+ "description": "Ply compiler",
5
5
  "license": "MIT",
6
6
  "author": "Algosail",
7
7
  "type": "module",
@@ -14,8 +14,7 @@
14
14
  "keywords": [
15
15
  "ply",
16
16
  "plylang",
17
- "compiler",
18
- "language-server"
17
+ "compiler"
19
18
  ],
20
19
  "engines": {
21
20
  "node": ">=24"
@@ -24,21 +23,19 @@
24
23
  "access": "public"
25
24
  },
26
25
  "bin": {
27
- "plylang": "bin/plylang.js",
28
- "plylang-ls": "bin/plylang-ls.js"
26
+ "plylang": "bin/plylang.js"
29
27
  },
30
28
  "files": [
31
29
  "bin/plylang.js",
32
- "bin/plylang-ls.js",
33
30
  "bin/native.js"
34
31
  ],
35
32
  "optionalDependencies": {
36
- "@plylang/plylang-darwin-arm64": "1.0.26",
37
- "@plylang/plylang-darwin-x64": "1.0.26",
38
- "@plylang/plylang-linux-arm64": "1.0.26",
39
- "@plylang/plylang-linux-x64": "1.0.26",
40
- "@plylang/plylang-win32-arm64": "1.0.26",
41
- "@plylang/plylang-win32-x64": "1.0.26"
33
+ "@plylang/plylang-darwin-arm64": "1.1.0",
34
+ "@plylang/plylang-darwin-x64": "1.1.0",
35
+ "@plylang/plylang-linux-arm64": "1.1.0",
36
+ "@plylang/plylang-linux-x64": "1.1.0",
37
+ "@plylang/plylang-win32-arm64": "1.1.0",
38
+ "@plylang/plylang-win32-x64": "1.1.0"
42
39
  },
43
40
  "scripts": {
44
41
  "build": "cargo build --release",
package/bin/plylang-ls.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import { run } from "./native.js";
3
-
4
- run("plylang-ls");