New macro system and stdlib additions
This commit is contained in:
@@ -4,8 +4,8 @@ use orchid_base::format::FmtUnit;
|
||||
use orchid_base::parse::{name_char, name_start};
|
||||
use orchid_extension::atom::Atomic;
|
||||
use orchid_extension::atom_thin::{ThinAtom, ThinVariant};
|
||||
use orchid_extension::context::i;
|
||||
use orchid_extension::lexer::{LexContext, Lexer, err_not_applicable};
|
||||
use orchid_extension::system::SysCtx;
|
||||
use orchid_extension::tree::{GenTokTree, x_tok};
|
||||
|
||||
use crate::macros::mactree::{Ph, PhKind};
|
||||
@@ -13,17 +13,15 @@ use crate::macros::mactree::{Ph, PhKind};
|
||||
#[derive(Clone, Coding)]
|
||||
pub struct PhAtom(orchid_api::TStr, PhKind);
|
||||
impl PhAtom {
|
||||
pub async fn to_full(&self, ctx: &SysCtx) -> Ph {
|
||||
Ph { kind: self.1, name: ctx.i().ex(self.0).await }
|
||||
}
|
||||
pub async fn to_full(&self) -> Ph { Ph { kind: self.1, name: i().ex(self.0).await } }
|
||||
}
|
||||
impl Atomic for PhAtom {
|
||||
type Data = Self;
|
||||
type Variant = ThinVariant;
|
||||
}
|
||||
impl ThinAtom for PhAtom {
|
||||
async fn print(&self, ctx: SysCtx) -> FmtUnit {
|
||||
Ph { name: ctx.i().ex(self.0).await, kind: self.1 }.to_string().into()
|
||||
async fn print(&self) -> FmtUnit {
|
||||
Ph { name: i().ex(self.0).await, kind: self.1 }.to_string().into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +52,7 @@ impl Lexer for PhLexer {
|
||||
(prio_num, tail)
|
||||
} else {
|
||||
return Err(mk_errv(
|
||||
ctx.ctx.i().i("Invalid priority, must be 0-255").await,
|
||||
i().i("Invalid priority, must be 0-255").await,
|
||||
format!("{prio} is not a valid placeholder priority"),
|
||||
[ctx.pos_lt(prio.len(), tail)],
|
||||
));
|
||||
@@ -70,10 +68,10 @@ impl Lexer for PhLexer {
|
||||
let (name, priority, tail) = name_and_prio(tail, ctx).await?;
|
||||
(tail, name, PhKind::Vector { at_least_one: true, priority })
|
||||
} else {
|
||||
return Err(err_not_applicable(ctx.ctx.i()).await);
|
||||
return Err(err_not_applicable().await);
|
||||
}
|
||||
};
|
||||
let ph_atom = PhAtom(ctx.ctx.i().i::<String>(name).await.to_api(), phkind);
|
||||
let ph_atom = PhAtom(i().i::<String>(name).await.to_api(), phkind);
|
||||
Ok((tail, x_tok(ph_atom).await.at(ctx.pos_tt(line, tail))))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user