Skip to main content

Ast

Enum Ast 

Source
pub enum Ast<I = String> {
Show 34 variants Unit, Bool(bool), Int(i64), Float(f64), Length(Length), Str(String), Var(I, Span), Apply(Box<Ast<I>>, Box<Ast<I>>), Lambda(I, Rc<Ast<I>>), LetIn(I, Box<Ast<I>>, Box<Ast<I>>), LetRecIn(Vec<(I, Rc<Ast<I>>)>, Box<Ast<I>>), LetMathIn(I, Box<Ast<I>>, Box<Ast<I>>), IfThenElse(Box<Ast<I>>, Box<Ast<I>>, Box<Ast<I>>), Match(Box<Ast<I>>, Vec<MatchArm<I>>), Tuple(Vec<Ast<I>>), Ctor(String, Option<Box<Ast<I>>>), Record(Vec<(String, Ast<I>)>), List(Vec<Ast<I>>), InlineText(Rc<Vec<IText<I>>>), BlockText(Rc<Vec<BText<I>>>), MathText(Rc<Vec<MathElem<I>>>), LetMutableIn(I, Box<Ast<I>>, Box<Ast<I>>), Overwrite(I, Span, Box<Ast<I>>), WhileDo(Box<Ast<I>>, Box<Ast<I>>), Sequential(Box<Ast<I>>, Box<Ast<I>>), AccessField(Box<Ast<I>>, String, Span), UpdateField(Box<Ast<I>>, String, Box<Ast<I>>), ApplyOpt { func: Box<Ast<I>>, opts: Vec<(String, Ast<I>)>, arg: Box<Ast<I>>, }, LambdaOpt { opts: Vec<(String, I)>, param: I, body: Rc<Ast<I>>, }, VersionScope(RustyfiVersion, Box<Ast<I>>), ModuleScope(Vec<String>, Box<Ast<I>>), StageScope(Stage, Box<Ast<I>>), Next(Box<Ast<I>>), Prev(Box<Ast<I>>),
}

Variants§

§

Unit

§

Bool(bool)

§

Int(i64)

§

Float(f64)

§

Length(Length)

§

Str(String)

§

Var(I, Span)

§

Apply(Box<Ast<I>>, Box<Ast<I>>)

§

Lambda(I, Rc<Ast<I>>)

§

LetIn(I, Box<Ast<I>>, Box<Ast<I>>)

§

LetRecIn(Vec<(I, Rc<Ast<I>>)>, Box<Ast<I>>)

Mutually recursive bindings (let-rec … and …); every body must be a Lambda, all names are in scope in all bodies.

§

LetMathIn(I, Box<Ast<I>>, Box<Ast<I>>)

let-math \cmd param* = expr in body — a math-command binding. Evaluates identically to LetIn; the DISTINCT variant exists purely so the typechecker can tell it apart from an ordinary \-sigiled LetIn (a let-inline binding, or a qualified-name alias of one) without re-deriving that from the shared \ sigil — see typecheck.rs’s Checker::math_command_scheme.

§

IfThenElse(Box<Ast<I>>, Box<Ast<I>>, Box<Ast<I>>)

§

Match(Box<Ast<I>>, Vec<MatchArm<I>>)

§

Tuple(Vec<Ast<I>>)

§

Ctor(String, Option<Box<Ast<I>>>)

A variant constructor, optionally applied (None / Some 3). The tag is a data-level name, not an environment key — see the module doc comment on what I does and does not cover.

§

Record(Vec<(String, Ast<I>)>)

§

List(Vec<Ast<I>>)

§

InlineText(Rc<Vec<IText<I>>>)

Quoted inline text: evaluated only when read-inline runs it.

§

BlockText(Rc<Vec<BText<I>>>)

Quoted block text: evaluated only when read-block runs it.

§

MathText(Rc<Vec<MathElem<I>>>)

Quoted math text (${…}); typesetting is deferred, the value is carried opaquely until then.

§

LetMutableIn(I, Box<Ast<I>>, Box<Ast<I>>)

let-mutable x <- init in body — binds x to a mutable cell.

§

Overwrite(I, Span, Box<Ast<I>>)

x <- e — overwrite a mutable cell; evaluates to unit.

§

WhileDo(Box<Ast<I>>, Box<Ast<I>>)

while cond do body — evaluates to unit.

§

Sequential(Box<Ast<I>>, Box<Ast<I>>)

e1 before e2 (UTSequential) — evaluate e1 for effect, then e2.

§

AccessField(Box<Ast<I>>, String, Span)

e#label (UTAccessField). The label is a record field, not an environment key — see the module doc comment.

§

UpdateField(Box<Ast<I>>, String, Box<Ast<I>>)

(| e with label = v |) (UTUpdateField) — functional record update.

§

ApplyOpt

f ?(l = e, …) arg — SATySFi 0.1 labeled-optional application (upstream Apply(labmap, e1, e2)). opts is non-empty by construction: a bundle-less 0.1 application lowers to plain Ast::Apply. Labels are deduplicated at elaboration; at beta-reduction a provided ?(l = e) binds the closure’s l binder to Some e, and any declared label the call omits binds None (see eval::Interp::apply_with_opts).

Fields

§func: Box<Ast<I>>
§opts: Vec<(String, Ast<I>)>
§arg: Box<Ast<I>>
§

LambdaOpt

fun ?(l = x, …) p -> body — SATySFi 0.1 labeled-optional lambda (upstream Function(evid_labmap, patbr)). opts maps each label to the binder name that receives its option-typed value. Pattern params are pre-desugared (by elaborate) to a fresh var + Match, like rec_clause_value, so param here is always a plain binder.

Note the mixed pair: each label is data (String — it is matched against a call site’s ?(l = e) labels), while each binder is a lexical variable (I — it becomes an environment key).

Fields

§opts: Vec<(String, I)>
§param: I
§body: Rc<Ast<I>>
§

VersionScope(RustyfiVersion, Box<Ast<I>>)

A version tag around one spliced cross-version dependency binding’s RHS. elaborate.rs’s cross-version splice wraps each binding contributed by a LoadedCst::V0_0 dependency in VersionScope(V0_0, rhs), at RHS granularity (never the surrounding LetIn/LetRecIn node, and never the continuation that follows it). Three consumers push/pop a cursor around recursing into body:

  • compile.rs’s Compiler::current_version — which base environment (V0_1’s or V0_0’s) an unshadowed Ast::Var constant-folds against, so a version-forked primitive (page-break, math-*, …) freezes to the RIGHT version’s PrimDef at compile time (the only version-sensitive resolution in the whole pipeline).
  • eval.rs’s Interp::version — any runtime fork that reads it (primitives.rs’s reflect_math_elem/coerce_graphics_result/ make_paren_run) sees V0_0 while evaluating on behalf of this subtree.
  • typecheck.rs’s base-type-env swap — the subtree’s internal forked-primitive-type use checks against V0_0’s primitive types.

Never emitted on a pure single-version load — structurally inert on the pure-0.0.6/pure-0.1 paths: no arm executes, no runtime check is involved.

§

ModuleScope(Vec<String>, Box<Ast<I>>)

ModuleScope(["M", "N"], rhs): marks that rhs is the body of a member of module M.N, so a BARE constructor reference inside it resolves against that module’s constructors first (the type/ctor analog of push_named_binding’s value Scope::rename). Transparent everywhere except Checker::infer/bind_pattern, which push the path and try qualified ctor keys before the bare fallback — no constructor NAME string ever changes (eval, exhaustiveness, and error/warning text stay byte-identical). Wraps a module member’s RHS only, exactly like VersionScope.

§

StageScope(Stage, Box<Ast<I>>)

Marks body as coming from a file that declared a stage other than the default (@stage: 0 / @stage: persistent), so the typechecker reads it at that stage and its & quotes are legal there.

The stage analogue of Ast::VersionScope, and for the same reason: the loader concatenates every library’s prelude into ONE file, so a per-file property has to travel with the bindings it came from or be lost at the merge.

§

Next(Box<Ast<I>>)

&e — quote. Evaluated at stage 0, it does NOT run e: it partially evaluates it into residual code and yields that code as a value (Value::Code), typed code ty. Upstream’s UTNext/Next (parser.mly:796, evaluator.cppo.ml’s interpret_1).

§

Prev(Box<Ast<I>>)

~e — splice. Legal inside a quote (stage 1): e is evaluated NOW, at stage 0, and the code it yields is spliced in where the ~e stood. Upstream’s UTPrev/Prev (parser.mly:797).

Implementations§

Source§

impl<I> Ast<I>

Source

pub fn map_idents<J>(&self, f: &impl Fn(&I) -> J) -> Ast<J>

Rebuild this tree with every lexical identifier mapped through f.

Trait Implementations§

Source§

impl<I: Clone> Clone for Ast<I>

Source§

fn clone(&self) -> Ast<I>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I: Debug> Debug for Ast<I>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: PartialEq> PartialEq for Ast<I>

Source§

fn eq(&self, other: &Ast<I>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<I: PartialEq> StructuralPartialEq for Ast<I>

Auto Trait Implementations§

§

impl<I = String> !Send for Ast<I>

§

impl<I = String> !Sync for Ast<I>

§

impl<I> Freeze for Ast<I>
where I: Freeze, Box<Ast<I>>: Freeze, Rc<Ast<I>>: Freeze, Vec<(I, Rc<Ast<I>>)>: Freeze, Vec<MatchArm<I>>: Freeze, Vec<Ast<I>>: Freeze, Option<Box<Ast<I>>>: Freeze, Vec<(String, Ast<I>)>: Freeze, Rc<Vec<IText<I>>>: Freeze, Rc<Vec<BText<I>>>: Freeze, Rc<Vec<MathElem<I>>>: Freeze, Vec<(String, I)>: Freeze,

§

impl<I> RefUnwindSafe for Ast<I>

§

impl<I> Unpin for Ast<I>
where I: Unpin, Box<Ast<I>>: Unpin, Rc<Ast<I>>: Unpin, Vec<(I, Rc<Ast<I>>)>: Unpin, Vec<MatchArm<I>>: Unpin, Vec<Ast<I>>: Unpin, Option<Box<Ast<I>>>: Unpin, Vec<(String, Ast<I>)>: Unpin, Rc<Vec<IText<I>>>: Unpin, Rc<Vec<BText<I>>>: Unpin, Rc<Vec<MathElem<I>>>: Unpin, Vec<(String, I)>: Unpin,

§

impl<I> UnsafeUnpin for Ast<I>

§

impl<I> UnwindSafe for Ast<I>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Clone for T
where T: Clone,

Source§

fn clone(&self) -> T

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Debug for T
where T: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V