Files
orchid/src/representations/namelike.rs
Lawrence Bethlenfalvy 3fdabc29da Most files suffered major changes
- Less ambiguous syntax
- Better parser (Chumsky only does tokenization now)
- Tidy(|ier) error handling
- Facade for simplified embedding
- External code grouped in (fairly) self-contained Systems
- Dynamic action dispatch
- Many STL additions
2023-08-18 12:57:41 +01:00

37 lines
884 B
Rust

use std::hash::Hash;
use crate::interner::{Interner, Tok};
/// A mutable representation of a namespaced identifier.
///
/// These names may be relative or otherwise partially processed.
///
/// See also [Sym]
pub type VName = Vec<Tok<String>>;
/// An interned representation of a namespaced identifier.
///
/// These names are always absolute.
///
/// See also [VName]
pub type Sym = Tok<Vec<Tok<String>>>;
/// An abstraction over tokenized vs non-tokenized names so that they can be
/// handled together in datastructures
pub trait NameLike: 'static + Clone + Eq + Hash {
/// Fully resolve the name for printing
fn to_strv(&self, i: &Interner) -> Vec<String>;
}
impl NameLike for Sym {
fn to_strv(&self, i: &Interner) -> Vec<String> {
i.extern_vec(*self)
}
}
impl NameLike for VName {
fn to_strv(&self, i: &Interner) -> Vec<String> {
i.extern_all(self)
}
}