From d2e04050336d90edd66ab62e90e9e3fd1cfe4610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Sat, 7 Mar 2026 10:07:47 +0100 Subject: [PATCH] Rename library to nomo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcel Müller --- Cargo.lock | 28 +++++------ Cargo.toml | 4 +- src/emit/mod.rs | 6 +-- src/eval/mod.rs | 4 +- src/input.rs | 50 +++++++++---------- src/lib.rs | 28 +++++------ src/parser/mod.rs | 20 ++++---- tests/cases/1-parsed@identifiers.snap | 2 +- tests/cases/1-parsed@interpolation.snap | 2 +- tests/cases/1-parsed@multiple.snap | 2 +- tests/cases/1-parsed@simple.snap | 2 +- tests/cases/2-ast@identifiers.snap | 2 +- tests/cases/2-ast@interpolation.snap | 2 +- tests/cases/2-ast@multiple.snap | 2 +- tests/cases/2-ast@simple.snap | 2 +- tests/cases/3-instructions@identifiers.snap | 2 +- tests/cases/3-instructions@interpolation.snap | 2 +- tests/cases/3-instructions@multiple.snap | 2 +- tests/cases/3-instructions@simple.snap | 2 +- tests/cases/4-output@identifiers.snap | 2 +- tests/cases/4-output@interpolation.snap | 2 +- tests/cases/4-output@multiple.snap | 2 +- tests/cases/4-output@simple.snap | 2 +- .../{identifiers.temple => identifiers.nomo} | 0 ...nterpolation.temple => interpolation.nomo} | 0 .../cases/{multiple.temple => multiple.nomo} | 0 tests/cases/{simple.temple => simple.nomo} | 0 tests/file_tests.rs | 12 ++--- 28 files changed, 92 insertions(+), 92 deletions(-) rename tests/cases/{identifiers.temple => identifiers.nomo} (100%) rename tests/cases/{interpolation.temple => interpolation.nomo} (100%) rename tests/cases/{multiple.temple => multiple.nomo} (100%) rename tests/cases/{simple.temple => simple.nomo} (100%) diff --git a/Cargo.lock b/Cargo.lock index 21b08d2..eb888da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,6 +228,20 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "nomo" +version = "0.1.0" +dependencies = [ + "annotate-snippets", + "displaydoc", + "insta", + "nomo", + "serde", + "serde_json", + "thiserror", + "winnow", +] + [[package]] name = "once_cell" version = "1.21.3" @@ -386,20 +400,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "temple" -version = "0.1.0" -dependencies = [ - "annotate-snippets", - "displaydoc", - "insta", - "serde", - "serde_json", - "temple", - "thiserror", - "winnow", -] - [[package]] name = "thiserror" version = "2.0.18" diff --git a/Cargo.toml b/Cargo.toml index 521eacb..ff05160 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "temple" +name = "nomo" version = "0.1.0" edition = "2024" @@ -14,7 +14,7 @@ winnow = { version = "0.7.14", features = ["unstable-recover"] } [dev-dependencies] annotate-snippets = { version = "0.12.13", features = ["testing-colors"] } insta = { version = "1.46.3", features = ["glob"] } -temple = { path = ".", features = ["serialize"] } +nomo = { path = ".", features = ["serialize"] } [profile.dev.package] insta.opt-level = 3 diff --git a/src/emit/mod.rs b/src/emit/mod.rs index 207866b..c3fb6a8 100644 --- a/src/emit/mod.rs +++ b/src/emit/mod.rs @@ -1,5 +1,5 @@ use crate::ast::TemplateAstExpr; -use crate::input::TempleInput; +use crate::input::NomoInput; pub struct EmitMachine { current_index: usize, @@ -25,10 +25,10 @@ pub struct VariableSlot { #[derive(Debug)] pub enum Instruction { AppendContent { - content: TempleInput, + content: NomoInput, }, LoadFromContextToSlot { - name: TempleInput, + name: NomoInput, slot: VariableSlot, }, EmitFromSlot { diff --git a/src/eval/mod.rs b/src/eval/mod.rs index f2097c6..579891e 100644 --- a/src/eval/mod.rs +++ b/src/eval/mod.rs @@ -5,12 +5,12 @@ use thiserror::Error; use crate::Context; use crate::emit::Instruction; -use crate::input::TempleInput; +use crate::input::NomoInput; #[derive(Debug, Error, Display)] pub enum EvaluationError { /// An unknown variable was encountered: .0 - UnknownVariable(TempleInput), + UnknownVariable(NomoInput), /// An explicit abort was requested ExplicitAbort, } diff --git a/src/input.rs b/src/input.rs index 955c6c2..0f0290f 100644 --- a/src/input.rs +++ b/src/input.rs @@ -9,14 +9,14 @@ use winnow::stream::Stream; use winnow::stream::StreamIsPartial; #[derive(Clone, PartialEq, Eq)] -pub struct TempleInput { +pub struct NomoInput { backing: Arc, range: Range, } -impl TempleInput { - pub fn from_parts(backing: Arc, range: Range) -> TempleInput { - TempleInput { backing, range } +impl NomoInput { + pub fn from_parts(backing: Arc, range: Range) -> NomoInput { + NomoInput { backing, range } } pub fn into_parts(self) -> (Arc, Range) { @@ -24,43 +24,43 @@ impl TempleInput { } } -impl std::fmt::Debug for TempleInput { +impl std::fmt::Debug for NomoInput { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "\"{}\"", self.as_str()) } } -impl From for TempleInput { +impl From for NomoInput { fn from(value: String) -> Self { let range = 0..value.len(); let backing = Arc::from(value); - TempleInput { backing, range } + NomoInput { backing, range } } } -impl From<&str> for TempleInput { +impl From<&str> for NomoInput { fn from(value: &str) -> Self { let backing = Arc::from(value.to_string()); let range = 0..value.len(); - TempleInput { backing, range } + NomoInput { backing, range } } } -impl FindSlice<&str> for TempleInput { +impl FindSlice<&str> for NomoInput { fn find_slice(&self, substr: &str) -> Option> { self.as_str().find_slice(substr) } } -impl Compare<&str> for TempleInput { +impl Compare<&str> for NomoInput { fn compare(&self, t: &str) -> winnow::stream::CompareResult { self.as_str().compare(t) } } -impl Deref for TempleInput { +impl Deref for NomoInput { type Target = str; fn deref(&self) -> &Self::Target { @@ -68,24 +68,24 @@ impl Deref for TempleInput { } } -impl TempleInput { +impl NomoInput { pub fn as_str(&self) -> &str { self.deref() } } -impl Offset for TempleInput { +impl Offset for NomoInput { fn offset_from(&self, start: &Self) -> usize { self.as_str().offset_from(&start.as_str()) } } -pub struct TempleInputIter { +pub struct NomoInputIter { idx: usize, - input: TempleInput, + input: NomoInput, } -impl Iterator for TempleInputIter { +impl Iterator for NomoInputIter { type Item = (usize, char); fn next(&mut self) -> Option { @@ -95,7 +95,7 @@ impl Iterator for TempleInputIter { } } -impl StreamIsPartial for TempleInput { +impl StreamIsPartial for NomoInput { type PartialState = (); fn complete(&mut self) -> Self::PartialState { @@ -109,17 +109,17 @@ impl StreamIsPartial for TempleInput { } } -impl Stream for TempleInput { +impl Stream for NomoInput { type Token = char; - type Slice = TempleInput; + type Slice = NomoInput; - type IterOffsets = TempleInputIter; + type IterOffsets = NomoInputIter; - type Checkpoint = TempleInput; + type Checkpoint = NomoInput; fn iter_offsets(&self) -> Self::IterOffsets { - TempleInputIter { + NomoInputIter { idx: 0, input: self.clone(), } @@ -187,11 +187,11 @@ impl Stream for TempleInput { mod tests { use winnow::stream::Stream; - use crate::input::TempleInput; + use crate::input::NomoInput; #[test] fn check_stream_impl() { - let mut stream = TempleInput::from("checking"); + let mut stream = NomoInput::from("checking"); let checkpoint = stream.checkpoint(); diff --git a/src/lib.rs b/src/lib.rs index fd23589..5bf0c60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ use serde::Serialize; use thiserror::Error; use crate::emit::Instruction; -use crate::input::TempleInput; +use crate::input::NomoInput; pub mod ast; pub mod emit; @@ -15,7 +15,7 @@ pub mod input; pub mod parser; #[derive(Debug, Error, Display)] -pub enum TempleError { +pub enum NomoError { /// Could not parse the given template ParseError { #[from] @@ -37,19 +37,19 @@ pub enum TempleError { UnknownTemplate(String), } -pub struct Temple { +pub struct Nomo { templates: HashMap, } -impl Default for Temple { +impl Default for Nomo { fn default() -> Self { Self::new() } } -impl Temple { - pub fn new() -> Temple { - Temple { +impl Nomo { + pub fn new() -> Nomo { + Nomo { templates: HashMap::new(), } } @@ -57,8 +57,8 @@ impl Temple { pub fn add_template( &mut self, name: impl Into, - value: impl Into, - ) -> Result<(), TempleError> { + value: impl Into, + ) -> Result<(), NomoError> { let source = value.into(); let parse = parser::parse(source.clone())?; let ast = ast::parse(parse.tokens())?; @@ -76,11 +76,11 @@ impl Temple { Ok(()) } - pub fn render(&self, name: &str, ctx: &Context) -> Result { + pub fn render(&self, name: &str, ctx: &Context) -> Result { let template = self .templates .get(name) - .ok_or_else(|| TempleError::UnknownTemplate(name.to_string()))?; + .ok_or_else(|| NomoError::UnknownTemplate(name.to_string()))?; let res = eval::execute(&template.instructions, ctx)?; @@ -89,7 +89,7 @@ impl Temple { } struct Template { - source: TempleInput, + source: NomoInput, instructions: Vec, } @@ -186,11 +186,11 @@ where #[cfg(test)] mod tests { use crate::Context; - use crate::Temple; + use crate::Nomo; #[test] fn check_simple_template() { - let mut temp = Temple::new(); + let mut temp = Nomo::new(); temp.add_template("base", "Hello {{= name }}").unwrap(); diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 63af6d9..f8089a3 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -33,10 +33,10 @@ use winnow::token::take_until; use winnow::token::take_while; use crate::SourceSpan; -use crate::input::TempleInput; +use crate::input::NomoInput; use crate::resume_after_cut; -type Input<'input> = Recoverable, ParseError>; +type Input<'input> = Recoverable, ParseError>; type PResult<'input, T> = Result; #[derive(Debug, Error)] @@ -52,7 +52,7 @@ impl std::fmt::Display for ParseFailure { } impl ParseFailure { - fn from_errors(errors: Vec, input: TempleInput) -> ParseFailure { + fn from_errors(errors: Vec, input: NomoInput) -> ParseFailure { ParseFailure { input: Arc::from(input.to_string()), errors, @@ -248,13 +248,13 @@ impl winnow::stream::ContainsToken<&'_ TemplateToken> for [Tok #[derive(Debug, Clone, PartialEq, Eq)] pub struct TemplateToken { kind: TokenKind, - source: TempleInput, + source: NomoInput, } macro_rules! impl_token_kind_builders { ($($name:ident => $kind:expr),+ $(,)?) => { $( - fn $name(source: TempleInput) -> Self { + fn $name(source: NomoInput) -> Self { TemplateToken { kind: $kind, source, @@ -277,7 +277,7 @@ impl TemplateToken { end => TokenKind::End, } - pub fn literal(literal: TokenLiteral, source: TempleInput) -> Self { + pub fn literal(literal: TokenLiteral, source: NomoInput) -> Self { TemplateToken { kind: TokenKind::Literal(literal), source, @@ -288,12 +288,12 @@ impl TemplateToken { self.kind } - pub fn source(&self) -> TempleInput { + pub fn source(&self) -> NomoInput { self.source.clone() } } -pub fn parse(input: TempleInput) -> Result { +pub fn parse(input: NomoInput) -> Result { let (_remaining, val, errors) = parse_tokens.recoverable_parse(LocatingSlice::new(input.clone())); @@ -335,7 +335,7 @@ fn parse_interpolate<'input>(input: &mut Input<'input>) -> PResult<'input, Vec(input: &mut Input<'input>) -> PResult<'input, TemplateTok .parse_next(input) } -fn ident<'input>(input: &mut Input<'input>) -> PResult<'input, TempleInput> { +fn ident<'input>(input: &mut Input<'input>) -> PResult<'input, NomoInput> { peek(not(parse_literal)) .context(ParseError::ctx().msg("Expected an ident, but found a literal instead")) .parse_next(input)?; diff --git a/tests/cases/1-parsed@identifiers.snap b/tests/cases/1-parsed@identifiers.snap index 755d9ec..935c9ff 100644 --- a/tests/cases/1-parsed@identifiers.snap +++ b/tests/cases/1-parsed@identifiers.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: parsed -input_file: tests/cases/identifiers.temple +input_file: tests/cases/identifiers.nomo --- ParsedTemplate { tokens: [ diff --git a/tests/cases/1-parsed@interpolation.snap b/tests/cases/1-parsed@interpolation.snap index d7ffd1c..9aa8976 100644 --- a/tests/cases/1-parsed@interpolation.snap +++ b/tests/cases/1-parsed@interpolation.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: parsed -input_file: tests/cases/interpolation.temple +input_file: tests/cases/interpolation.nomo --- ParsedTemplate { tokens: [ diff --git a/tests/cases/1-parsed@multiple.snap b/tests/cases/1-parsed@multiple.snap index 665cf57..ad8715b 100644 --- a/tests/cases/1-parsed@multiple.snap +++ b/tests/cases/1-parsed@multiple.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: parsed -input_file: tests/cases/multiple.temple +input_file: tests/cases/multiple.nomo --- ParsedTemplate { tokens: [ diff --git a/tests/cases/1-parsed@simple.snap b/tests/cases/1-parsed@simple.snap index cf2fa7c..2114563 100644 --- a/tests/cases/1-parsed@simple.snap +++ b/tests/cases/1-parsed@simple.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: parsed -input_file: tests/cases/simple.temple +input_file: tests/cases/simple.nomo --- ParsedTemplate { tokens: [ diff --git a/tests/cases/2-ast@identifiers.snap b/tests/cases/2-ast@identifiers.snap index abfc850..6a2ca03 100644 --- a/tests/cases/2-ast@identifiers.snap +++ b/tests/cases/2-ast@identifiers.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: ast -input_file: tests/cases/identifiers.temple +input_file: tests/cases/identifiers.nomo --- TemplateAst { root: [ diff --git a/tests/cases/2-ast@interpolation.snap b/tests/cases/2-ast@interpolation.snap index 2c2b869..78da4c0 100644 --- a/tests/cases/2-ast@interpolation.snap +++ b/tests/cases/2-ast@interpolation.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: ast -input_file: tests/cases/interpolation.temple +input_file: tests/cases/interpolation.nomo --- TemplateAst { root: [ diff --git a/tests/cases/2-ast@multiple.snap b/tests/cases/2-ast@multiple.snap index 5627af6..b2b9471 100644 --- a/tests/cases/2-ast@multiple.snap +++ b/tests/cases/2-ast@multiple.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: ast -input_file: tests/cases/multiple.temple +input_file: tests/cases/multiple.nomo --- TemplateAst { root: [ diff --git a/tests/cases/2-ast@simple.snap b/tests/cases/2-ast@simple.snap index 1fd3a24..cffaa71 100644 --- a/tests/cases/2-ast@simple.snap +++ b/tests/cases/2-ast@simple.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: ast -input_file: tests/cases/simple.temple +input_file: tests/cases/simple.nomo --- TemplateAst { root: [ diff --git a/tests/cases/3-instructions@identifiers.snap b/tests/cases/3-instructions@identifiers.snap index 482d6a6..bd18fe5 100644 --- a/tests/cases/3-instructions@identifiers.snap +++ b/tests/cases/3-instructions@identifiers.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: emit -input_file: tests/cases/identifiers.temple +input_file: tests/cases/identifiers.nomo --- [ LoadFromContextToSlot { diff --git a/tests/cases/3-instructions@interpolation.snap b/tests/cases/3-instructions@interpolation.snap index 116329e..d2acc12 100644 --- a/tests/cases/3-instructions@interpolation.snap +++ b/tests/cases/3-instructions@interpolation.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: emit -input_file: tests/cases/interpolation.temple +input_file: tests/cases/interpolation.nomo --- [ AppendContent { diff --git a/tests/cases/3-instructions@multiple.snap b/tests/cases/3-instructions@multiple.snap index 3e4513a..a65b11a 100644 --- a/tests/cases/3-instructions@multiple.snap +++ b/tests/cases/3-instructions@multiple.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: emit -input_file: tests/cases/multiple.temple +input_file: tests/cases/multiple.nomo --- [ AppendContent { diff --git a/tests/cases/3-instructions@simple.snap b/tests/cases/3-instructions@simple.snap index 512e4d3..976141e 100644 --- a/tests/cases/3-instructions@simple.snap +++ b/tests/cases/3-instructions@simple.snap @@ -1,7 +1,7 @@ --- source: tests/file_tests.rs expression: emit -input_file: tests/cases/simple.temple +input_file: tests/cases/simple.nomo --- [ AppendContent { diff --git a/tests/cases/4-output@identifiers.snap b/tests/cases/4-output@identifiers.snap index 67a3f6e..33a3457 100644 --- a/tests/cases/4-output@identifiers.snap +++ b/tests/cases/4-output@identifiers.snap @@ -1,6 +1,6 @@ --- source: tests/file_tests.rs expression: output -input_file: tests/cases/identifiers.temple +input_file: tests/cases/identifiers.nomo --- "Foo\nFoo\nFoo\nFoo\nFoo\nFoo" diff --git a/tests/cases/4-output@interpolation.snap b/tests/cases/4-output@interpolation.snap index f91df8c..f27078d 100644 --- a/tests/cases/4-output@interpolation.snap +++ b/tests/cases/4-output@interpolation.snap @@ -1,6 +1,6 @@ --- source: tests/file_tests.rs expression: output -input_file: tests/cases/interpolation.temple +input_file: tests/cases/interpolation.nomo --- "Hello! I'm Hemera" diff --git a/tests/cases/4-output@multiple.snap b/tests/cases/4-output@multiple.snap index 0808a5a..b6a763a 100644 --- a/tests/cases/4-output@multiple.snap +++ b/tests/cases/4-output@multiple.snap @@ -1,6 +1,6 @@ --- source: tests/file_tests.rs expression: output -input_file: tests/cases/multiple.temple +input_file: tests/cases/multiple.nomo --- "Hi there! My name is Hemera Green" diff --git a/tests/cases/4-output@simple.snap b/tests/cases/4-output@simple.snap index 31bd0cf..35ba658 100644 --- a/tests/cases/4-output@simple.snap +++ b/tests/cases/4-output@simple.snap @@ -1,6 +1,6 @@ --- source: tests/file_tests.rs expression: output -input_file: tests/cases/simple.temple +input_file: tests/cases/simple.nomo --- "Hello World!" diff --git a/tests/cases/identifiers.temple b/tests/cases/identifiers.nomo similarity index 100% rename from tests/cases/identifiers.temple rename to tests/cases/identifiers.nomo diff --git a/tests/cases/interpolation.temple b/tests/cases/interpolation.nomo similarity index 100% rename from tests/cases/interpolation.temple rename to tests/cases/interpolation.nomo diff --git a/tests/cases/multiple.temple b/tests/cases/multiple.nomo similarity index 100% rename from tests/cases/multiple.temple rename to tests/cases/multiple.nomo diff --git a/tests/cases/simple.temple b/tests/cases/simple.nomo similarity index 100% rename from tests/cases/simple.temple rename to tests/cases/simple.nomo diff --git a/tests/file_tests.rs b/tests/file_tests.rs index 0c60c54..85049e8 100644 --- a/tests/file_tests.rs +++ b/tests/file_tests.rs @@ -1,10 +1,10 @@ use std::collections::HashMap; -use temple::Context; +use nomo::Context; #[test] fn check_cases() { - insta::glob!("cases/*.temple", |path| { + insta::glob!("cases/*.nomo", |path| { let mut settings = insta::Settings::clone_current(); settings.set_snapshot_path("cases"); settings.set_snapshot_suffix(path.file_stem().unwrap().display().to_string()); @@ -27,19 +27,19 @@ fn check_cases() { context.insert(k, v); } - let parsed = temple::parser::parse(input.into()).unwrap(); + let parsed = nomo::parser::parse(input.into()).unwrap(); insta::assert_debug_snapshot!("1-parsed", parsed); - let ast = temple::ast::parse(parsed.tokens()).unwrap(); + let ast = nomo::ast::parse(parsed.tokens()).unwrap(); insta::assert_debug_snapshot!("2-ast", ast); - let emit = temple::emit::emit_machine(ast); + let emit = nomo::emit::emit_machine(ast); insta::assert_debug_snapshot!("3-instructions", emit); - let output = temple::eval::execute(&emit, &context).unwrap(); + let output = nomo::eval::execute(&emit, &context).unwrap(); insta::assert_debug_snapshot!("4-output", output); });