pub struct Node {
pub kind: NodeKind,
pub span: Span,
pub leading: Vec<Trivia>,
pub trailing: Vec<Trivia>,
pub after: Vec<Trivia>,
}Expand description
A parsed Lisp node with span + attached trivia.
Fields§
§kind: NodeKind§span: Span§leading: Vec<Trivia>Comments / blank lines immediately before this node.
trailing: Vec<Trivia>For a compound node: trivia sitting between its last child and its
closing delimiter, with no child to attach to. Emitted INSIDE the
form, before the ).
Note this slot is overloaded relative to its original meaning
(“trailing on the same line”); sequence() claimed it for the
dangling case. That is why Self::after exists rather than this
being reused again.
after: Vec<Trivia>Trivia that follows this node at its own level — OUTSIDE any delimiter it owns.
The distinction from Self::trailing is load-bearing, not
pedantry: (define x 1) ; why and (define x 1 ; why\n) are
different documents, and a single slot cannot represent both. With
only the two original slots the top-level case had nowhere to go
and was DISCARDED at EOF — measurably: one mass-format destroyed 44
trailing comments in pleme-io/actions alone.
Implementations§
Source§impl Node
impl Node
pub fn new(kind: NodeKind, span: Span) -> Self
Sourcepub fn to_tatara_sexp(&self) -> Sexp
pub fn to_tatara_sexp(&self) -> Sexp
Drop all spans + trivia, lowering into the plain tatara_lisp::Sexp
used by the compile pipeline.
Sourcepub fn head_symbol(&self) -> Option<&str>
pub fn head_symbol(&self) -> Option<&str>
Head symbol for a list node like (defX ...). Returns None unless this
is a List whose first element is a Symbol.