marduk-plan 0.2.0__tar.gz
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.
- marduk_plan-0.2.0/PKG-INFO +52 -0
- marduk_plan-0.2.0/README.md +32 -0
- marduk_plan-0.2.0/marduk/__init__.py +45 -0
- marduk_plan-0.2.0/marduk/asm/__init__.py +46 -0
- marduk_plan-0.2.0/marduk/asm/expander.py +546 -0
- marduk_plan-0.2.0/marduk/asm/prelude.py +111 -0
- marduk_plan-0.2.0/marduk/asm/printer.py +107 -0
- marduk_plan-0.2.0/marduk/asm/reader.py +271 -0
- marduk_plan-0.2.0/marduk/runtime/__init__.py +39 -0
- marduk_plan-0.2.0/marduk/runtime/bplan.py +721 -0
- marduk_plan-0.2.0/marduk/runtime/core.py +664 -0
- marduk_plan-0.2.0/marduk/runtime/jets.py +175 -0
- marduk_plan-0.2.0/marduk/runtime/strnat.py +33 -0
- marduk_plan-0.2.0/marduk_plan.egg-info/PKG-INFO +52 -0
- marduk_plan-0.2.0/marduk_plan.egg-info/SOURCES.txt +24 -0
- marduk_plan-0.2.0/marduk_plan.egg-info/dependency_links.txt +1 -0
- marduk_plan-0.2.0/marduk_plan.egg-info/requires.txt +3 -0
- marduk_plan-0.2.0/marduk_plan.egg-info/top_level.txt +1 -0
- marduk_plan-0.2.0/pyproject.toml +39 -0
- marduk_plan-0.2.0/setup.cfg +4 -0
- marduk_plan-0.2.0/tests/test_asm.py +276 -0
- marduk_plan-0.2.0/tests/test_bplan.py +352 -0
- marduk_plan-0.2.0/tests/test_core.py +391 -0
- marduk_plan-0.2.0/tests/test_differential.py +281 -0
- marduk_plan-0.2.0/tests/test_jets.py +222 -0
- marduk_plan-0.2.0/tests/test_skeleton.py +13 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: marduk-plan
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python implementation of the PLAN instruction set.
|
|
5
|
+
Author-email: Neal Davis <davisneale@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/sigilante/marduk
|
|
7
|
+
Project-URL: Repository, https://github.com/sigilante/marduk
|
|
8
|
+
Keywords: plan,bplan,interpreter,runtime
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Education
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Provides-Extra: dev
|
|
19
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
20
|
+
|
|
21
|
+
# marduk
|
|
22
|
+
|
|
23
|
+
A standalone Python runtime for the [PLAN virtual machine](https://github.com/xocore-tech/PLAN).
|
|
24
|
+
|
|
25
|
+
**Status:** pre-alpha. The package is a placeholder — the spec-faithful core, BPLAN op coverage, and jet overlay land in subsequent commits. Until then, callers that need a Python PLAN runtime use [`packages/plan-kernel/`](../plan-kernel/)'s vendored harness.
|
|
26
|
+
|
|
27
|
+
## Goals
|
|
28
|
+
|
|
29
|
+
- **Spec-faithful core.** A direct translation of [`vendor/reaver/doc/plan-spec.txt`](https://github.com/xocore-tech/PLAN) — `E`/`R`/`H`/`J`/`B`/`S`/`C`/`I`/`X` as Python functions over a `Thunk`-cell value type with update-in-place `force`. Strictness comes from the spec's `;` sequencing, not from Python's evaluation order.
|
|
30
|
+
- **Complete BPLAN op coverage.** All of Reaver's `op 66` named primitives, including the IO family that today's harness stubs.
|
|
31
|
+
- **Jet overlay.** An optional id-keyed performance layer; correctness lives in the spec-faithful interpreter regardless of jet presence.
|
|
32
|
+
- **Differential against Reaver.** A small Plan Asm corpus run on both Marduk and Reaver in CI.
|
|
33
|
+
- **No coupling to gallowglass.** Marduk imports nothing from gallowglass; gallowglass eventually depends on Marduk as a library.
|
|
34
|
+
|
|
35
|
+
## Non-goals
|
|
36
|
+
|
|
37
|
+
- Native-speed PLAN execution. Marduk is correctness-first; production workloads belong on Reaver.
|
|
38
|
+
- Hosting Reaver-itself-as-BPLAN. A future possibility once IO ops and performance reach the bar; not in scope for the initial release.
|
|
39
|
+
|
|
40
|
+
## Layout
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
packages/marduk/
|
|
44
|
+
├── marduk/ # Python package
|
|
45
|
+
│ └── __init__.py
|
|
46
|
+
├── tests/
|
|
47
|
+
└── pyproject.toml
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# marduk
|
|
2
|
+
|
|
3
|
+
A standalone Python runtime for the [PLAN virtual machine](https://github.com/xocore-tech/PLAN).
|
|
4
|
+
|
|
5
|
+
**Status:** pre-alpha. The package is a placeholder — the spec-faithful core, BPLAN op coverage, and jet overlay land in subsequent commits. Until then, callers that need a Python PLAN runtime use [`packages/plan-kernel/`](../plan-kernel/)'s vendored harness.
|
|
6
|
+
|
|
7
|
+
## Goals
|
|
8
|
+
|
|
9
|
+
- **Spec-faithful core.** A direct translation of [`vendor/reaver/doc/plan-spec.txt`](https://github.com/xocore-tech/PLAN) — `E`/`R`/`H`/`J`/`B`/`S`/`C`/`I`/`X` as Python functions over a `Thunk`-cell value type with update-in-place `force`. Strictness comes from the spec's `;` sequencing, not from Python's evaluation order.
|
|
10
|
+
- **Complete BPLAN op coverage.** All of Reaver's `op 66` named primitives, including the IO family that today's harness stubs.
|
|
11
|
+
- **Jet overlay.** An optional id-keyed performance layer; correctness lives in the spec-faithful interpreter regardless of jet presence.
|
|
12
|
+
- **Differential against Reaver.** A small Plan Asm corpus run on both Marduk and Reaver in CI.
|
|
13
|
+
- **No coupling to gallowglass.** Marduk imports nothing from gallowglass; gallowglass eventually depends on Marduk as a library.
|
|
14
|
+
|
|
15
|
+
## Non-goals
|
|
16
|
+
|
|
17
|
+
- Native-speed PLAN execution. Marduk is correctness-first; production workloads belong on Reaver.
|
|
18
|
+
- Hosting Reaver-itself-as-BPLAN. A future possibility once IO ops and performance reach the bar; not in scope for the initial release.
|
|
19
|
+
|
|
20
|
+
## Layout
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
packages/marduk/
|
|
24
|
+
├── marduk/ # Python package
|
|
25
|
+
│ └── __init__.py
|
|
26
|
+
├── tests/
|
|
27
|
+
└── pyproject.toml
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Marduk — standalone Python runtime for the PLAN virtual machine.
|
|
2
|
+
|
|
3
|
+
This package is a thunked, spec-faithful translation of
|
|
4
|
+
``vendor/reaver/doc/plan-spec.txt`` into Python. The core interpreter
|
|
5
|
+
(spec rules E/F/X/S and friends, plus the ``Val`` cell type that supports
|
|
6
|
+
update-in-place for letrec / Y / fix) lives in :mod:`marduk.runtime.core`.
|
|
7
|
+
|
|
8
|
+
Public surface, re-exported from :mod:`marduk.runtime`:
|
|
9
|
+
|
|
10
|
+
* ``Val`` — universal cell type.
|
|
11
|
+
* ``Hol``, ``Nat``, ``Pin``, ``App``, ``Law`` — smart constructors.
|
|
12
|
+
* ``evaluate(v)`` — force to WHNF.
|
|
13
|
+
* ``force(v)`` — force the App spine to NF (pins and law bodies stay opaque).
|
|
14
|
+
* ``PlanError``, ``PlanLoop`` — exceptions for stuck states and hole-loops.
|
|
15
|
+
|
|
16
|
+
Optional jet overlay (see :mod:`marduk.runtime.jets`):
|
|
17
|
+
|
|
18
|
+
* ``register_jet(law, fn)`` — install a native Python implementation
|
|
19
|
+
for a specific Law value.
|
|
20
|
+
* ``set_jets(bool)`` / ``jets_enabled()`` — global on/off switch. Use
|
|
21
|
+
``set_jets(False)`` to force every law to evaluate via the
|
|
22
|
+
spec-faithful path (correctness oracle / differential testing).
|
|
23
|
+
|
|
24
|
+
Plan Asm I/O lives in :mod:`marduk.asm`.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
from .runtime import (
|
|
28
|
+
Val,
|
|
29
|
+
Hol, Nat, Pin, App, Law,
|
|
30
|
+
evaluate, force,
|
|
31
|
+
PlanError, PlanLoop,
|
|
32
|
+
register_jet, lookup_jet, clear_jets,
|
|
33
|
+
set_jets, jets_enabled,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
__version__ = "0.0.1"
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"Val",
|
|
40
|
+
"Hol", "Nat", "Pin", "App", "Law",
|
|
41
|
+
"evaluate", "force",
|
|
42
|
+
"PlanError", "PlanLoop",
|
|
43
|
+
"register_jet", "lookup_jet", "clear_jets",
|
|
44
|
+
"set_jets", "jets_enabled",
|
|
45
|
+
]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""marduk.asm — Plan Asm I/O.
|
|
2
|
+
|
|
3
|
+
Read, macro-expand, and print Plan Asm text against the Marduk runtime.
|
|
4
|
+
|
|
5
|
+
* :func:`parse` / :func:`parse_many` — Plan Asm text → ``Val``.
|
|
6
|
+
* :class:`Env` — top-level mutable environment for ``#bind``.
|
|
7
|
+
* :func:`macroexpand` / :func:`thunk` / :func:`eval_form` — the macro-layer
|
|
8
|
+
pipeline. ``eval_form(val, env)`` is the full driver: macroexpand →
|
|
9
|
+
thunk → runtime evaluate.
|
|
10
|
+
* :func:`dump` — ``Val`` → Plan Asm text (best-effort round-trippable).
|
|
11
|
+
|
|
12
|
+
A typical interactive flow:
|
|
13
|
+
|
|
14
|
+
>>> from marduk.asm import parse, eval_form, Env, dump
|
|
15
|
+
>>> env = Env()
|
|
16
|
+
>>> # Bind ``add`` to a 2-arg law that calls BPLAN's Add.
|
|
17
|
+
>>> form = parse('(#bind add (#law "add" (self n m) (Add n m)))')
|
|
18
|
+
>>> # ``Add`` would need to be in env first; see prelude wiring.
|
|
19
|
+
|
|
20
|
+
The expander's API is shape-compatible with plan-kernel's lifted-from
|
|
21
|
+
predecessor so the kernel's evaluator can swap the import path with
|
|
22
|
+
minimal change.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from .reader import ParseError, parse, parse_many
|
|
26
|
+
from .expander import (
|
|
27
|
+
Env,
|
|
28
|
+
MacroError,
|
|
29
|
+
macroexpand,
|
|
30
|
+
thunk,
|
|
31
|
+
eval_form,
|
|
32
|
+
)
|
|
33
|
+
from .printer import dump
|
|
34
|
+
from .prelude import load_prelude, make_bplan_wrapper, PRELUDE_NAMES, BPLAN
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
# reader
|
|
39
|
+
"ParseError", "parse", "parse_many",
|
|
40
|
+
# expander
|
|
41
|
+
"Env", "MacroError", "macroexpand", "thunk", "eval_form",
|
|
42
|
+
# printer
|
|
43
|
+
"dump",
|
|
44
|
+
# prelude
|
|
45
|
+
"load_prelude", "make_bplan_wrapper", "PRELUDE_NAMES", "BPLAN",
|
|
46
|
+
]
|