Files
rose-ash/shared/sx/__init__.py
giles 29c90a625b Delete evaluator.py shim: all imports go directly to bootstrapped sx_ref.py
EvalError moved to types.py. All 27 files updated to import eval_expr,
trampoline, call_lambda, etc. directly from shared.sx.ref.sx_ref instead
of through the evaluator.py indirection layer. 320/320 spec tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 11:15:48 +00:00

70 lines
1.3 KiB
Python

"""
S-expression language core.
Parse, evaluate, and serialize s-expressions. This package provides the
foundation for the composable fragment architecture described in
``docs/sx-architecture-plan.md``.
Quick start::
from shared.sx import parse, evaluate, serialize, Symbol, Keyword
expr = parse('(let ((x 10)) (+ x 1))')
result = evaluate(expr) # → 11
expr2 = parse('(map (fn (n) (* n n)) (list 1 2 3))')
result2 = evaluate(expr2) # → [1, 4, 9]
"""
from .types import (
NIL,
Component,
HandlerDef,
Keyword,
Lambda,
Macro,
Symbol,
)
from .parser import (
ParseError,
parse,
parse_all,
serialize,
)
from .types import EvalError
from .ref.sx_ref import evaluate, make_env
from .primitives import (
all_primitives,
get_primitive,
register_primitive,
)
from . import primitives_stdlib # noqa: F401 — registers stdlib primitives
from .env import Env
__all__ = [
# Types
"Symbol",
"Keyword",
"Lambda",
"Macro",
"Component",
"HandlerDef",
"NIL",
# Parser
"parse",
"parse_all",
"serialize",
"ParseError",
# Evaluator
"evaluate",
"make_env",
"EvalError",
# Primitives
"register_primitive",
"get_primitive",
"all_primitives",
# Environment
"Env",
]