Skip to main content

TopBinding

Enum TopBinding 

Source
pub enum TopBinding {
    LetRec {
        kw: KwLetRec,
        stage: Option<TopStage>,
        first: RecBinding,
        ands: Vec<AndBinding>,
    },
    Let(TopLet),
    LetPattern {
        let_kw: KwLet,
        pat: PatNonVarErased,
        eq: DefEqTok,
        value: Expr,
    },
    LetInline {
        kw: KwLetHorz,
        stage: Option<TopStage>,
        ctx: Option<VarTok>,
        cmd: HorzCmdTok,
        params: Vec<Param>,
        eq: DefEqTok,
        value: Expr,
    },
    LetBlock {
        kw: KwLetVert,
        stage: Option<TopStage>,
        ctx: Option<VarTok>,
        cmd: VertCmdTok,
        params: Vec<Param>,
        eq: DefEqTok,
        value: Expr,
    },
    LetMath {
        kw: KwLetMath,
        stage: Option<TopStage>,
        cmd: HorzCmdTok,
        params: Vec<Param>,
        eq: DefEqTok,
        value: Expr,
    },
    Type(TypeDecl),
    LetMutable {
        kw: KwLetMutable,
        stage: Option<TopStage>,
        name: VarTok,
        arrow: OverwriteEqTok,
        value: Expr,
    },
    Module {
        kw: KwModule,
        name: CtorTok,
        sig: Option<SigAnnot>,
        eq: DefEqTok,
        struct_kw: KwStruct,
        decls: Vec<StructDecl>,
        end_kw: KwEnd,
    },
    Open {
        kw: KwOpen,
        name: CtorTok,
    },
}
Expand description

One top-level declaration (nxtoplevel/nxstruct’s per-declaration alternatives). LetInline/LetBlock only exist here — see the module doc comment.

Variants§

§

LetRec

let-rec name param* = expr (and name param* = expr)*

Fields

§stage: Option<TopStage>

See TopLet::stage — upstream 0.1 puts the qualifier before the WHOLE bind_value, and bind_value covers rec/mutable/ inline/block/math as well as the plain non-recursive form (dev-0-1-0 parser.mly:417-421:581-593), so every binding shape below carries one too. The stage applies to each and clause of this one let-rec, exactly as it does upstream (one UTBindValue(stage, UTRec(binds)) for the whole chain).

§

Let(TopLet)

let name param* = expr

§

LetPattern

let pat = expr — a top-level (or struct-level) DESTRUCTURING let whose target is a general pattern, not a plain variable (e.g. satysfi-xpath’s let (ulim1, ulim2) = (0. -. eps, 1. +. eps)). The struct-body twin of ast::Expr::LetPatternIn, and — for the same reason it sits after Expr::LetInmust stay after Let: an ordinary let x = e parses through Let first (its name: BindName only accepts a bare var/op), leaving this to match only a non-variable pattern target. That “leaving” is enforced by the target’s own type (PatNonVarErased) rather than left to variant order, so the two alternatives are disjoint and neither re-parses the other’s value. No argpart (curried params after the pattern), as upstream’s nxnonrecdec never uses one here.

Fields

§let_kw: KwLet
§value: Expr
§

LetInline

[ctxvar] let-inline \cmd param* = expr (nxhorzdec; each param is upstream’s arg — a full patbot, or a ?:-marked variable, see ast::Param’s doc comment — parser.mly:622-624).

§

LetBlock

[ctxvar] let-block +cmd param* = expr (nxvertdec).

§

LetMath

let-math \cmd param* = expr (nxmathdec, parser.mly:586-591). No leading context variable — unlike LetInline/LetBlock, upstream’s nxmathdec curries straight from the command name into cmdarglst* with no ctxvar slot at all (UTLambdaMath, not UTLambdaHorz/UTLambdaVert), since a math command’s own type (math-cmd) carries no implicit context argument the way inline-cmd/block-cmd do. cmd reuses the plain HorzCmdTok token (upstream’s nxmathdec also reuses HORZCMD, not a math-specific token — \frac here is lexed exactly like \frac in let-inline; the two forms are told apart only by which keyword introduced them).

§

Type(TypeDecl)

type name = [|] Ctor [of ty] (| Ctor [of ty])* (a variant declaration) or type name = ty (a transparent type synonym) — nxvariantdec; see TypeDeclBody for how the two are told apart.

§

LetMutable

let-mutable name <- expr (top-level; nxtoplevel/nxstruct’s LETMUTABLE case — the local, in-bodied form is ast::Expr::LetMutableIn).

§

Module

module Name [: sig ... end] = struct ... end (nxtoplevel’s MODULE case).

Fields

§name: CtorTok
§struct_kw: KwStruct
§end_kw: KwEnd
§

Open

open Name (nxtoplevel’s OPEN case; the local, in-bodied form is ast::Expr::OpenIn).

Fields

§name: CtorTok

Trait Implementations§

Source§

impl Clone for TopBinding

Source§

fn clone(&self) -> TopBinding

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 TopBinding

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 TopBinding
where __SyanMacro_Atom: Spanned + Clone, KwLetRec: Parse<__SyanMacro_Atom>, Option<TopStage>: Parse<__SyanMacro_Atom>, RecBinding: Parse<__SyanMacro_Atom>, Vec<AndBinding>: Parse<__SyanMacro_Atom>, TopLet: Parse<__SyanMacro_Atom>, KwLet: Parse<__SyanMacro_Atom>, PatNonVarErased: Parse<__SyanMacro_Atom>, DefEqTok: Parse<__SyanMacro_Atom>, Expr: Parse<__SyanMacro_Atom>, KwLetHorz: Parse<__SyanMacro_Atom>, Option<VarTok>: Parse<__SyanMacro_Atom>, HorzCmdTok: Parse<__SyanMacro_Atom>, Vec<Param>: Parse<__SyanMacro_Atom>, KwLetVert: Parse<__SyanMacro_Atom>, VertCmdTok: Parse<__SyanMacro_Atom>, KwLetMath: Parse<__SyanMacro_Atom>, TypeDecl: Parse<__SyanMacro_Atom>, KwLetMutable: Parse<__SyanMacro_Atom>, VarTok: Parse<__SyanMacro_Atom>, OverwriteEqTok: Parse<__SyanMacro_Atom>, KwModule: Parse<__SyanMacro_Atom>, CtorTok: Parse<__SyanMacro_Atom>, Option<SigAnnot>: Parse<__SyanMacro_Atom>, KwStruct: Parse<__SyanMacro_Atom>, Vec<StructDecl>: Parse<__SyanMacro_Atom>, KwEnd: Parse<__SyanMacro_Atom>, KwOpen: 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 TopBinding

Source§

fn eq(&self, other: &TopBinding) -> 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 TopBinding

Source§

impl<__SyanMacro_Atom> Unparse<__SyanMacro_Atom> for TopBinding
where KwLetRec: Unparse<__SyanMacro_Atom>, Option<TopStage>: Unparse<__SyanMacro_Atom>, RecBinding: Unparse<__SyanMacro_Atom>, Vec<AndBinding>: Unparse<__SyanMacro_Atom>, TopLet: Unparse<__SyanMacro_Atom>, KwLet: Unparse<__SyanMacro_Atom>, PatNonVarErased: Unparse<__SyanMacro_Atom>, DefEqTok: Unparse<__SyanMacro_Atom>, Expr: Unparse<__SyanMacro_Atom>, KwLetHorz: Unparse<__SyanMacro_Atom>, Option<VarTok>: Unparse<__SyanMacro_Atom>, HorzCmdTok: Unparse<__SyanMacro_Atom>, Vec<Param>: Unparse<__SyanMacro_Atom>, KwLetVert: Unparse<__SyanMacro_Atom>, VertCmdTok: Unparse<__SyanMacro_Atom>, KwLetMath: Unparse<__SyanMacro_Atom>, TypeDecl: Unparse<__SyanMacro_Atom>, KwLetMutable: Unparse<__SyanMacro_Atom>, VarTok: Unparse<__SyanMacro_Atom>, OverwriteEqTok: Unparse<__SyanMacro_Atom>, KwModule: Unparse<__SyanMacro_Atom>, CtorTok: Unparse<__SyanMacro_Atom>, Option<SigAnnot>: Unparse<__SyanMacro_Atom>, KwStruct: Unparse<__SyanMacro_Atom>, Vec<StructDecl>: Unparse<__SyanMacro_Atom>, KwEnd: Unparse<__SyanMacro_Atom>, KwOpen: 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§

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.