Skip to content

Commit d29f02c

Browse files
Add primitive command support
1 parent d443c29 commit d29f02c

14 files changed

Lines changed: 415 additions & 12 deletions

Cargo.lock

Lines changed: 30 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ default = ["bin"]
1717
bin = ["egglog/bin"]
1818

1919
[dependencies]
20-
egglog = { git = "https://github.com/egraphs-good/egglog.git", default-features = false, rev = "602a6bd" }
21-
egglog-ast = { git = "https://github.com/egraphs-good/egglog.git", default-features = false, rev = "602a6bd" }
22-
egglog-reports = { git = "https://github.com/egraphs-good/egglog.git", default-features = false, rev = "602a6bd" }
20+
egglog = { git = "https://github.com/saulshanabrook/egg-smol.git", branch = "codex/split-primitive-body-runtime-apis", default-features = false }
21+
egglog-ast = { git = "https://github.com/saulshanabrook/egg-smol.git", branch = "codex/split-primitive-body-runtime-apis", default-features = false }
22+
egglog-reports = { git = "https://github.com/saulshanabrook/egg-smol.git", branch = "codex/split-primitive-body-runtime-apis", default-features = false }
2323

2424
num = "0.4.3"
2525
lazy_static = "1.4"

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
//! - [`(get-size!)` primitive](https://github.com/egraphs-good/egglog-experimental/blob/main/tests/web-demo/node-limit.egg)
1717
//! for inspecting total tuple counts, optionally restricted to specific tables
1818
//! - [Multi-extraction](https://github.com/egraphs-good/egglog-experimental/blob/main/tests/web-demo/multi-extract.egg)
19+
//! - Body-defined primitives with `(primitive name (InputSort*) OutputSort body)`.
20+
//! Body variables are positional (`_0`, `_1`, ...), and a partial primitive
21+
//! body result propagates as primitive failure. Bodies may call built-in or
22+
//! previously registered primitives, but they may not call or capture
23+
//! table-backed functions, nor accept or return function-container sorts,
24+
//! because those reads are hidden from seminaive rule dependency analysis.
1925
//!
2026
//! Each bullet links to a runnable demo so you can explore the feature quickly.
2127
//! The rest of this crate exposes the Rust APIs and helpers that back these extensions.
@@ -37,6 +43,7 @@ mod multi_extract;
3743
pub use multi_extract::*;
3844
mod size;
3945
pub use size::*;
46+
mod primitive;
4047

4148
// Sugar modules using parse-time macros
4249
mod sugar;
@@ -72,6 +79,9 @@ pub fn new_experimental_egraph() -> EGraph {
7279
)
7380
.unwrap();
7481
egraph
82+
.add_command("primitive".into(), Arc::new(primitive::RegisterPrimitive))
83+
.unwrap();
84+
egraph
7585
}
7686

7787
// Create a parser with experimental macros

0 commit comments

Comments
 (0)