Skip to main content

Node

Enum Node 

Source
pub enum Node {
    Root {
        children: Vec<NodeId>,
        mode: ContentMode,
    },
    Group {
        children: Vec<NodeId>,
        kind: GroupKind,
        mode: ContentMode,
    },
    Command {
        name: String,
        args: Vec<ArgumentSlot>,
        known: bool,
    },
    Infix {
        name: String,
        args: Vec<ArgumentSlot>,
        left: NodeId,
        right: NodeId,
    },
    Declarative {
        name: String,
        args: Vec<ArgumentSlot>,
    },
    Environment {
        name: String,
        args: Vec<ArgumentSlot>,
        known: bool,
        body: NodeId,
    },
    Scripted {
        base: NodeId,
        subscript: Option<NodeId>,
        superscript: Option<NodeId>,
    },
    Prime {
        count: usize,
    },
    Text(String),
    Char(char),
    ActiveSpace,
    Error {
        message: String,
        snippet: String,
    },
}
Expand description

Mutable AST node stored inside Ast.

Variants§

§

Root

Main document root containing top-level children and parse mode.

Fields

§children: Vec<NodeId>

Ordered direct children of the root

§mode: ContentMode

Content mode used to parse the formula

§

Group

Group node containing ordered children and mode metadata.

Fields

§children: Vec<NodeId>

Ordered direct children of the group

§kind: GroupKind

Source-level grouping form

§mode: ContentMode

Content mode used to parse the group

§

Command

Prefix command with argument slots.

Fields

§name: String

Command name without leading backslash

§args: Vec<ArgumentSlot>

Slots defined by the matched command spec

§known: bool

Whether this name is present in the knowledge base.

§

Infix

Infix command with explicit left and right operands.

Fields

§name: String

Command name without leading backslash

§args: Vec<ArgumentSlot>

Additional argument slots owned by the infix node

§left: NodeId

Left operand subtree

§right: NodeId

Right operand subtree

§

Declarative

Declarative command with explicit argument slots.

Fields

§name: String

Command name without leading backslash

§args: Vec<ArgumentSlot>

Additional argument slots owned by the declarative node

§

Environment

Environment node whose body must always be a group.

Fields

§name: String

Environment name without begin / end

§args: Vec<ArgumentSlot>

Parsed argument slots attached to the environment

§known: bool

Whether this name is present in the knowledge base.

§body: NodeId

Environment body subtree. Must be a Node::Group

§

Scripted

Scripted expression such as x_i^2.

Fields

§base: NodeId

Base expression

§subscript: Option<NodeId>

Optional subscript subtree

§superscript: Option<NodeId>

Optional superscript subtree

§

Prime

Math prime shorthand represented by one or more consecutive prime marks.

Fields

§count: usize

Number of consecutive prime marks. Must be greater than zero.

§

Text(String)

Text-mode text chunk

§

Char(char)

Single character node

§

ActiveSpace

Active ~ space node

§

Error

Parser-produced error placeholder, mirroring SyntaxNode::Error.

Error is a first-class structural leaf: a tree containing Error nodes is still structurally valid. Semantic completeness (the absence of Error nodes) is a separate property, not a structural invariant. Error carries the original recovery message and the source snippet so serialization can round-trip it losslessly.

Fields

§message: String

Human-readable recovery message captured by the parser.

§snippet: String

Verbatim source slice the parser failed to interpret.

Implementations§

Source§

impl Node

Source

pub const fn kind(&self) -> NodeKind

Return the lightweight discriminant for this node.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Node

Source§

impl PartialEq for Node

Source§

fn eq(&self, other: &Node) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.