reefer 0.3.0

Optimizing proc-macro for geometric algebra
Documentation
#![doc = include_str!("../docs/2-overview.md")]
#![doc = ""]
#![doc = include_str!("../docs/1-quickstart.md")]
#![doc = ""]
#![doc = include_str!("../docs/3-using-the-macros.md")]
#![doc = ""]
#![doc = include_str!("../docs/4-expressions-and-operators.md")]
#![doc = ""]
#![doc = include_str!("../docs/5-optimization-pipeline.md")]
#![doc = ""]
#![doc = include_str!("../docs/6-backends-and-features.md")]
#![doc = ""]
#![doc = include_str!("../docs/7-troubleshooting.md")]

use proc_macro::TokenStream;

mod basis_grammar;
mod builder;
mod clifford;
mod optimizer;
mod spec;
mod symbol_field;

#[cfg(feature = "bits_u128")]
pub(crate) type BladeBits = u128;
#[cfg(feature = "bits_u64")]
pub(crate) type BladeBits = u64;
#[cfg(feature = "bits_u32")]
pub(crate) type BladeBits = u32;
#[cfg(feature = "bits_u16")]
pub(crate) type BladeBits = u16;
#[cfg(feature = "bits_u8")]
pub(crate) type BladeBits = u8;
#[cfg(not(any(
    feature = "bits_u8",
    feature = "bits_u16",
    feature = "bits_u32",
    feature = "bits_u64",
    feature = "bits_u128",
)))]
pub(crate) type BladeBits = u32;

/// Unsigned integer type used when describing frame indices in the generated algebra.
pub(crate) type FrameType = BladeBits;

/// Attribute macro that expands a module definition into a full Clifford algebra implementation.
///
/// The macro expects an attribute payload describing the scalar type along with the signature
/// of the algebra, and it transforms the annotated module accordingly.
#[proc_macro_attribute]
pub fn algebra(attr: TokenStream, item: TokenStream) -> TokenStream {
    let build = builder::do_algebra_macro(attr.into(), item.into());
    build.unwrap_or_else(|err| err.to_compile_error()).into()
}

/// Proc-macro helper that builds optimized Clifford algebra expressions at compile time.
///
/// The macro accepts an algebra specification followed by a closure describing the computation
/// to perform and returns a token stream implementing that computation.
#[proc_macro]
pub fn build_expr(item: TokenStream) -> TokenStream {
    let build = builder::do_build_expr_macro(item.into());
    build.unwrap_or_else(|err| err.to_compile_error()).into()
}