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).
first: RecBindingands: Vec<AndBinding>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::LetIn — must 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.
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
decls: Vec<StructDecl>Open
open Name (nxtoplevel’s OPEN case; the local, in-bodied form
is ast::Expr::OpenIn).
Trait Implementations§
Source§impl Clone for TopBinding
impl Clone for TopBinding
Source§fn clone(&self) -> TopBinding
fn clone(&self) -> TopBinding
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TopBinding
impl Debug for TopBinding
Source§impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for TopBindingwhere
__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>,
impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for TopBindingwhere
__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>
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.