pub enum SigExpr {
Functor {
lp: LParenTok,
param: CtorTok,
colon: ColonTok,
dom: Box<SigExpr>,
rp: RParenTok,
arrow: ArrowTok,
cod: Box<SigExpr>,
},
WithType {
base: SigBotV1,
with_kw: KwWith,
path: Option<ModChainV1>,
type_kw: KwType,
binds: TypeBindsErasedV1,
},
Bot(SigBotV1),
}Expand description
sigexpr (parser_v1.mly:558-573). SELF-LOOP ROOT: Functor.dom/
Functor.cod: Box<SigExpr> (:570-571).
Left-recursion note (load-bearing). The naive sketch would write
With { base: Box<SigExpr>, … } — as a syan2 ordered-choice
production that is LEFT RECURSION (SigExpr would begin by parsing
SigExpr; syan2 gives no diagnostic, it just recurses/fails at parse
time — a known consumer hazard). Upstream is not left-recursive:
the with base is sigexpr_bot (:559,564) and with cannot chain
(the result of a with is never itself a valid with base). So the
faithful encoding is bot + one optional-shaped suffix arm, tried
before the bare-bot fallthrough: S with type t = int with type u = bool is a parse error here exactly as upstream (pinned in tests).
NO arm of this enum may ever begin with Box<SigExpr>/SigExpr as
its first field — reviewer checklist item.
Variants§
Functor
( UPPER : sigexpr ) ARROW sigexpr (:570-571) — the functor
signature. (-headed; no SigBotV1 starts with (, so this
is token-disjoint from the other arms.
Fields
WithType
sigexpr_bot WITH TYPE bind_type (:559-563) /
sigexpr_bot WITH mod_chain TYPE bind_type (:564-569). The
Option<ModChainV1> is greedy-then-backtrack: on with type the
chain fails (type is a keyword token, not UPPER/LONG_UPPER)
and collapses to None. binds goes through
super::TypeBindsErasedV1.
Bot(SigBotV1)
A bare sigexpr_bot (:572-573). Must come after SigExpr::WithType
(maximal munch of the with suffix).
Trait Implementations§
Source§impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for SigExprwhere
__SyanMacro_Atom: Spanned + Clone,
LParenTok: Parse<__SyanMacro_Atom>,
CtorTok: Parse<__SyanMacro_Atom>,
ColonTok: Parse<__SyanMacro_Atom>,
RParenTok: Parse<__SyanMacro_Atom>,
ArrowTok: Parse<__SyanMacro_Atom>,
SigBotV1: Parse<__SyanMacro_Atom>,
KwWith: Parse<__SyanMacro_Atom>,
Option<ModChainV1>: Parse<__SyanMacro_Atom>,
KwType: Parse<__SyanMacro_Atom>,
TypeBindsErasedV1: Parse<__SyanMacro_Atom>,
Self: ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>,
impl<__SyanMacro_Atom> Parse<__SyanMacro_Atom> for SigExprwhere
__SyanMacro_Atom: Spanned + Clone,
LParenTok: Parse<__SyanMacro_Atom>,
CtorTok: Parse<__SyanMacro_Atom>,
ColonTok: Parse<__SyanMacro_Atom>,
RParenTok: Parse<__SyanMacro_Atom>,
ArrowTok: Parse<__SyanMacro_Atom>,
SigBotV1: Parse<__SyanMacro_Atom>,
KwWith: Parse<__SyanMacro_Atom>,
Option<ModChainV1>: Parse<__SyanMacro_Atom>,
KwType: Parse<__SyanMacro_Atom>,
TypeBindsErasedV1: Parse<__SyanMacro_Atom>,
Self: ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>,
Source§type Error = <SigExpr as ParseRanked8909385c15d27adc<(((),),), __SyanMacro_Atom>>::Error
type Error = <SigExpr 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.