New macro system and stdlib additions

This commit is contained in:
2025-11-21 14:25:03 +01:00
parent b77653f841
commit 603efef28e
230 changed files with 3033 additions and 16640 deletions

View File

@@ -1,15 +1,15 @@
use std::borrow::Cow;
use std::rc::Rc;
use hashbrown::HashSet;
use never::Never;
use orchid_base::interner::Tok;
use orchid_base::name::Sym;
use orchid_extension::atom::Atomic;
use orchid_extension::atom_owned::{OwnedAtom, OwnedVariant};
use orchid_extension::system::SysCtx;
use orchid_extension::context::i;
use crate::macros::rule::matcher::{NamedMatcher, PriodMatcher};
use crate::macros::mactree::MacTreeSeq;
use crate::macros::rule::matcher::Matcher;
#[derive(Debug)]
pub struct MacroData {
@@ -21,23 +21,18 @@ pub struct MacroData {
#[derive(Clone, Debug)]
pub struct Macro(pub Rc<MacroData>);
impl Macro {
pub async fn canonical_name(&self, ctx: &SysCtx) -> Sym {
self.0.module.suffix([self.0.rules[0].body_name.clone()], ctx.i()).await
pub async fn canonical_name(&self) -> Sym {
self.0.module.suffix([self.0.rules[0].body_name.clone()], &i()).await
}
}
#[derive(Debug)]
pub struct Rule {
pub pattern: Matcher,
pub glossary: HashSet<Sym>,
pub pattern: MacTreeSeq,
pub matcher: Matcher,
pub placeholders: Vec<Tok<String>>,
pub body_name: Tok<String>,
}
#[derive(Debug)]
pub enum Matcher {
Named(NamedMatcher),
Priod(PriodMatcher),
}
impl Atomic for Macro {
type Data = ();
type Variant = OwnedVariant;