pub struct SemanticNode {
pub node_type: String,
pub value: Option<String>,
pub children: Vec<SemanticNode>,
pub annotations: HashMap<String, String>,
}Expand description
AST node for semantic analysis
Fields§
§node_type: StringNode type
value: Option<String>Node value (if any)
children: Vec<SemanticNode>Child nodes
annotations: HashMap<String, String>Semantic annotations
Implementations§
Source§impl SemanticNode
impl SemanticNode
Sourcepub fn with_child(self, child: SemanticNode) -> Self
pub fn with_child(self, child: SemanticNode) -> Self
Add a child node
Sourcepub fn with_value(self, value: impl Into<String>) -> Self
pub fn with_value(self, value: impl Into<String>) -> Self
Set node value
Sourcepub fn with_annotation(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_annotation( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add annotation
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Count total nodes in tree
Trait Implementations§
Source§impl Clone for SemanticNode
impl Clone for SemanticNode
Source§fn clone(&self) -> SemanticNode
fn clone(&self) -> SemanticNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SemanticNode
impl Debug for SemanticNode
Source§impl<'de> Deserialize<'de> for SemanticNode
impl<'de> Deserialize<'de> for SemanticNode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for SemanticNode
impl PartialEq for SemanticNode
Source§impl Serialize for SemanticNode
impl Serialize for SemanticNode
impl StructuralPartialEq for SemanticNode
Auto Trait Implementations§
impl Freeze for SemanticNode
impl RefUnwindSafe for SemanticNode
impl Send for SemanticNode
impl Sync for SemanticNode
impl Unpin for SemanticNode
impl UnsafeUnpin for SemanticNode
impl UnwindSafe for SemanticNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more