pub struct Node {
pub head: Head,
pub args: Vec<Node>,
pub applied: bool,
pub meta: Meta,
}Fields§
§head: Head§args: Vec<Node>§applied: boolWhether this node was written as an application.
§2.2’s model has args: list[Node], which leaves (params) and params indistinguishable
— and an empty parameter list is not the same thing as a reference to a variable called
params. Elixir solves this by giving a variable nil args where a call has a list; this
is the same distinction with a cheaper representation.
meta: MetaImplementations§
Source§impl Node
impl Node
pub fn sym(name: impl AsRef<str>, span: Span) -> Node
pub fn symbol(sym: Symbol, span: Span) -> Node
pub fn lit(lit: Lit, span: Span) -> Node
pub fn form(head: impl AsRef<str>, args: Vec<Node>, span: Span) -> Node
pub fn form_sym(head: Symbol, args: Vec<Node>, span: Span) -> Node
pub fn span(&self) -> Span
pub fn head_sym(&self) -> Option<&Symbol>
pub fn head_name(&self) -> Option<&str>
pub fn as_lit(&self) -> Option<&Lit>
pub fn as_str_lit(&self) -> Option<&str>
pub fn as_keyword(&self) -> Option<&str>
Sourcepub fn is_form(&self, head: &str) -> bool
pub fn is_form(&self, head: &str) -> bool
An application with this exact head name — (params) counts, a bare params does not.
pub fn arg(&self, i: usize) -> Option<&Node>
Sourcepub fn structurally_eq(&self, other: &Node) -> bool
pub fn structurally_eq(&self, other: &Node) -> bool
Structural equality ignoring spans and expansion chains — what tests and the round-trip
property compare, since formatting is explicitly not part of a Node’s identity.
Sourcepub fn map_symbols(&self, f: &mut impl FnMut(&Symbol) -> Symbol) -> Node
pub fn map_symbols(&self, f: &mut impl FnMut(&Symbol) -> Symbol) -> Node
Rewrite every symbol in the tree. The expander’s workhorse.
Sourcepub fn flip_scope(&self, s: Scope) -> Node
pub fn flip_scope(&self, s: Scope) -> Node
Flip a scope on every symbol in the tree (see ScopeSet::flip).
Sourcepub fn with_expansion(&self, name: Arc<str>, at: Span) -> Node
pub fn with_expansion(&self, name: Arc<str>, at: Span) -> Node
Record that this subtree came out of a macro, for §4.5’s expansion chain in diagnostics.
pub fn node_count(&self) -> usize
Trait Implementations§
Source§impl PartialEq for Node
Structural equality, ignoring spans and expansion chains.
impl PartialEq for Node
Structural equality, ignoring spans and expansion chains.
Salsa needs Eq to decide whether a re-executed query actually produced a different value, and
formatting is explicitly not part of a Node’s identity (§2.2) — so equality is exactly
Node::structurally_eq, and a re-parse that moved a span does not invalidate anything
downstream.