partway towards commands
I got very confused and started mucking about with "spawn" when in fact all I needed was the "inline" extension type in orcx that allows the interpreter to expose custom constants.
This commit is contained in:
@@ -11,8 +11,7 @@ use futures::future::{OptionFuture, join_all};
|
||||
use itertools::Itertools;
|
||||
use trait_set::trait_set;
|
||||
|
||||
use crate::api;
|
||||
use crate::interner::{IStr, IStrv, es, ev, is, iv};
|
||||
use crate::{IStr, IStrv, api, es, ev, is, iv};
|
||||
|
||||
trait_set! {
|
||||
/// Traits that all name iterators should implement
|
||||
@@ -143,7 +142,6 @@ impl VName {
|
||||
}
|
||||
/// Read a `::` separated namespaced name
|
||||
pub async fn parse(s: &str) -> Result<Self, EmptyNameError> { Self::new(VPath::parse(s).await) }
|
||||
pub async fn literal(s: &'static str) -> Self { Self::parse(s).await.expect("empty literal !?") }
|
||||
/// Obtain an iterator over the segments of the name
|
||||
pub fn iter(&self) -> impl Iterator<Item = IStr> + '_ { self.0.iter().cloned() }
|
||||
}
|
||||
@@ -213,10 +211,13 @@ impl Sym {
|
||||
pub fn id(&self) -> NonZeroU64 { self.0.to_api().0 }
|
||||
/// Extern the sym for editing
|
||||
pub fn to_vname(&self) -> VName { VName(self[..].to_vec()) }
|
||||
/// Decode from a message
|
||||
pub async fn from_api(marker: api::TStrv) -> Sym {
|
||||
Self::from_tok(ev(marker).await).expect("Empty sequence found for serialized Sym")
|
||||
}
|
||||
/// Encode into a message
|
||||
pub fn to_api(&self) -> api::TStrv { self.tok().to_api() }
|
||||
/// Copy the symbol and extend it with a suffix
|
||||
pub async fn suffix(&self, tokv: impl IntoIterator<Item = IStr>) -> Sym {
|
||||
Self::new(self.0.iter().cloned().chain(tokv)).await.unwrap()
|
||||
}
|
||||
@@ -246,7 +247,7 @@ impl Deref for Sym {
|
||||
|
||||
/// An abstraction over tokenized vs non-tokenized names so that they can be
|
||||
/// handled together in datastructures. The names can never be empty
|
||||
#[allow(clippy::len_without_is_empty)] // never empty
|
||||
#[allow(clippy::len_without_is_empty, reason = "never empty")]
|
||||
pub trait NameLike:
|
||||
'static + Clone + Eq + Hash + fmt::Debug + fmt::Display + Borrow<[IStr]>
|
||||
{
|
||||
@@ -292,11 +293,11 @@ impl NameLike for VName {}
|
||||
#[macro_export]
|
||||
macro_rules! sym {
|
||||
($seg1:tt $( :: $seg:tt)*) => {
|
||||
$crate::tl_cache!(async $crate::name::Sym : {
|
||||
$crate::name::Sym::from_tok(
|
||||
$crate::interner::iv(&[
|
||||
$crate::interner::is($crate::sym!(@SEG $seg1)).await
|
||||
$( , $crate::interner::is($crate::sym!(@SEG $seg)).await )*
|
||||
$crate::tl_cache!(async $crate::Sym : {
|
||||
$crate::Sym::from_tok(
|
||||
$crate::iv(&[
|
||||
$crate::is($crate::sym!(@SEG $seg1)).await
|
||||
$( , $crate::is($crate::sym!(@SEG $seg)).await )*
|
||||
])
|
||||
.await
|
||||
).unwrap()
|
||||
@@ -316,10 +317,10 @@ macro_rules! sym {
|
||||
#[macro_export]
|
||||
macro_rules! vname {
|
||||
($seg1:tt $( :: $seg:tt)*) => {
|
||||
$crate::tl_cache!(async $crate::name::VName : {
|
||||
$crate::name::VName::new([
|
||||
$crate::interner::is(stringify!($seg1)).await
|
||||
$( , $crate::interner::is(stringify!($seg)).await )*
|
||||
$crate::tl_cache!(async $crate::VName : {
|
||||
$crate::VName::new([
|
||||
$crate::is(stringify!($seg1)).await
|
||||
$( , $crate::is(stringify!($seg)).await )*
|
||||
]).unwrap()
|
||||
})
|
||||
};
|
||||
@@ -331,28 +332,26 @@ macro_rules! vname {
|
||||
#[macro_export]
|
||||
macro_rules! vpath {
|
||||
($seg1:tt $( :: $seg:tt)*) => {
|
||||
$crate::tl_cache!(async $crate::name::VPath : {
|
||||
$crate::name::VPath(vec![
|
||||
$crate::interner::is(stringify!($seg1)).await
|
||||
$( , $crate::interner::is(stringify!($seg)).await )*
|
||||
$crate::tl_cache!(async $crate::VPath : {
|
||||
$crate::VPath::new(vec![
|
||||
$crate::is(stringify!($seg1)).await
|
||||
$( , $crate::is(stringify!($seg)).await )*
|
||||
])
|
||||
})
|
||||
};
|
||||
() => {
|
||||
$crate::name::VPath(vec![])
|
||||
$crate::VPath::new(vec![])
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod test {
|
||||
mod test {
|
||||
use std::borrow::Borrow;
|
||||
|
||||
use orchid_api_traits::spin_on;
|
||||
|
||||
use super::{NameLike, Sym, VName};
|
||||
use crate::interner::local_interner::local_interner;
|
||||
use crate::interner::{IStr, is, with_interner};
|
||||
use crate::name::VPath;
|
||||
use crate::local_interner::local_interner;
|
||||
use crate::{IStr, NameLike, Sym, VName, VPath, is, with_interner};
|
||||
|
||||
#[test]
|
||||
pub fn recur() {
|
||||
|
||||
Reference in New Issue
Block a user