Skip to main content

ConcreteSyntaxTree

Struct ConcreteSyntaxTree 

Source
pub struct ConcreteSyntaxTree<T, Nt> { /* private fields */ }
Expand description

A generic concrete syntax tree with stable child ordering

Implementations§

Source§

impl<T, Nt> ConcreteSyntaxTree<T, Nt>
where T: Clone, Nt: Clone,

Source

pub fn new(root_data: CstNodeData<T, Nt>) -> Self

Source

pub fn root(&self) -> CstNodeId

Source

pub fn set_root(&mut self, new_root: CstNodeId)

Source

pub fn change_parent(&mut self, id: CstNodeId, new_parent: CstNodeId)

Source

pub fn add_node(&mut self, data: CstNodeData<T, Nt>) -> CstNodeId

Source

pub fn add_node_with_parent( &mut self, data: CstNodeData<T, Nt>, parent: CstNodeId, ) -> CstNodeId

Source

pub fn add_child(&mut self, parent: CstNodeId, child: CstNodeId)

Source

pub fn has_no_children(&self, node: CstNodeId) -> bool

Source

pub fn children( &self, node: CstNodeId, ) -> impl DoubleEndedIterator<Item = CstNodeId> + '_

Source

pub fn parent(&self, node: CstNodeId) -> Option<CstNodeId>

Source

pub fn get_str<'a: 'c, 'b: 'c, 'c>( &'a self, terminal: TerminalData, input: &'b str, ) -> Option<&'c str>

Source

pub fn dynamic_token(&self, id: DynamicTokenId) -> Option<&str>

Source

pub fn update_node( &mut self, id: CstNodeId, data: CstNodeData<T, Nt>, ) -> Option<CstNodeData<T, Nt>>

Source

pub fn update_children( &mut self, id: CstNodeId, new_children: impl IntoIterator<Item = CstNodeId>, )

Source

pub fn insert_dynamic_terminal( &mut self, data: impl Into<String>, ) -> DynamicTokenId

Source§

impl<T, Nt> ConcreteSyntaxTree<T, Nt>
where T: Copy, Nt: Copy,

Source

pub fn node_data(&self, node: CstNodeId) -> Option<CstNodeData<T, Nt>>

Source

pub fn remove_node(&mut self, id: CstNodeId)

Remove a node from the tree by removing it from all parent-child relationships. The node data remains in the vector but becomes unreachable through tree traversal.

Source§

impl ConcreteSyntaxTree<TerminalKind, NonTerminalKind>

Source

pub fn get_non_terminal( &self, id: CstNodeId, kind: NonTerminalKind, ) -> Result<NonTerminalData, CstConstructError>

Source

pub fn get_terminal( &self, id: CstNodeId, kind: TerminalKind, ) -> Result<TerminalData, CstConstructError>

Source

pub fn collect_nodes<'v, const N: usize, V: BuiltinTerminalVisitor<E, F>, O, E, F: CstFacade>( &self, facade: &F, parent: CstNodeId, nodes: [NodeKind<TerminalKind, NonTerminalKind>; N], visitor: impl FnMut([CstNodeId; N], &'v mut V) -> Result<(O, &'v mut V), CstConstructError<E>>, visit_ignored: &'v mut V, ) -> Result<O, CstConstructError<E>>

Source

pub fn root_handle(&self) -> RootHandle

Source

pub fn visit_from_root<V: CstVisitor<Self>>( &self, visitor: &mut V, ) -> Result<(), V::Error>

Trait Implementations§

Source§

impl<T: Clone, Nt: Clone> Clone for ConcreteSyntaxTree<T, Nt>

Source§

fn clone(&self) -> ConcreteSyntaxTree<T, Nt>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CstFacade for ConcreteSyntaxTree<TerminalKind, NonTerminalKind>

Source§

fn get_str<'a: 'c, 'b: 'c, 'c>( &'a self, terminal: TerminalData, input: &'b str, ) -> Option<&'c str>

Source§

fn node_data( &self, node: CstNodeId, ) -> Option<CstNodeData<TerminalKind, NonTerminalKind>>

Source§

fn has_no_children(&self, node: CstNodeId) -> bool

Source§

fn children( &self, node: CstNodeId, ) -> impl DoubleEndedIterator<Item = CstNodeId>

Source§

fn get_terminal( &self, node: CstNodeId, kind: TerminalKind, ) -> Result<TerminalData, CstConstructError>

Source§

fn get_non_terminal( &self, node: CstNodeId, kind: NonTerminalKind, ) -> Result<NonTerminalData, CstConstructError>

Source§

fn collect_nodes<'v, const N: usize, V: BuiltinTerminalVisitor<E, Self>, O, E>( &self, parent: CstNodeId, nodes: [NodeKind<TerminalKind, NonTerminalKind>; N], visitor: impl FnMut([CstNodeId; N], &'v mut V) -> Result<(O, &'v mut V), CstConstructError<E>>, visit_ignored: &'v mut V, ) -> Result<O, CstConstructError<E>>

Source§

fn dynamic_token(&self, id: DynamicTokenId) -> Option<&str>

Source§

fn parent(&self, node: CstNodeId) -> Option<CstNodeId>

Source§

fn root_handle(&self) -> RootHandle

Source§

fn get_terminal_str<'a: 'c, 'b: 'c, 'c, T: TerminalHandle>( &'a self, input: &'b str, handle: T, ) -> Result<Result<&'c str, DynamicTokenId>, CstConstructError>

Returns the string representation of a terminal. Returns None if the terminal is a dynamic token and not found.
Source§

fn span(&self, node_id: CstNodeId) -> Option<InputSpan>

Returns a span that excludes leading and trailing trivia (whitespace, newlines, comments). Read more
Source§

fn concrete_span(&self, node_id: CstNodeId) -> Option<InputSpan>

Returns the span of a node, including the trivia.
Source§

fn find_first_non_trivia_span(&self, node_id: CstNodeId) -> Option<InputSpan>

Helper: finds the first non-trivia span by depth-first search from the start.
Source§

fn find_last_non_trivia_span(&self, node_id: CstNodeId) -> Option<InputSpan>

Helper: finds the last non-trivia span by depth-first search from the end.
Source§

impl<T: Debug, Nt: Debug> Debug for ConcreteSyntaxTree<T, Nt>

Source§

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

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

impl<T: PartialEq, Nt: PartialEq> PartialEq for ConcreteSyntaxTree<T, Nt>

Source§

fn eq(&self, other: &ConcreteSyntaxTree<T, Nt>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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<T: Eq, Nt: Eq> Eq for ConcreteSyntaxTree<T, Nt>

Source§

impl<T, Nt> StructuralPartialEq for ConcreteSyntaxTree<T, Nt>

Auto Trait Implementations§

§

impl<T, Nt> Freeze for ConcreteSyntaxTree<T, Nt>

§

impl<T, Nt> RefUnwindSafe for ConcreteSyntaxTree<T, Nt>

§

impl<T, Nt> Send for ConcreteSyntaxTree<T, Nt>
where T: Send, Nt: Send,

§

impl<T, Nt> Sync for ConcreteSyntaxTree<T, Nt>
where T: Sync, Nt: Sync,

§

impl<T, Nt> Unpin for ConcreteSyntaxTree<T, Nt>
where T: Unpin, Nt: Unpin,

§

impl<T, Nt> UnwindSafe for ConcreteSyntaxTree<T, Nt>
where T: UnwindSafe, Nt: UnwindSafe,

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<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<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.