tamer: xir::st: Static namespace prefixes (c and t)

In particular, `t:*` will be recognized by NIR for short-hand template
application.  These will be utilized in an upcoming commit.

DEV-7145
main
Mike Gerwitz 2022-08-10 16:33:46 -04:00
parent 88fa0688fa
commit f9fe4aa13b
4 changed files with 29 additions and 1 deletions

View File

@ -73,6 +73,8 @@
#![feature(adt_const_params)]
// We build docs for private items.
#![allow(rustdoc::private_intra_doc_links)]
// For sym::prefill recursive macro `static_symbols!`.
#![recursion_limit = "256"]
pub mod global;

View File

@ -498,6 +498,7 @@ pub mod st {
N9: dec "9",
L_BOOLEAN: cid "boolean",
L_C: cid "c",
L_CGEN: cid "cgen",
L_CLASS: cid "class",
L_CLASSIFY: cid "classify",
@ -549,6 +550,7 @@ pub mod st {
L_SYM_DEP: cid "sym-dep",
L_SYM_DEPS: cid "sym-deps",
L_SYM_REF: cid "sym-ref",
L_T: cid "t",
L_TITLE: cid "title",
L_TPL: cid "tpl",
L_TRUE: cid "true",

View File

@ -160,6 +160,15 @@ impl TryFrom<&str> for NCName {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Prefix(NCName);
impl Prefix {
/// Construct a constant [`Prefix`] from a static C-style symbol.
pub const fn st_cid<T: QNameCompatibleStaticSymbolId>(
prefix_sym: &T,
) -> Self {
Self(NCName(st_as_sym(prefix_sym)))
}
}
/// Local name portion of a [`QName`].
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct LocalPart(NCName);

View File

@ -21,10 +21,25 @@
//!
//! This is analogous to [`crate::sym::st`].
use crate::sym::st::*;
pub mod prefix {
//! Static [`Prefix`]es.
use super::super::Prefix;
use super::*;
/// Namespace prefix [`L_C`] used for calculation expressions.
pub const NS_C: Prefix = Prefix::st_cid(&L_C);
/// Namespace prefix [`L_T`] used for short-hand template application.
pub const NS_T: Prefix = Prefix::st_cid(&L_T);
}
pub mod qname {
//! Static [`QName`]s.
use crate::sym::st::*;
use super::*;
use crate::sym::{
CIdentStaticSymbolId, StaticSymbolId, TameIdentStaticSymbolId,
};