Skip to main content

Crate opy_rs

Crate opy_rs 

Source
Expand description

The standalone OverPy-compatible .opy implementation (opy-rs).

Owns the OPY source-language surface of the opy-rs repository: a lexer, an indentation-aware CST/parser with structured diagnostics and recovery, token-level preprocessing (includes and #!define macros), semantic resolution, and lowering into the opy-rs-owned Opy HIR contract (hir::Program). Everything from source through the Opy HIR semantic model is Workshop-independent: source analysis never depends on workshop-rs, OverPy, or Node. The bounded source-to-Workshop compiler is exposed from this same crate behind the explicit Compiler API.

Pipeline: lexer::lexpreprocess::preprocessparser::parselower::lower → Opy HIR (hir).

OverPy-compatible __script__("…") macros execute at compile time through the bounded embedded macro runtime: script macros expand during preprocessing with the reference’s argument-injection ABI, and resource limits mirror the pinned reference constants (macro_js::Limits::default()). Script-macro expansion is compile-time behavior and is source-supported.

#!postCompileHook is recognized, parsed, validated, and recorded only (see [preprocess] and CompileOutcome::post_compile_hook): the The source implementation never executes the hook. Real hook execution receives the final Workshop text produced by lowering and is lowering-dependent (workshop-rs emission, issue #8); source analysis never fabricates a Workshop payload.

This crate owns the OverPy source-language implementation, its bounded compiler, Workshop→OPY reconstruction, and the isolated differential harness entry points.

Re-exports§

pub use diag::OpyError;
pub use diag::OpyResult;
pub use lower::lower;
pub use parser::parse;
pub use preprocess::preprocess;
pub use preprocess::preprocess_with_overlay;

Modules§

cst
The frontend’s concrete syntax tree (CST).
diag
Frontend diagnostics: structured, source-located failures.
hir
Opy HIR v2 — the OPY semantic model owned by opy-rs.
lexer
The native .opy lexer.
lower
Semantic resolution and HIR lowering (#45).
manifest
The OPY semantic compatibility manifest (issue #109).
parser
The indentation-aware .opy CST parser.
preprocess
.opy preprocessing: includes, #!define macros (textual and __script__ JavaScript-backed), #!postCompileHook, and expansion.
reconstruct
Workshop IR → OPY reconstruction (issue #124).
settings
Scoped settings { ... } extraction and JSONC parsing (#86).
support
Compatibility support-matrix accessor (read-only).
tooling
Workshop-independent tooling APIs: check a project and query the resolved semantic model.

Structs§

CompilationArtifact
A validated WIR program and its emitted Workshop artifact for advanced integrations.
CompileDiagnostic
A versioned, source-attributed diagnostic exposed by the compile API.
CompileOutcome
The outcome of a compile with overlays.
CompileOutput
A source compile result for ordinary embedding callers.
CompileReport
Complete versioned compile report for CLI, CI, and embedding consumers.
CompileResult
The machine-readable result for one compile operation.
Compiler
The compiler-facing integration object. Construction validates the public manifest/catalog contract once and exposes the pinned catalog identity.
CompilerIdentity
Stable identity of the compiler that produced a compile report.
IntegrationDiagnostic
A source-attributed integration diagnostic.
IntegrationError
An integration boundary failure.
LinkReport
Results of the manifest-to-catalog cross-check.
PostCompileHookRecord
The recorded declaration of a #!postCompileHook script.
ScriptDiagnostic
Script-runtime provenance retained alongside the OPY directive anchor.

Enums§

CompileFailureClass
Stable classification for a compile failure.
CompileStatus
Whether compilation produced a valid Workshop artifact.

Constants§

COMPILE_SCHEMA_VERSION
Version of the machine-readable compile report contract.
LANGUAGE_NAME
The producer identity for generated HIR.
LANGUAGE_VERSION
WORKSHOP_RS_VERSION
The exact released dependency contract consumed by this crate.

Functions§

compile
Compile one .opy source end-to-end into the Opy HIR contract: preprocess (includes/defines) → parse (CST) → lower (HIR).
compile_with_overlay
Compile with open-document overlays: includes resolve to overlay text (keyed by the include string or the resolved canonical path) before the filesystem, so unsaved editor buffers participate in include resolution.
compile_with_overlay_outcome
Compile with open-document overlays while retaining the source file registry on parse/lower failure.