From 122d81f252b91897ce9b965930b6885ae7568d20 Mon Sep 17 00:00:00 2001 From: Jeff Date: Fri, 16 Feb 2024 11:04:43 -0500 Subject: [PATCH] Clean up docs --- src/abstract_tree/mod.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/abstract_tree/mod.rs b/src/abstract_tree/mod.rs index f17b40c..40cfbaa 100644 --- a/src/abstract_tree/mod.rs +++ b/src/abstract_tree/mod.rs @@ -1,11 +1,6 @@ //! Abstract, executable representations of corresponding items found in Dust //! source code. The types that implement [AbstractTree] are inteded to be -//! created by an [Evaluator]. -//! -//! When adding new lanugage features, first extend the grammar to recognize new -//! syntax nodes. Then add a new AbstractTree type using the existing types as -//! examples. - +//! created by an [Interpreter]. pub mod r#as; pub mod assignment; pub mod assignment_operator; @@ -55,6 +50,7 @@ use crate::{ SyntaxNode, Value, }; +/// A detailed report of a position in the source code string. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub struct SourcePosition { pub start_byte: usize, @@ -78,6 +74,7 @@ impl From for SourcePosition { } } +/// Abstraction that represents a whole, executable unit of dust code. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)] pub struct Root { statements: Vec, @@ -141,8 +138,8 @@ impl Format for Root { /// This trait is implemented by the Evaluator's internal types to form an /// executable tree that resolves to a single value. pub trait AbstractTree: Sized + Format { - /// Interpret the syntax tree at the given node and return the abstraction. Returns a syntax - /// error if the source is invalid. + /// Interpret the syntax tree at the given node and return the abstraction. + /// Returns a syntax error if the source is invalid. /// /// This function is used to convert nodes in the Tree Sitter concrete /// syntax tree into executable nodes in an abstract tree. This function is @@ -153,15 +150,16 @@ pub trait AbstractTree: Sized + Format { /// node's byte range. fn from_syntax(node: SyntaxNode, source: &str, context: &Context) -> Result; - /// Return the type of the value that this abstract node will create when run. Returns a - /// validation error if the tree is invalid. + /// Return the type of the value that this abstract node will create when + /// run. Returns a validation error if the tree is invalid. fn expected_type(&self, context: &Context) -> Result; - /// Verify the type integrity of the node. Returns a validation error if the tree is invalid. + /// Verify the type integrity of the node. Returns a validation error if the + /// tree is invalid. fn validate(&self, source: &str, context: &Context) -> Result<(), ValidationError>; - /// Execute this node's logic and return a value. Returns a runtime error if the node cannot - /// resolve to a value. + /// Execute this node's logic and return a value. Returns a runtime error if + /// the node cannot resolve to a value. fn run(&self, source: &str, context: &Context) -> Result; }