Comments

Comments, like much of Spade’s syntax, are heavily inspired by that of Rust. It has a couple types of comments and they are properly integrated into the lexer to enable features such as nested multiline comments.

Types of Comment

Spade supports 4 types of comments:

Note: One area where Spade deviates from Rust in this regard is in the lack of inclusion of block documentation comments.

Non-Documentation Comments

Non-documentation (standard line and block comments) are treated by spade as whitespace and have no semantic meaning.

Block comments support nested usage, meaning each /* must have a matching */, even if it is within another comment:

/*
*    /* Inner comment */
*/

Documentation Comments

Documentation comments are treated as a form of attribute. They are used, as the name implies, to document items and modules. Content within them is treated as markdown.

//! This is top-level documentation applying to the module represented by this file


/// This is documentation on this type
struct MyType {
    x: uint<8>,

    /// Documentation on a specific field
    y: bool,
}

impl MyType {
    /// And this is documentation on a specific method
    fn return_self(self) -> MyType {
        self
    }
}