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: PatErasedV1,
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.
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
arrow: OverwriteEqTokLetIn
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
LetPatternIn
let pat = value in body (parser_v1.mly:796,
pattern_non_var) — any pattern shape, tried only after the
bare-variable form Expr::LetIn fails to match.
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).
If
if cond then a else b (else is never optional, so there is
no dangling-else ambiguity).
Fields
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.
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
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.
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<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for Exprwhere
__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>,
PatErasedV1: 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>,
impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for Exprwhere
__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>,
PatErasedV1: 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
type Error = <Expr as ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>>::Error
<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.