Skip to main content

Bind

Enum Bind 

Source
pub enum Bind {
    Value {
        kw: KwVal,
        stage: Option<BindStageV1>,
        name: BindName,
        params: Vec<Param>,
        eq: DefEqTok,
        body: Expr,
    },
    ValueInline {
        kw: KwVal,
        stage: Option<BindStageV1>,
        inline_kw: KwInline,
        ctx: Option<VarTok>,
        cmd: AnyHorzCmdTok,
        params: Vec<Param>,
        eq: DefEqTok,
        body: Expr,
    },
    ValueBlock {
        kw: KwVal,
        stage: Option<BindStageV1>,
        block_kw: KwBlock,
        ctx: Option<VarTok>,
        cmd: AnyVertCmdTok,
        params: Vec<Param>,
        eq: DefEqTok,
        body: Expr,
    },
    ValueMath {
        kw: KwVal,
        stage: Option<BindStageV1>,
        math_kw: KwMath,
        ctx: VarTok,
        cmd: AnyHorzCmdTok,
        params: Vec<Param>,
        scripts: Option<ScriptsParamV1>,
        eq: DefEqTok,
        body: Expr,
    },
    ValueRec {
        kw: KwVal,
        stage: Option<BindStageV1>,
        rec_kw: KwRec,
        first: RecClauseV1,
        ands: Vec<AndClauseV1>,
    },
    ValueMutable {
        kw: KwVal,
        stage: Option<BindStageV1>,
        mutable_kw: KwMutable,
        name: VarTok,
        arrow: OverwriteEqTok,
        value: Expr,
    },
    Type {
        kw: KwType,
        first: TypeBindSingleV1,
        ands: Vec<TypeAndV1>,
    },
    Module {
        module_kw: KwModule,
        name: CtorTok,
        sig_annot: Option<SigAnnotV1>,
        eq: DefEqTok,
        body: ModExprErasedV1,
    },
    Signature {
        kw: KwSignature,
        name: CtorTok,
        eq: DefEqTok,
        sig_: SigExprErasedV1,
    },
    Include {
        kw: KwInclude,
        body: ModExprErasedV1,
    },
}
Expand description

Every arm of bind (parser_v1.mly:415-440) — upstream’s own nonterminal name (helper types like StructBindV1/ TypeBindSingleV1 keep a V1 suffix). Every value arm’s = is EXACT_EQ (DefEqTok) and body is an ast::Expr. name is a crate::cst::BindName wherever upstream’s bound_identifier reaches it (Value, and the rec clauses inside ast::RecClauseV1); ValueMutable and ValueInline/ValueBlock’s ctx stay plain VarToks — upstream’s MUTABLE LOWER …/ctx-variable productions are a plain LOWER, not bound_identifier (see crate::cst::BindName’s doc comment for the ordered-choice-safety argument).

Variants§

§

Value

VAL PERSISTENT? EXACT_TILDE? bind_value_nonrec (parser_v1.mly:416-421,442,459-465): val <stage>? <name> <param>* = <expr>, where <stage> is ~ (stage 0) or persistent ~ (the persistent stage) and its absence means stage 1, the document stage.

The prefix is an Option<BindStageV1> tried before name; on an unstaged val x = … it fails at the first token, collapses to None and steals nothing, so every existing fixture parses unchanged. It also keeps this arm ordered-choice-safe against the keyword-headed Value* arms below: val ~rec … still fails here (at name, which cannot match the rec keyword) and falls through, exactly as val rec … does.

Fields

§params: Vec<Param>
§body: Expr
§

ValueInline

VAL INLINE bind_inline (parser_v1.mly:422-431 dispatch → 448466-491): val inline <ctx> \cmd <param>* = <expr> (the heavyweight, ctx-explicit form — the only one stdja-mini uses; ctx stays Option so the lightweight, ctx-synthesized form parses too, for free).

Fields

§stage: Option<BindStageV1>

See Bind::Value::stage — upstream’s qualifier sits before the whole bind_value, and bind_value is what inline/block/ math/rec/mutable select between (parser_v1.mly:417-421:581-593), so every arm below carries the same prefix.

§inline_kw: KwInline
§params: Vec<Param>
§body: Expr
§

ValueBlock

VAL BLOCK bind_block (parser_v1.mly:450493-518): val block <ctx> +cmd <param>* = <expr>.

§

ValueMath

VAL MATH bind_math (parser_v1.mly:452-453 dispatch → 520-531): val math <ctx> \cmd <param>* [with <sub> <sup>] = <expr>. Unlike ValueInline/ValueBlock, ctx is MANDATORY — upstream has no lightweight ctx-less form (contrast bind_inline’s two productions, :466-491). Placed after ValueBlock, ordered-choice-safe for the same reason as Value above: math/with both lex as keyword tokens under V0_1, so no arm can steal another’s input.

Fields

§math_kw: KwMath
§cmd: AnyHorzCmdTok

\cmd — math commands share the \ sigil with inline commands (there is no separate math-command token; see elaborate.rs’s command_scheme doc comment, which notes the same sharing on the eval side).

§params: Vec<Param>
§body: Expr
§

ValueRec

VAL REC bind_value_nonrec (AND bind_value_nonrec)* (parser_v1.mly:444-445,455-465): val rec f p* = e (and g p* = e)*. With rec/mutable/inline/block all lexed as keyword tokens under V0_1, no arm can steal another’s input — Value.name: BindName cannot match a keyword token — so declared order is a documentation/perf choice; Value stays first because it is the overwhelmingly common arm.

Fields

§stage: Option<BindStageV1>

See Bind::ValueInline::stage. One qualifier covers the whole and-chain, matching upstream’s single UTBindValue(stage, UTRec(binds)).

§rec_kw: KwRec
§

ValueMutable

VAL MUTABLE LOWER REVERSED_ARROW expr (parser_v1.mly:446-447): val mutable x <- e. The name is a plain LOWER upstream (not bound_identifier), hence VarTok, matching the cst target (cst::TopBinding::LetMutable.name, cst.rs:237).

§

Type

TYPE bind_type_single (AND bind_type_single)* (parser_v1.mly:432-433,535-544): type t 'a* = body (and u 'a* = body)* — variant and synonym forms, mutually recursive across the and chain.

§

Module

MODULE UPPER option(sig_annot) EXACT_EQ modexpr — upstream bind’s MODULE arm (parser_v1.mly:434-435), with the FULL modexpr body and the optional :> annotation. The body goes through ModExprErasedV1: Bind is outside the #[recurse] module, and Bind → ModExpr → StructBindV1 → Bind is the runtime cycle both connectors erase (one break per direction).

Fields

§module_kw: KwModule
§name: CtorTok
§sig_annot: Option<SigAnnotV1>
§

Signature

SIGNATURE UPPER EXACT_EQ sigexpr (parser_v1.mly:436-437).

§

Include

INCLUDE modexpr (:438-439) — a bind-include includes a MODULE (contrast ast::Decl::Include, which includes a signature).

Trait Implementations§

Source§

impl Clone for Bind

Source§

fn clone(&self) -> Bind

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 Debug for Bind

Source§

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

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

impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for Bind
where __SyanMacro_Atom: Spanned + Clone, KwVal: Parse<__SyanMacro_Atom>, Option<BindStageV1>: Parse<__SyanMacro_Atom>, BindName: Parse<__SyanMacro_Atom>, Vec<Param>: Parse<__SyanMacro_Atom>, DefEqTok: Parse<__SyanMacro_Atom>, Expr: Parse<__SyanMacro_Atom>, KwInline: Parse<__SyanMacro_Atom>, Option<VarTok>: Parse<__SyanMacro_Atom>, AnyHorzCmdTok: Parse<__SyanMacro_Atom>, KwBlock: Parse<__SyanMacro_Atom>, AnyVertCmdTok: Parse<__SyanMacro_Atom>, KwMath: Parse<__SyanMacro_Atom>, VarTok: Parse<__SyanMacro_Atom>, Option<ScriptsParamV1>: Parse<__SyanMacro_Atom>, KwRec: Parse<__SyanMacro_Atom>, RecClauseV1: Parse<__SyanMacro_Atom>, Vec<AndClauseV1>: Parse<__SyanMacro_Atom>, KwMutable: Parse<__SyanMacro_Atom>, OverwriteEqTok: Parse<__SyanMacro_Atom>, KwType: Parse<__SyanMacro_Atom>, TypeBindSingleV1: Parse<__SyanMacro_Atom>, Vec<TypeAndV1>: Parse<__SyanMacro_Atom>, KwModule: Parse<__SyanMacro_Atom>, CtorTok: Parse<__SyanMacro_Atom>, Option<SigAnnotV1>: Parse<__SyanMacro_Atom>, ModExprErasedV1: Parse<__SyanMacro_Atom>, KwSignature: Parse<__SyanMacro_Atom>, SigExprErasedV1: Parse<__SyanMacro_Atom>, KwInclude: Parse<__SyanMacro_Atom>,

Source§

type Error = ParseError<<__SyanMacro_Atom as Spanned>::Span>

Every error must be convertible to the universal one, so a field’s failure can become the enclosing type’s failure with no per-field where-predicate. Stating it HERE rather than at each derived impl is what keeps it out of the obligation graph: a per-field <FieldTy as Parse<Atom>>::Error: Into<…> predicate re-creates a projection cycle on a recursive field (E0275), which decycle’s bound-peeling does not break.
Source§

fn parse_stream<__SyanMacro_S: ParseStream<Atom = __SyanMacro_Atom>>( __syan_stream: &mut __SyanMacro_S, ) -> Result<Self, Self::Error>

Parse from a reborrowable stream. Read more
Source§

fn parse(stream: impl IntoParseStream<Atom = Atom>) -> Result<Self, Self::Error>

Parse from anything that can become a stream — String, TokenStream, an existing stream. Read more
Source§

fn attempt(self) -> Attempt<Self>

Wrap this value in Attempt, the atomic-parse marker: parsing an Attempt<Self> parses Self but rewinds the stream on failure (it requires Atom: Clone). This is the value constructor; value.attempt() is sugar for Attempt(value).
Source§

impl PartialEq for Bind

Source§

fn eq(&self, other: &Bind) -> bool

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Bind

Source§

impl<__SyanMacro_Atom> Unparse<__SyanMacro_Atom> for Bind
where KwVal: Unparse<__SyanMacro_Atom>, Option<BindStageV1>: Unparse<__SyanMacro_Atom>, BindName: Unparse<__SyanMacro_Atom>, Vec<Param>: Unparse<__SyanMacro_Atom>, DefEqTok: Unparse<__SyanMacro_Atom>, Expr: Unparse<__SyanMacro_Atom>, KwInline: Unparse<__SyanMacro_Atom>, Option<VarTok>: Unparse<__SyanMacro_Atom>, AnyHorzCmdTok: Unparse<__SyanMacro_Atom>, KwBlock: Unparse<__SyanMacro_Atom>, AnyVertCmdTok: Unparse<__SyanMacro_Atom>, KwMath: Unparse<__SyanMacro_Atom>, VarTok: Unparse<__SyanMacro_Atom>, Option<ScriptsParamV1>: Unparse<__SyanMacro_Atom>, KwRec: Unparse<__SyanMacro_Atom>, RecClauseV1: Unparse<__SyanMacro_Atom>, Vec<AndClauseV1>: Unparse<__SyanMacro_Atom>, KwMutable: Unparse<__SyanMacro_Atom>, OverwriteEqTok: Unparse<__SyanMacro_Atom>, KwType: Unparse<__SyanMacro_Atom>, TypeBindSingleV1: Unparse<__SyanMacro_Atom>, Vec<TypeAndV1>: Unparse<__SyanMacro_Atom>, KwModule: Unparse<__SyanMacro_Atom>, CtorTok: Unparse<__SyanMacro_Atom>, Option<SigAnnotV1>: Unparse<__SyanMacro_Atom>, ModExprErasedV1: Unparse<__SyanMacro_Atom>, KwSignature: Unparse<__SyanMacro_Atom>, SigExprErasedV1: Unparse<__SyanMacro_Atom>, KwInclude: Unparse<__SyanMacro_Atom>,

Source§

fn unparse<__Syan_Emitter: Emitter<__SyanMacro_Atom>>( &self, __syan_sink: &mut __Syan_Emitter, ) -> Result<(), <__Syan_Emitter as Emitter<__SyanMacro_Atom>>::Error>

Auto Trait Implementations§

§

impl Freeze for Bind

§

impl RefUnwindSafe for Bind

§

impl Send for Bind

§

impl Sync for Bind

§

impl Unpin for Bind

§

impl UnsafeUnpin for Bind

§

impl UnwindSafe for Bind

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<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> 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.