Add a package manager: rex init/add/remove/get/update/deps
Packages come from git (a registry can be added later; a bare version in rex.toml is reserved for it). rex.toml [deps] names them, rex.lock pins exact commits, and run/build/check/test download what is missing. `import json` reads the package's json.rex; package files get `@json...` module keys so they never mix with the project's own files. Newest tag of the same major version wins when packages disagree. The language server reads downloaded packages. Docs: docs/14-packages.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
300d767124
commit
15da1e2379
16 files changed
+1588
-61
No files matched your search
@@ -212,6 +212,19 @@ Targets: game dev, CLI tools, desktop apps.
|
||||
`CLITERAL(Color){...}` (emitted as the macro). Programs that import headers are built with `-std=gnu11`.
|
||||
Not supported (a clear error when called): variadic functions, callbacks, unions/arrays by value, lists of
|
||||
structs, `long double`, function-like macros. Rex never frees C memory. `rex header x.h [word]` lists what Rex sees.
|
||||
- **Packages** (`src/pkg.rs`): git repositories (a registry may come later; `json = "1.2.0"` is reserved for
|
||||
it and is an error now). `rex.toml` `[deps]` maps a name to `"host/owner/repo@rev"` (https is added; `://`
|
||||
and `git@host:` addresses kept as written; rev = tag, branch or commit; none = main branch) or a folder
|
||||
(`"../lib"`). `rex.lock` (lines `name url rev commit`) pins commits. Cache: `$REX_HOME` or `~/.cache/rex`
|
||||
(`git/` bare mirrors, `pkg/<url>/<commit>/` unpacked with `git archive`). `run/build/check/test` download what
|
||||
is missing and rewrite the lock when rex.toml changed; the LSP only reads what is downloaded. Versions: one per
|
||||
package name in a build; same repo + same major -> the newest tag wins (re-walk), else an error naming both.
|
||||
The project's folder deps override. `import json` -> the package's `json.rex`, `import json.p` -> its `p.rex`;
|
||||
inside the package, imports count from its top folder. Module keys of package files start with `@`
|
||||
(`@json.p`, see `loader::Scope`), and the loader sets `Import.alias` to the written last word. A project file
|
||||
`json.rex` next to a package `json` is an error. Commands: `rex init [name]`, `rex add <addr>[@rev] [--name n]`
|
||||
(newest tag when none given; name from the package's `[package] name`, else the last address part),
|
||||
`rex remove`, `rex get`, `rex update [names]` (newest tag of the same major; branch deps move), `rex deps`.
|
||||
- **String slicing**: `s[a..b]`, `s[a..]`, `s[..b]` (byte positions, bounds checked; panics with "the length is N").
|
||||
- **Running**: `rex run file.rex a b c` passes `a b c` to the program (`os.args`).
|
||||
- **Example**: `examples/calc/` is a multi-file calculator (tokenizer, parser, evaluator, shared scope); `session.txt` / `session.out` are checked by a test.
|
||||
|
||||
Reference in new issue
Block a user