Skip to main content

Crate rpic_core

Crate rpic_core 

Source
Expand description

rpic-core — engine for the pic picture-drawing language.

Pipeline: source → lexerparserast → [eval] → placed primitives (ir) → render backends (svg, later PNG/PDF). This crate is pure (no file I/O); the CLI and WASM wrappers drive it.

Note: [eval] is the pic-language interpreter — a safe walker over a typed expression/geometry tree. It executes no arbitrary code.

Re-exports§

pub use eval::EvalError;
pub use eval::eval;
pub use ir::Drawing;
pub use lexer::LexError;
pub use lexer::lex;
pub use parser::ParseError;
pub use parser::parse;
pub use parser::parse_in_dir;
pub use svg::to_svg;
pub use token::Token;

Modules§

ast
Abstract syntax tree for the pic language.
eval
Evaluator: walks the crate::ast and produces a placed-primitive Drawing using pic’s positioning semantics.
geom
Geometry primitives. pic works in a Cartesian plane with y pointing up; internal units are pic “inches” (scaled to device units by each backend).
ir
Intermediate representation: the placed-primitive tree produced by the evaluator and consumed by the render backends. All coordinates are absolute, in pic units (inches), y pointing up.
lexer
Hand-written lexer for the pic language.
parser
Recursive-descent parser for the pic drawing core.
svg
SVG 1.1 backend. Renders a Drawing to an SVG string.
token
Token set for the pic language, mirroring dpic’s dpic.toks.

Structs§

MathSpan
A typeset math label: a self-contained SVG fragment (glyph paths only, rasterizable with no font database) plus exact metrics in inches.

Constants§

CIRCUITS
Bundled native circuit-element library (the define dialect). Prepend it to source to use resistor, capacitor, … See std/circuits.pic.

Functions§

animations_json
Build the JSON animation manifest array ([{id,effect,start,duration},…]) for an already-compiled drawing.
compile
Compile pic source into a placed-primitive Drawing.
compile_in_dir
Compile pic source, resolving copy "file" includes relative to base.
compile_json
Compile to a single JSON object { "svg": "...", "animations": [...], "diagnostics": [...] }, or { "error": "..." } on failure. This is the entry point the WASM wrapper and browser playground consume.
diagnostics_json
Build the JSON diagnostic array emitted by pic print statements.
render_svg
Compile pic source directly to an SVG string.
render_svg_in_dir
Render pic source to SVG, resolving copy "file" includes relative to base.
set_math_renderer
Register the process-wide math renderer. The first call wins; later calls are ignored (returns whether this call installed the renderer).