diff options
| -rw-r--r-- | build.zig | 22 | ||||
| -rw-r--r-- | docs/typ/building.typ | 75 |
2 files changed, 60 insertions, 37 deletions
@@ -3,15 +3,25 @@ //! builds the editor; docs/typ/building.typ has the rest. //! //! A package that depends on pardes is given its syntax, `pardes-syntax` -//! (core/lib_syntax.zig): +//! (`core/lib_syntax.zig`): //! -//! const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .minimal }); +//! const pardes = b.dependency("pardes", .{ +//! .target = target, +//! .optimize = optimize, +//! .grammars = .minimal, +//! }); //! exe.root_module.addImport("pardes-syntax", pardes.module("pardes-syntax")); //! -//! and, when it asks, the text pane, `pardes-editor` (core/lib_editor.zig), -//! here with a grammar of its own handed in at run time: +//! and, when it asks, the text pane, `pardes-editor` +//! (`core/lib_editor.zig`), here with a grammar of its own handed in at +//! run time: //! -//! const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, .grammars = .none, .editor = true }); +//! const pardes = b.dependency("pardes", .{ +//! .target = target, +//! .optimize = optimize, +//! .grammars = .none, +//! .editor = true, +//! }); //! exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); //! //! `.grammars`: the tree-sitter grammars compiled in: `none` (the runtime @@ -22,7 +32,7 @@ //! Every dependency but tree-sitter's runtime is lazy in the manifest, so //! such a package fetches what it asked for and nothing else. //! `pardes-editor` has `pardes-syntax` in it as `.syntax`: a file belongs -//! to one module, so a package imports one of the two. test/consumer is +//! to one module, so a package imports one of the two. `test/consumer` is //! such a package, with both shapes; `lib-test`, which `unit-test` runs, //! builds and runs it. const std = @import("std"); diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 8d14374d..d73543e1 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -92,15 +92,12 @@ moves an anchor fails that file's step. Each table says why, edit by edit. == As a library <library> -A Zig package that depends on pardes is given one module and nothing of -the editor: `pardes-syntax` (`core/lib_syntax.zig`), for a program that -draws source text itself and wants it parsed and coloured as pardes has -it. +As `build.zig`'s head comment says it, word for word: + +A package that depends on pardes is given its syntax, `pardes-syntax` +(`core/lib_syntax.zig`): ``` -// build.zig.zon -.pardes = .{ .path = "../pardes" }, -// build.zig const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, @@ -109,6 +106,36 @@ const pardes = b.dependency("pardes", .{ exe.root_module.addImport("pardes-syntax", pardes.module("pardes-syntax")); ``` +and, when it asks, the text pane, `pardes-editor` +(`core/lib_editor.zig`), here with a grammar of its own handed in at +run time: + +``` +const pardes = b.dependency("pardes", .{ + .target = target, + .optimize = optimize, + .grammars = .none, + .editor = true, +}); +exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); +``` + +`.grammars`: the tree-sitter grammars compiled in: `none` (the runtime +alone), `minimal` (C, C++ and Zig) or `full` (all of them; the default). +`.editor`: exports `pardes-editor` besides `pardes-syntax`, and with it +fetches uucode, mvzr and vaxis. + +Every dependency but tree-sitter's runtime is lazy in the manifest, so +such a package fetches what it asked for and nothing else. +`pardes-editor` has `pardes-syntax` in it as `.syntax`: a file belongs +to one module, so a package imports one of the two. `test/consumer` is +such a package, with both shapes; `lib-test`, which `unit-test` runs, +builds and runs it. + +`build.zig.zon` names pardes by its path: `.pardes = .{ .path = "../pardes" }`. + +=== The syntax + It is the editor's own code under the names it has there. A language is told by a path's extension, as in the editor, and `pathFor` gives a path for a language's name. @@ -122,35 +149,21 @@ for a language's name. [`start`, `stop`], [tree-sitter's allocator, and the end of the parsers kept per language], ) -The `grammars` option is the build's own: `none` (the runtime alone), -`minimal` (C, C++ and Zig) or `full` (all of them; the default). Every dependency but tree-sitter's -runtime is lazy in the manifest, so the package fetches the runtime and -its set's grammars and compiles those alone; pardes's own build asks for -what it is missing in one round. Zig still unpacks a lazy package whose -archive its global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) -at pardes's `zig-pkg` shares the one copy. What a pane measures stays -out: a cell's width is vaxis's and uucode's, and a tab is -`config.tab_width` cells wherever it stands. `test/consumer` is such a -package, and `zig build lib-test` builds and runs it. +pardes's own build takes `-Dgrammars` too, and asks for what it is +missing in one round. Zig still unpacks a lazy package whose archive its +global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) at +pardes's `zig-pkg` shares the one copy. What a pane measures stays out: a +cell's width is vaxis's and uucode's, and a tab is `config.tab_width` +cells wherever it stands. === The editor `pardes-editor` (`core/lib_editor.zig`) is the text pane as a library: helix's keys on a text kept in memory, no files, commands, builtins, -prompts or views. A package asks for it, and is then given uucode, mvzr -and vaxis's grapheme width besides; one that does not fetches nothing more. -It has `pardes-syntax` in it as `.syntax`: a file belongs to one module, so -a package imports one of the two. - -``` -const pardes = b.dependency("pardes", .{ - .target = target, - .optimize = optimize, - .grammars = .minimal, - .editor = true, -}); -exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); -``` +prompts or views. Of vaxis it takes the grapheme width alone. With +`.grammars = .none` it has no grammar of pardes's: a program hands its +own in at run time (`Language`, below), linking the grammar's parser +itself, as `test/consumer` does with C's. The editor is a value of plain data, `Editor(capacity)`: no pointer, no allocator, every capacity in its type, so a program keeps it where it |
