diff --git a/examples/to-lisp.rs b/examples/to-lisp.rs index a2a662f..2580da6 100644 --- a/examples/to-lisp.rs +++ b/examples/to-lisp.rs @@ -2,7 +2,9 @@ use std::error::Error; use doughlang::{ ast::{ - types::{Literal, Path}, visit::{Visit, Walk}, * + types::{Literal, Path}, + visit::{Visit, Walk}, + *, }, intern::interned::Interned, lexer::Lexer, diff --git a/src/ast.rs b/src/ast.rs index 6832a1d..318e5a1 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -23,7 +23,7 @@ pub trait AstTypes: Annotation { /// A literal value type Literal: Annotation; - /// A (possibly interned) symbol or index which implements [AsRef] + /// A (possibly interned) symbol or index which implements [`AsRef`] type MacroId: Annotation + Hash + AsRef; /// A (possibly interned) symbol or index @@ -31,12 +31,6 @@ pub trait AstTypes: Annotation { /// A (possibly compound) symbol or index type Path: Annotation; - - // /// An Operator in an [Expression](Expr) - // type ExprOp: Annotation + Copy; - - // /// An Operator within a [Pattern](Pat) - // type PatOp: Annotation + Copy; } /// A value with an annotation. @@ -279,9 +273,9 @@ impl Expr { /// ```ignore /// let Pat (= Expr (else Expr)?)? /// type Pat (= Expr)? -/// fn Pat Expr -/// mod Pat Expr -/// impl Pat Expr +/// fn Pat =? Expr +/// mod Pat =? Expr +/// impl Pat =? Expr /// struct Pat /// enum Pat /// for Pat in Expr Expr (else Expr)? @@ -295,6 +289,9 @@ pub struct Bind( pub Vec, A>>, ); +/// The binding operation used by a [Bind]. +/// +/// See [Bind] for their syntactic representations #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum BindOp { /// A `let Pat (= Expr (else Expr)?)?` binding @@ -316,6 +313,7 @@ pub enum BindOp { /// A `Pat => Expr` binding Match, } + /// Binding patterns for each kind of matchable value. /// /// This covers both bindings and type annotations in [Bind] expressions. diff --git a/src/ast/fold.rs b/src/ast/fold.rs index 6d6ea40..b9358f5 100644 --- a/src/ast/fold.rs +++ b/src/ast/fold.rs @@ -72,7 +72,7 @@ pub trait Foldable: Sized { /// The return type of the associated [Fold] function type Out; - /// Calls `Self`'s appropriate [Folder] function(s) + /// Calls `Self`'s appropriate [Folder](Fold) function(s) fn fold_in + ?Sized>(self, folder: &mut F) -> Result; /// Destructures `self`, calling [`Foldable::fold_in`] on all foldable members, diff --git a/src/ast/types.rs b/src/ast/types.rs index 13d2b57..964dd08 100644 --- a/src/ast/types.rs +++ b/src/ast/types.rs @@ -1,3 +1,5 @@ +//! The default (as-parsed) implementation of the AST's customization points. + use std::fmt::Display; use crate::{ast::AstTypes, fmt::FmtAdapter, intern::interned::Interned, span::Span}; diff --git a/src/intern.rs b/src/intern.rs index e89e19e..1583857 100644 --- a/src/intern.rs +++ b/src/intern.rs @@ -303,7 +303,7 @@ pub mod dropless_interner { } impl<'a, T: Eq + Hash> DroplessInterner<'a, T> { - /// Creates a new [DroplessInterner] backed by the provided [TypedArena] + /// Creates a new [DroplessInterner] backed by the provided [`DroplessArena`] /// /// # Panics /// Panics if T [needs drop](std::mem::needs_drop) @@ -335,6 +335,7 @@ pub mod dropless_interner { } }) } + /// Returns the [Interned] copy of the given value, if one already exists /// /// # Blocks