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
stage: Option<BindStageV1>ValueInline
VAL INLINE bind_inline (parser_v1.mly:422-431 dispatch → 448 →
466-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.
cmd: AnyHorzCmdTokValueBlock
VAL BLOCK bind_block (parser_v1.mly:450 → 493-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
stage: Option<BindStageV1>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).
scripts: Option<ScriptsParamV1>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)).
first: RecClauseV1ands: Vec<AndClauseV1>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).
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<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for Bindwhere
__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>,
impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for Bindwhere
__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>
type Error = ParseError<<__SyanMacro_Atom as Spanned>::Span>
<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.