Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
    LetRecIn {
        let_kw: KwLet,
        rec_kw: KwRec,
        first: RecClauseV1,
        ands: Vec<AndClauseV1>,
        in_kw: KwIn,
        body: Box<Expr>,
    },
    LetMutableIn {
        let_kw: KwLet,
        mutable_kw: KwMutable,
        name: VarTok,
        arrow: OverwriteEqTok,
        init: Box<Expr>,
        in_kw: KwIn,
        body: Box<Expr>,
    },
    LetIn {
        kw: KwLet,
        name: BindName,
        params: Vec<Param>,
        eq: DefEqTok,
        value: Box<Expr>,
        in_kw: KwIn,
        body: Box<Expr>,
    },
    LetPatternIn {
        kw: KwLet,
        pat: PatNonVarErasedV1,
        eq: DefEqTok,
        value: Box<Expr>,
        in_kw: KwIn,
        body: Box<Expr>,
    },
    OpenIn {
        let_kw: KwLet,
        open_kw: KwOpen,
        name: CtorTok,
        in_kw: KwIn,
        body: Box<Expr>,
    },
    If {
        kw: KwIf,
        cond: Box<Expr>,
        then_kw: KwThen,
        then_branch: Box<Expr>,
        else_kw: KwElse,
        else_branch: Box<Expr>,
    },
    Fun {
        kw: KwFun,
        params: Vec<Param>,
        arrow: ArrowTok,
        body: Box<Expr>,
    },
    Match {
        kw: KwMatch,
        scrutinee: Box<Expr>,
        with_kw: KwWith,
        leading_bar: Option<BarTok>,
        first: MatchArm,
        rest: Vec<BarArm>,
        end_kw: KwEnd,
    },
    Overwrite {
        name: VarTok,
        arrow: OverwriteEqTok,
        value: ExprErasedV1,
    },
    Ops(OpChain),
}
Expand description

nxlet-analogue: a let/if/match/lambda-headed expression, falling through to the flattened operator chain (Expr::Ops, OpChain) at the bottom. Variant order is parse priority (ordered-choice backtracking): every let-headed form is tried before the fallback Expr::Overwrite/Expr::Ops (which may also start with a bare variable), and Ops — having no distinguishing leading keyword — must stay last.

0.1 deltas from crate::cst::ast::Expr: Match gains a mandatory trailing end (parser_v1.mly:792); let-rec becomes let rec … in … (a plain let followed by the new KwRec keyword) with full and-chained mutual recursion (see Expr::LetRecIn); a new LetMutableIn form covers let mutable x <- init in body; a new LetPatternIn form covers let pat = value in body for any non-bare-variable pattern (parser_v1.mly:796, pattern_non_var); open requires a leading let (parser_v1.mly:798, LET OPEN UPPER IN) where 0.0.6 allows a bare open Name in body; and WhileDo, the Guard/when match-arm suffix, and OpChain’s before postfix are dropped entirely — SATySFi 0.1’s grammar has no WHEN/WHILE/BEFORE tokens at all (confirmed by grep of parser_v1.mly). Overwrite (name <- value) is kept unchanged (parser_v1.mly:810-812, REVERSED_ARROW) — it is unrelated to the removed before postfix.

Variants§

§

LetRecIn

let rec clause (and clause)* in body (parser_v1.mly:794-795 dispatching to bind_value_rec, :455-458) — full mutual recursion.

Fields

§let_kw: KwLet
§rec_kw: KwRec
§in_kw: KwIn
§body: Box<Expr>
§

LetMutableIn

let mutable x <- init in body (parser_v1.mly:794-795 dispatching to bind_value’s MUTABLE arm, :446-447). Same shape as crate::cst::ast::Expr::LetMutableIn minus the fused keyword: 0.1 spells it let mutable (two tokens), 0.0.6 let-mutable (one). Disambiguated one token after let by the V0_1-gated mutable keyword, so declared order relative to the other let-headed arms is correctness-irrelevant.

Fields

§let_kw: KwLet
§mutable_kw: KwMutable
§name: VarTok
§init: Box<Expr>
§in_kw: KwIn
§body: Box<Expr>
§

LetIn

let name param* = value in body (only a plain variable target is supported here — a general pattern falls through to Expr::LetPatternIn). name is a super::BindName — upstream’s expression-level let reaches the same bind_value_nonrec (:794-795:459-465) val/val rec do, so let (+++) a b = … in is valid 0.1 here too.

Fields

§params: Vec<Param>
§value: Box<Expr>
§in_kw: KwIn
§body: Box<Expr>
§

LetPatternIn

let pat = value in body (parser_v1.mly:796, pattern_non_var) — any pattern shape EXCEPT a bare variable, which Expr::LetIn already covers. The exclusion is upstream’s (the nonterminal is literally named pattern_non_var) and is carried by the field’s type, super::PatNonVarErasedV1, rather than by variant order: leaving the two alternatives overlapping made a failure inside body cost ×2 per enclosing let.

Fields

§value: Box<Expr>
§in_kw: KwIn
§body: Box<Expr>
§

OpenIn

let open Name in body (parser_v1.mly:798; unlike 0.0.6’s bare open Name in body, 0.1 requires the leading let).

Fields

§let_kw: KwLet
§open_kw: KwOpen
§name: CtorTok
§in_kw: KwIn
§body: Box<Expr>
§

If

if cond then a else b (else is never optional, so there is no dangling-else ambiguity).

Fields

§kw: KwIf
§cond: Box<Expr>
§then_kw: KwThen
§then_branch: Box<Expr>
§else_kw: KwElse
§else_branch: Box<Expr>
§

Fun

fun x y -> body. Each parameter is a full patbot (through Param), not a bare variable: upstream parser_v1.mly:849-863’s fun genuinely binds a patbot per parameter (ELambda(patbot, e) in types.cppo.ml), so fun _ -> … (wildcard) and fun (a, b) -> … (tuple-destructuring) are legal upstream syntax (gaps 2+3 of the V0_1-only language-completeness sweep). Reaching PatBot from here is the same cross-root DAG edge RecClauseV1::params already makes (both Expr and PatBot are roots inside this #[recurse] module — see the module doc comment), so no new SCC edge.

Fields

§params: Vec<Param>
§arrow: ArrowTok
§body: Box<Expr>
§

Match

match scrutinee with [|] pat -> body (| pat -> body)* end (parser_v1.mly:792). Mandatorily closed with end (tokR=END); no when guards (0.1 has no WHEN token).

Fields

§scrutinee: Box<Expr>
§with_kw: KwWith
§leading_bar: Option<BarTok>
§first: MatchArm
§rest: Vec<BarArm>
§end_kw: KwEnd
§

Overwrite

name <- value (expr_overwrite, parser_v1.mly:810-812, REVERSED_ARROW). Starts with a bare VarTok, which is also how Expr::Ops can start — must stay before Ops so backtracking tries the <- shape first.

Fields

§name: VarTok
§

Ops(OpChain)

The flattened binary-operator chain — see crate::cst::ast::Expr’s module doc comment on precedence flattening (unchanged approach here). Must stay last (no leading keyword).

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 Expr

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 Expr
where __SyanMacro_Atom: Spanned + Clone, KwLet: Parse<__SyanMacro_Atom>, KwRec: Parse<__SyanMacro_Atom>, RecClauseV1: Parse<__SyanMacro_Atom>, Vec<AndClauseV1>: Parse<__SyanMacro_Atom>, KwIn: Parse<__SyanMacro_Atom>, KwMutable: Parse<__SyanMacro_Atom>, VarTok: Parse<__SyanMacro_Atom>, OverwriteEqTok: Parse<__SyanMacro_Atom>, BindName: Parse<__SyanMacro_Atom>, Vec<Param>: Parse<__SyanMacro_Atom>, DefEqTok: Parse<__SyanMacro_Atom>, PatNonVarErasedV1: Parse<__SyanMacro_Atom>, KwOpen: Parse<__SyanMacro_Atom>, CtorTok: Parse<__SyanMacro_Atom>, KwIf: Parse<__SyanMacro_Atom>, KwThen: Parse<__SyanMacro_Atom>, KwElse: Parse<__SyanMacro_Atom>, KwFun: Parse<__SyanMacro_Atom>, ArrowTok: Parse<__SyanMacro_Atom>, KwMatch: Parse<__SyanMacro_Atom>, KwWith: Parse<__SyanMacro_Atom>, Option<BarTok>: Parse<__SyanMacro_Atom>, MatchArm: Parse<__SyanMacro_Atom>, Vec<BarArm>: Parse<__SyanMacro_Atom>, KwEnd: Parse<__SyanMacro_Atom>, ExprErasedV1: Parse<__SyanMacro_Atom>, OpChain: Parse<__SyanMacro_Atom>, Self: ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>,

Source§

type Error = <Expr as ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>>::Error

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 Expr

Source§

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

Source§

impl<__SyanMacro_Atom> Unparse<__SyanMacro_Atom> for Expr
where KwLet: Unparse<__SyanMacro_Atom>, KwRec: Unparse<__SyanMacro_Atom>, RecClauseV1: Unparse<__SyanMacro_Atom>, Vec<AndClauseV1>: Unparse<__SyanMacro_Atom>, KwIn: Unparse<__SyanMacro_Atom>, KwMutable: Unparse<__SyanMacro_Atom>, VarTok: Unparse<__SyanMacro_Atom>, OverwriteEqTok: Unparse<__SyanMacro_Atom>, BindName: Unparse<__SyanMacro_Atom>, Vec<Param>: Unparse<__SyanMacro_Atom>, DefEqTok: Unparse<__SyanMacro_Atom>, PatNonVarErasedV1: Unparse<__SyanMacro_Atom>, KwOpen: Unparse<__SyanMacro_Atom>, CtorTok: Unparse<__SyanMacro_Atom>, KwIf: Unparse<__SyanMacro_Atom>, KwThen: Unparse<__SyanMacro_Atom>, KwElse: Unparse<__SyanMacro_Atom>, KwFun: Unparse<__SyanMacro_Atom>, ArrowTok: Unparse<__SyanMacro_Atom>, KwMatch: Unparse<__SyanMacro_Atom>, KwWith: Unparse<__SyanMacro_Atom>, Option<BarTok>: Unparse<__SyanMacro_Atom>, MatchArm: Unparse<__SyanMacro_Atom>, Vec<BarArm>: Unparse<__SyanMacro_Atom>, KwEnd: Unparse<__SyanMacro_Atom>, ExprErasedV1: Unparse<__SyanMacro_Atom>, OpChain: Unparse<__SyanMacro_Atom>, Self: UnparseRanked8909385c15d27adc<(((),),), __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 Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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.