Skip to main content

Module leaf

Module leaf 

Source
Expand description

Leaf token types and the delimiter Group aliases.

The unit and single-field leaves (KwLet, VarTok, IntTok, …) are generated by token_leaves! in crate::token and re-exported here (so use crate::leaf::* still names them). This module keeps only what that macro cannot express — the multi-field qualified-name leaves, LengthTok/LiteralTok, the multi-variant BinOpTok, and the AnyHorzCmdTok/AnyVertCmdTok alternations — plus the delimiter Group aliases, which are the core atom-generic syan::nested::group::Group.

Re-exports§

pub use crate::token::*;

Structs§

BinOpTok
A binary-operator token: the binop family of nxlor..nxrtimes plus the mod/:: operators that also act as binops (parser.mly’s binop nonterminal, minus UNOP_EXCLAM/BEFORE/LNOT, which are not simple infix operators in this grammar’s flattened operator-chain shape). Deliberately excludes Token::Bar (match-arm separator) and Token::ExactAmp (the &-prefixed “next” unary operator) — see cst.rs’s note on Bar handling.
ExactTimesTok
A standalone * (EXACT_TIMES in parser.mly) in type-expression position — the product-type separator (type point = length * length, cst.rs’s TypeProd). Hand-written (not #[leaf(...)]-generated on Token::ExactTimes in token.rs) because Token::ExactTimes already doubles as one of BinOpTok’s matched variants for the expression-level *; this leaf lets TypeProd consume the same token without pulling in the rest of the binop set, mirroring LengthTok’s boilerplate.
HeaderStageTok
@stage: persistent / @stage: 0 / @stage: 1 header token (cst.rs’s Header::Stage). Hand-written like BinOpTok above: the three spellings are separate unit Token variants with no shared payload for a #[leaf(...)] derive to key off, so this matches any of them and keeps whichever one matched (needed for a lossless round-trip — Unparse replays exactly the token that was read).
HorzCmdWithModTok
A module-qualified inline command, e.g. \Mod.cmd.
LengthTok
A length constant such as 12pt (two payload fields, hand-written).
LiteralTok
A backtick string literal with its space-trimming flags.
LongUpperTok
A dotted module path ending in an UPPER segment, e.g. A.B.C (upstream LONG_UPPER) — module-expression paths, functor application operands, and signature paths (mod_chain, sigexpr_bot). V0_1-only (a lex error under V0_0).
MathCmdWithModTok
A module-qualified math command, e.g. \Mod.cmd in math mode.
NamingOpTok
The operator token accepted inside a ( ‹op› ) NAMING form (see OpNameTok) — BinOpTok’s whole alternative set, PLUS !/before. Upstream parser.mly’s binop nonterminal is used in exactly two productions, both naming forms (VAL LPAREN binop RPAREN and LPAREN binop RPAREN as a bare atomic-expression reference) — never for infix chaining — and it accepts UNOP_EXCLAM/BEFORE/ LNOT there, unlike this grammar’s flattened infix operator chain (cst.rs’s OpRhs, which uses BinOpTok directly and correctly excludes them: !/before are not simple infix operators here). LNOT (not) has no reserved keyword token in this port at all (see the not note beside crate::token::Token::Mod): it lexes as an ordinary VarTok, so let not x = ../val not : ty (unparenthesized) already parse via the plain-name arm of cst.rs’s BindName/ast::Atomic:: OpRef’s sibling Var arm, with no token to add here. Kept as its own struct (mirroring BinOpTok’s shape) rather than widening BinOpTok itself, so the infix-chain grammar’s exclusion stays intact by construction — nothing downstream of BinOpTok::parse can ever see !/before.
OpNameTok
( ‹op› ) — a parenthesized (possibly user-defined) operator name. Two surface uses share this leaf: a binding-position NAME (cst.rs’s BindName, e.g. let (+++>) = .. / val (-->) : ty — the gap blocking itemize.satyh/progsynt.satyh) and a bare atomic-expression reference to an operator as a first-class value (cst.rs’s ast::Atomic::OpRef, e.g. (+++)). .name is the operator’s text (NamingOpTok::op_text); .span covers the whole ( .. ), delimiters included. Both are precomputed here (rather than left to the Spanned trait) so a downstream crate with no direct syan dependency (rustyfi-lang) can read them as plain fields, exactly like every other leaf’s .name/ .span. Hand-written (not #[leaf(...)]-generated) for the same reason as BinOpTok: it spans three atoms, not one. The inner operator is a NamingOpTok (not a bare BinOpTok) so (!)/(before) — valid only in this naming position, per upstream’s binop nonterminal — also parse; see NamingOpTok’s doc comment.
UnitParen
Unparse for an EMPTY group used as an ordinary field rather than as the target of a #[group(self.x)]PatBot::Unit { paren: ParenGroup<()> } and its three siblings, which spell () with nothing inside.
VarInHorzTok
#var (or #Mod.var) in inline text, before the mode switches to active.
VarInMathTok
#var (or #Mod.var) in math mode.
VarInVertTok
#var (or #Mod.var) in block text, before the mode switches to active.
VarWithModTok
A module-qualified variable, e.g. Mod.x.
VertCmdWithModTok
A module-qualified block command, e.g. +Mod.cmd.

Enums§

AnyHorzCmdTok
Either sigil-only (\cmd) or module-qualified (\Mod.cmd) inline command name — hcmd in parser.mly. Not itself recursive, so (unlike crate::cst::ast::InlineElem) it can be a plain top-level derive.
AnyMathCmdTok
Either sigil-only (\cmd) or module-qualified (\Mod.cmd) math command name in math mode — the math analogue of AnyHorzCmdTok.
AnyVertCmdTok
Either sigil-only (+cmd) or module-qualified (+Mod.cmd) block command name — vcmd in parser.mly.

Type Aliases§

BlockGroup
'< … > / < … > block text.
InlineGroup
{ … } inline text.
ListGroup
[ … ] list.
MathGroup
${ … } / { … } math (the latter when already inside math mode).
OpenModuleGroup
Mod.( … ) — the open-module-scope expression (cst.rs’s Atomic::OpenModule). The open delimiter (OpenModuleTok, carrying the module name) is Mod.(; the close is a plain ) (RParenTok, exactly like ParenGroup’s).
ParenGroup
( … ) in program mode.
RecordGroup
(| … |) record.