summaryrefslogtreecommitdiff
path: root/crimtag
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2026-08-19 10:06:25 -0700
committerMike Buland <mike@xagasoft.com>2026-08-19 10:06:25 -0700
commit5602585e7afe431f25e68f30ac54761db2a710e5 (patch)
tree94461a3d5eba1ce0a6402e2c07cdfc9facf21d76 /crimtag
parentba96bd8a4a1583edd3677dd613c89504d9ce88cf (diff)
downloaddeepcrow-5602585e7afe431f25e68f30ac54761db2a710e5.tar.gz
deepcrow-5602585e7afe431f25e68f30ac54761db2a710e5.tar.bz2
deepcrow-5602585e7afe431f25e68f30ac54761db2a710e5.tar.xz
deepcrow-5602585e7afe431f25e68f30ac54761db2a710e5.zip
Renamed to DeepCrow
Diffstat (limited to '')
-rw-r--r--deepcrow/Cargo.lock (renamed from crimtag/Cargo.lock)2
-rw-r--r--deepcrow/Cargo.toml (renamed from crimtag/Cargo.toml)2
-rw-r--r--deepcrow/src/context.rs (renamed from crimtag/src/context.rs)10
-rw-r--r--deepcrow/src/error.rs (renamed from crimtag/src/error.rs)10
-rw-r--r--deepcrow/src/lexer.rs (renamed from crimtag/src/lexer.rs)0
-rw-r--r--deepcrow/src/lib.rs (renamed from crimtag/src/lib.rs)42
-rw-r--r--deepcrow/src/parser.rs (renamed from crimtag/src/parser.rs)98
-rw-r--r--deepcrow/src/position.rs (renamed from crimtag/src/position.rs)0
8 files changed, 82 insertions, 82 deletions
diff --git a/crimtag/Cargo.lock b/deepcrow/Cargo.lock
index f7e6686..9bfb874 100644
--- a/crimtag/Cargo.lock
+++ b/deepcrow/Cargo.lock
@@ -3,5 +3,5 @@
3version = 4 3version = 4
4 4
5[[package]] 5[[package]]
6name = "crimtag" 6name = "deepcrow"
7version = "0.1.0" 7version = "0.1.0"
diff --git a/crimtag/Cargo.toml b/deepcrow/Cargo.toml
index e48d065..de3156a 100644
--- a/crimtag/Cargo.toml
+++ b/deepcrow/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2name = "crimtag" 2name = "deepcrow"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2024" 4edition = "2024"
5 5
diff --git a/crimtag/src/context.rs b/deepcrow/src/context.rs
index a922fd8..4a22cdd 100644
--- a/crimtag/src/context.rs
+++ b/deepcrow/src/context.rs
@@ -1,7 +1,7 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2use std::fmt; 2use std::fmt;
3 3
4use crate::error::CrimResult; 4use crate::error::Result;
5 5
6use crate::{Identifier,IdentifierValue}; 6use crate::{Identifier,IdentifierValue};
7 7
@@ -19,7 +19,7 @@ impl<'a> MappedStructure<'a> for Context {
19 19
20pub trait MappedList<'a> { 20pub trait MappedList<'a> {
21 fn get_index(&'a self, id: usize) -> Option<MappedValue<'a>>; 21 fn get_index(&'a self, id: usize) -> Option<MappedValue<'a>>;
22 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> CrimResult<()>) -> CrimResult<String>; 22 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> Result<()>) -> Result<String>;
23} 23}
24 24
25impl<'a, T: MappedStructure<'a>> MappedList<'a> for Vec<T> { 25impl<'a, T: MappedStructure<'a>> MappedList<'a> for Vec<T> {
@@ -31,7 +31,7 @@ impl<'a, T: MappedStructure<'a>> MappedList<'a> for Vec<T> {
31 } 31 }
32 } 32 }
33 33
34 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> CrimResult<()>) -> CrimResult<String> { 34 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> Result<()>) -> Result<String> {
35 let mut buf = String::new(); 35 let mut buf = String::new();
36 for i in self { 36 for i in self {
37 func( &MappedValue::Struct(i), &mut buf )?; 37 func( &MappedValue::Struct(i), &mut buf )?;
@@ -49,7 +49,7 @@ impl<'a> MappedList<'a> for Vec<Value> {
49 } 49 }
50 } 50 }
51 51
52 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> CrimResult<()>) -> CrimResult<String> { 52 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> Result<()>) -> Result<String> {
53 let mut buf = String::new(); 53 let mut buf = String::new();
54 for i in self { 54 for i in self {
55 func( &Into::<MappedValue<'a>>::into( i ), &mut buf )?; 55 func( &Into::<MappedValue<'a>>::into( i ), &mut buf )?;
@@ -67,7 +67,7 @@ impl<'a> MappedList<'a> for Vec<MappedValue<'a>> {
67 } 67 }
68 } 68 }
69 69
70 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> CrimResult<()>) -> CrimResult<String> { 70 fn for_each(&'a self, func: &dyn Fn(&MappedValue<'a>, &mut String) -> Result<()>) -> Result<String> {
71 let mut buf = String::new(); 71 let mut buf = String::new();
72 for i in self { 72 for i in self {
73 func( i, &mut buf )?; 73 func( i, &mut buf )?;
diff --git a/crimtag/src/error.rs b/deepcrow/src/error.rs
index bbb5d6f..8fe21f0 100644
--- a/crimtag/src/error.rs
+++ b/deepcrow/src/error.rs
@@ -5,12 +5,12 @@ use std::fmt;
5use crate::position::*; 5use crate::position::*;
6 6
7#[derive(Debug)] 7#[derive(Debug)]
8pub struct CrimError { 8pub struct DeepCrowError {
9 position: Position, 9 position: Position,
10 what: String, 10 what: String,
11} 11}
12 12
13impl CrimError { 13impl DeepCrowError {
14 pub fn parse( position: Position, what: String ) -> Self { 14 pub fn parse( position: Position, what: String ) -> Self {
15 Self { 15 Self {
16 position, 16 position,
@@ -48,12 +48,12 @@ impl CrimError {
48 } 48 }
49} 49}
50 50
51impl fmt::Display for CrimError { 51impl fmt::Display for DeepCrowError {
52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 52 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53 write!(f, "Error parsing input: {}", "yeah") 53 write!(f, "Error parsing input: {}", "yeah")
54 } 54 }
55} 55}
56 56
57impl Error for CrimError { } 57impl Error for DeepCrowError { }
58 58
59pub type CrimResult<T> = Result<T, CrimError>; 59pub type Result<T> = std::result::Result<T, DeepCrowError>;
diff --git a/crimtag/src/lexer.rs b/deepcrow/src/lexer.rs
index d4d39e9..d4d39e9 100644
--- a/crimtag/src/lexer.rs
+++ b/deepcrow/src/lexer.rs
diff --git a/crimtag/src/lib.rs b/deepcrow/src/lib.rs
index 0fe0e4e..b10cd03 100644
--- a/crimtag/src/lib.rs
+++ b/deepcrow/src/lib.rs
@@ -9,14 +9,14 @@ mod position;
9mod error; 9mod error;
10pub mod context; 10pub mod context;
11 11
12pub use derive::CrimtagMappable; 12pub use derive::DeepCrowMappable;
13 13
14pub use error::{CrimError,CrimResult}; 14pub use error::{DeepCrowError,Result};
15pub use position::*; 15pub use position::*;
16pub use context::{Context,Value,MappedStructure,StatefulContext,MappedValue,MappedList,MappedHash}; 16pub use context::{Context,Value,MappedStructure,StatefulContext,MappedValue,MappedList,MappedHash};
17 17
18#[derive(Debug)] 18#[derive(Debug)]
19pub struct Crimtag { 19pub struct DeepCrow {
20 views: HashMap<String, View>, 20 views: HashMap<String, View>,
21 sources: Vec<ViewSource>, 21 sources: Vec<ViewSource>,
22} 22}
@@ -43,7 +43,7 @@ struct View {
43} 43}
44 44
45impl View { 45impl View {
46 fn process(&self, input: &dyn for<'a> MappedStructure<'a>) -> CrimResult<Context> { 46 fn process(&self, input: &dyn for<'a> MappedStructure<'a>) -> Result<Context> {
47 let mut out_vars = Context::new(); 47 let mut out_vars = Context::new();
48 for output in &self.outputs { 48 for output in &self.outputs {
49 let mut buf = String::new(); 49 let mut buf = String::new();
@@ -80,7 +80,7 @@ pub enum IdentifierValue {
80 80
81pub type Identifier = Vec<IdentifierValue>; 81pub type Identifier = Vec<IdentifierValue>;
82 82
83impl Crimtag { 83impl DeepCrow {
84 pub fn new() -> Self { 84 pub fn new() -> Self {
85 Self { 85 Self {
86 views: HashMap::new(), 86 views: HashMap::new(),
@@ -101,7 +101,7 @@ impl Crimtag {
101 idx 101 idx
102 } 102 }
103 103
104 pub fn load_file(&mut self, path: &Path) -> Result<(),Box::<dyn Error>> { 104 pub fn load_file(&mut self, path: &Path) -> std::result::Result<(),Box::<dyn Error>> {
105 let time = if let Ok(meta) = path.metadata() { 105 let time = if let Ok(meta) = path.metadata() {
106 if let Ok(t) = meta.modified() { 106 if let Ok(t) = meta.modified() {
107 t 107 t
@@ -129,13 +129,13 @@ impl Crimtag {
129 Ok(()) 129 Ok(())
130 } 130 }
131 131
132 pub fn load_static(&mut self, data: &str) -> CrimResult<()> { 132 pub fn load_static(&mut self, data: &str) -> Result<()> {
133 let source_id = self.id_source( &ViewSource::Static ); 133 let source_id = self.id_source( &ViewSource::Static );
134 let p = parser::Parser::new(); 134 let p = parser::Parser::new();
135 self.register_views( p.parse( &data, source_id )? ) 135 self.register_views( p.parse( &data, source_id )? )
136 } 136 }
137 137
138 pub fn load_external(&mut self, key: &str, data: &str) -> CrimResult<()> { 138 pub fn load_external(&mut self, key: &str, data: &str) -> Result<()> {
139 let source_id = self.id_source( 139 let source_id = self.id_source(
140 &ViewSource::External{ key: key.to_string()} 140 &ViewSource::External{ key: key.to_string()}
141 ); 141 );
@@ -146,7 +146,7 @@ impl Crimtag {
146 ) 146 )
147 } 147 }
148 148
149 fn register_views(&mut self, views: Vec<View>) -> CrimResult<()> { 149 fn register_views(&mut self, views: Vec<View>) -> Result<()> {
150 for view in views { 150 for view in views {
151 self.views.insert( view.name.clone(), view ); 151 self.views.insert( view.name.clone(), view );
152 } 152 }
@@ -165,15 +165,15 @@ impl Crimtag {
165 } 165 }
166 } 166 }
167 167
168 pub fn render_partial(&self, view: &str, input: &dyn for<'a> MappedStructure<'a> ) -> CrimResult<Context> { 168 pub fn render_partial(&self, view: &str, input: &dyn for<'a> MappedStructure<'a> ) -> Result<Context> {
169 if let Some(view) = self.views.get(view) { 169 if let Some(view) = self.views.get(view) {
170 return view.process( input ) 170 return view.process( input )
171 } else { 171 } else {
172 return Err(CrimError::other("No such view found".into())); 172 return Err(DeepCrowError::other("No such view found".into()));
173 } 173 }
174 } 174 }
175 175
176 pub fn render(&self, view: &str, input: &dyn for<'a> MappedStructure<'a> ) -> CrimResult<String> { 176 pub fn render(&self, view: &str, input: &dyn for<'a> MappedStructure<'a> ) -> Result<String> {
177 if let Some(view) = self.views.get( view ) { 177 if let Some(view) = self.views.get( view ) {
178 //println!("::Token tree::\n{:?}", view ); 178 //println!("::Token tree::\n{:?}", view );
179 let mut output = view.process( input )?; 179 let mut output = view.process( input )?;
@@ -185,17 +185,17 @@ impl Crimtag {
185 185
186 Ok(s) 186 Ok(s)
187 } else { 187 } else {
188 Err(CrimError::other("No content found in root layout.".into())) 188 Err(DeepCrowError::other("No content found in root layout.".into()))
189 } 189 }
190 } 190 }
191 191
192 } else { 192 } else {
193 Err(CrimError::other("No such view found".into())) 193 Err(DeepCrowError::other("No such view found".into()))
194 } 194 }
195 } 195 }
196} 196}
197 197
198fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Token>, buf: &mut String) -> CrimResult<()> { 198fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Token>, buf: &mut String) -> Result<()> {
199 for token in tokens { 199 for token in tokens {
200 match token { 200 match token {
201 Token::Loop(ident,code) => { 201 Token::Loop(ident,code) => {
@@ -320,7 +320,7 @@ mod tests {
320 320
321 #[test] 321 #[test]
322 fn parsing() { 322 fn parsing() {
323 let mut ct = Crimtag::new(); 323 let mut ct = DeepCrow::new();
324 if let Err(e) = ct.load_static(r#"Here is a sample 324 if let Err(e) = ct.load_static(r#"Here is a sample
325[|view "index" theme="standard"|><html><body>Hi</body></html><|view|] 325[|view "index" theme="standard"|><html><body>Hi</body></html><|view|]
326That was fun! now a placeholder: [|view "placeholder"|] and now one with an implicit [|view "simple"|>Body -> [|show content|] <- and end<|view|] aoeu 326That was fun! now a placeholder: [|view "placeholder"|] and now one with an implicit [|view "simple"|>Body -> [|show content|] <- and end<|view|] aoeu
@@ -360,8 +360,8 @@ Now with explicit outputs:
360 } 360 }
361 361
362 #[test] 362 #[test]
363 fn loops() -> Result<(),CrimError> { 363 fn loops() -> Result<()> {
364 let mut ct = Crimtag::new(); 364 let mut ct = DeepCrow::new();
365 ct.load_static(r#"Looping code: 365 ct.load_static(r#"Looping code:
366[|view "index"|>We will enumerate people here:[|loop people|> 366[|view "index"|>We will enumerate people here:[|loop people|>
367 - [|show last_name|], [|show first_name|][|if show_title |>: [|show title|] <|else|> **title redacted** <|if|] ::>[|loop tags|> [|show tag|]<|loop|] <:: <|loop|] 367 - [|show last_name|], [|show first_name|][|if show_title |>: [|show title|] <|else|> **title redacted** <|if|] ::>[|loop tags|> [|show tag|]<|loop|] <:: <|loop|]
@@ -419,8 +419,8 @@ Now with explicit outputs:
419 } 419 }
420 420
421 #[test] 421 #[test]
422 fn conditional() -> Result<(),CrimError> { 422 fn conditional() -> Result<()> {
423 let mut ct = Crimtag::new(); 423 let mut ct = DeepCrow::new();
424 ct.load_static(r#"Hi there 424 ct.load_static(r#"Hi there
425[|view "index"|> 425[|view "index"|>
426 Color: [|if is_red|> red <|elif is_blue |> blue <|else|> green <|if|] 426 Color: [|if is_red|> red <|elif is_blue |> blue <|else|> green <|if|]
@@ -525,7 +525,7 @@ Now with explicit outputs:
525 } 525 }
526 526
527 #[test] 527 #[test]
528 fn custom() -> Result<(), CrimError> { 528 fn custom() -> Result<()> {
529 let page = Page::new(); 529 let page = Page::new();
530 530
531 println!("{:?}", 531 println!("{:?}",
diff --git a/crimtag/src/parser.rs b/deepcrow/src/parser.rs
index 4f7ff6a..fbfc44e 100644
--- a/crimtag/src/parser.rs
+++ b/deepcrow/src/parser.rs
@@ -36,9 +36,9 @@ impl<'a> Context<'a> {
36 } 36 }
37 37
38 /* 38 /*
39 pub fn check_unwrapped<T: Fn( &SymbolType, &SymbolType ) -> bool>(&self, context: &str, f: T) -> CrimResult<bool> { 39 pub fn check_unwrapped<T: Fn( &SymbolType, &SymbolType ) -> bool>(&self, context: &str, f: T) -> Result<bool> {
40 if self.cur().is_none() || self.peek().is_none() { 40 if self.cur().is_none() || self.peek().is_none() {
41 Err(CrimError::eos( context )) 41 Err(DeepCrowError::eos( context ))
42 } else { 42 } else {
43 Ok(f( self.cur().unwrap().symbol(), self.peek().unwrap().symbol())) 43 Ok(f( self.cur().unwrap().symbol(), self.peek().unwrap().symbol()))
44 } 44 }
@@ -51,21 +51,21 @@ impl<'a> Context<'a> {
51} 51}
52 52
53trait SymbolHelper { 53trait SymbolHelper {
54 fn is<T: Fn( &SymbolType ) -> bool>(&self, context: &str, f: T ) -> CrimResult<bool>; 54 fn is<T: Fn( &SymbolType ) -> bool>(&self, context: &str, f: T ) -> Result<bool>;
55 #[allow(dead_code)] 55 #[allow(dead_code)]
56 fn is_valid_tag_name(&self) -> CrimResult<bool>; 56 fn is_valid_tag_name(&self) -> Result<bool>;
57} 57}
58 58
59impl<'a> SymbolHelper for Option<Symbol<'a>> { 59impl<'a> SymbolHelper for Option<Symbol<'a>> {
60 fn is<T: Fn( &SymbolType ) -> bool>(&self, context: &str, f: T ) -> CrimResult<bool> { 60 fn is<T: Fn( &SymbolType ) -> bool>(&self, context: &str, f: T ) -> Result<bool> {
61 if let Some(st) = self { 61 if let Some(st) = self {
62 Ok(f( &st.symbol() )) 62 Ok(f( &st.symbol() ))
63 } else { 63 } else {
64 Err(CrimError::eos( context )) 64 Err(DeepCrowError::eos( context ))
65 } 65 }
66 } 66 }
67 67
68 fn is_valid_tag_name(&self) -> CrimResult<bool> { 68 fn is_valid_tag_name(&self) -> Result<bool> {
69 if let Some(st) = self { 69 if let Some(st) = self {
70 Ok(match st.symbol() { 70 Ok(match st.symbol() {
71 SymbolType::Token(_) | 71 SymbolType::Token(_) |
@@ -79,7 +79,7 @@ impl<'a> SymbolHelper for Option<Symbol<'a>> {
79 _ => false 79 _ => false
80 }) 80 })
81 } else { 81 } else {
82 Err(CrimError::parse( 82 Err(DeepCrowError::parse(
83 Position::none(), 83 Position::none(),
84 "Unexpeceted end of stream.".to_string() 84 "Unexpeceted end of stream.".to_string()
85 )) 85 ))
@@ -183,17 +183,17 @@ impl Parser {
183 } 183 }
184 } 184 }
185 185
186 fn lex_error<T>(&self, error: &Symbol) -> CrimResult<T> { 186 fn lex_error<T>(&self, error: &Symbol) -> Result<T> {
187 if let SymbolType::Error{what} = error.symbol() { 187 if let SymbolType::Error{what} = error.symbol() {
188 Err(CrimError::parse( *error.start(), 188 Err(DeepCrowError::parse( *error.start(),
189 format!("What: {:?}", *what) 189 format!("What: {:?}", *what)
190 )) 190 ))
191 } else { 191 } else {
192 Err(CrimError::parse( Position::none(), "Not an error?".into())) 192 Err(DeepCrowError::parse( Position::none(), "Not an error?".into()))
193 } 193 }
194 } 194 }
195 195
196 pub fn parse(&self, src: &str, source: usize ) -> CrimResult<Vec<View>> { 196 pub fn parse(&self, src: &str, source: usize ) -> Result<Vec<View>> {
197 let ll = Lexer::new( src ); 197 let ll = Lexer::new( src );
198 let mut ctx = Context::new( ll, source ); 198 let mut ctx = Context::new( ll, source );
199 199
@@ -201,7 +201,7 @@ impl Parser {
201 self.p_input( &mut ctx ) 201 self.p_input( &mut ctx )
202 } 202 }
203 203
204 fn p_input(&self, ctx: &mut Context ) -> CrimResult<Vec<View>> { 204 fn p_input(&self, ctx: &mut Context ) -> Result<Vec<View>> {
205 let mut tags = Vec::new(); 205 let mut tags = Vec::new();
206 loop { 206 loop {
207 if ctx.cur().is_none() { 207 if ctx.cur().is_none() {
@@ -218,7 +218,7 @@ impl Parser {
218 self.lex_error( &ctx.cur().unwrap() )?; 218 self.lex_error( &ctx.cur().unwrap() )?;
219 } 219 }
220 _ => { 220 _ => {
221 return Err(CrimError::parse( 221 return Err(DeepCrowError::parse(
222 *ctx.cur().unwrap().start(), 222 *ctx.cur().unwrap().start(),
223 format!("Unexpected symbol {:?} found looking for tags.", ctx.cur().unwrap().symbol() ) 223 format!("Unexpected symbol {:?} found looking for tags.", ctx.cur().unwrap().symbol() )
224 )); 224 ));
@@ -235,7 +235,7 @@ impl Parser {
235 let BuildResult::View(view) = tag.build( ctx )? { 235 let BuildResult::View(view) = tag.build( ctx )? {
236 views.push( view ); 236 views.push( view );
237 } else { 237 } else {
238 return Err(CrimError::parse( 238 return Err(DeepCrowError::parse(
239 start_pos, 239 start_pos,
240 format!("Expected view at root, found {:?}", name ) 240 format!("Expected view at root, found {:?}", name )
241 )); 241 ));
@@ -244,7 +244,7 @@ impl Parser {
244 Ok(views) 244 Ok(views)
245 } 245 }
246 246
247 fn parse_tag<'a>(&self, ctx: &mut Context<'a>) -> CrimResult<TagBuilder<'a>> { 247 fn parse_tag<'a>(&self, ctx: &mut Context<'a>) -> Result<TagBuilder<'a>> {
248 let start_sym = ctx.cur().unwrap(); 248 let start_sym = ctx.cur().unwrap();
249 let mut tb = TagBuilder::new(&start_sym); 249 let mut tb = TagBuilder::new(&start_sym);
250 250
@@ -258,14 +258,14 @@ impl Parser {
258 tb.set_name( name_sym ); 258 tb.set_name( name_sym );
259 } 259 }
260 _ => { 260 _ => {
261 return Err(CrimError::parse( 261 return Err(DeepCrowError::parse(
262 *ctx.cur().unwrap().start(), 262 *ctx.cur().unwrap().start(),
263 "Unexpected symbol".to_string() 263 "Unexpected symbol".to_string()
264 )); 264 ));
265 } 265 }
266 } 266 }
267 } else { 267 } else {
268 return Err(CrimError::eos("tag type")); 268 return Err(DeepCrowError::eos("tag type"));
269 } 269 }
270 270
271 if tb.can_have_params() || tb.can_have_expr() { 271 if tb.can_have_params() || tb.can_have_expr() {
@@ -281,7 +281,7 @@ impl Parser {
281 tb.set_end( &end_sym )?; 281 tb.set_end( &end_sym )?;
282 } 282 }
283 _ => { 283 _ => {
284 return Err(CrimError::parse( 284 return Err(DeepCrowError::parse(
285 *end_sym.start(), 285 *end_sym.start(),
286 format!("Unexpected symbol {:?} looking for end of tag.", end_sym.symbol()) 286 format!("Unexpected symbol {:?} looking for end of tag.", end_sym.symbol())
287 )); 287 ));
@@ -294,14 +294,14 @@ impl Parser {
294 Ok(tb) 294 Ok(tb)
295 } 295 }
296 296
297 fn parse_tag_set<'a>(&self, ctx: &mut Context<'a>, mut base: TagBuilder<'a>) -> CrimResult<TagBuilder<'a>> { 297 fn parse_tag_set<'a>(&self, ctx: &mut Context<'a>, mut base: TagBuilder<'a>) -> Result<TagBuilder<'a>> {
298 if base.is_unary() { 298 if base.is_unary() {
299 return Ok(base); 299 return Ok(base);
300 } 300 }
301 301
302 loop { 302 loop {
303 if ctx.cur().is_none() { 303 if ctx.cur().is_none() {
304 return Err(CrimError::eos(format!("close tag for {:?}", base.name()).as_str())); 304 return Err(DeepCrowError::eos(format!("close tag for {:?}", base.name()).as_str()));
305 } 305 }
306 match ctx.cur().unwrap().symbol() { 306 match ctx.cur().unwrap().symbol() {
307 SymbolType::Text(s) => { 307 SymbolType::Text(s) => {
@@ -326,7 +326,7 @@ impl Parser {
326 tb.is_name(base.name().unwrap().symbol()) { 326 tb.is_name(base.name().unwrap().symbol()) {
327 return Ok(base); 327 return Ok(base);
328 } else { 328 } else {
329 return Err(CrimError::parse( 329 return Err(DeepCrowError::parse(
330 *tb.name().unwrap().start(), 330 *tb.name().unwrap().start(),
331 format!("Found {:?} looking for close of {:?}", tb.name().unwrap().symbol(), base.name().unwrap().symbol()) 331 format!("Found {:?} looking for close of {:?}", tb.name().unwrap().symbol(), base.name().unwrap().symbol())
332 )); 332 ));
@@ -336,7 +336,7 @@ impl Parser {
336 base.add_child(Entry::TagBuilder(tb)); 336 base.add_child(Entry::TagBuilder(tb));
337 } 337 }
338 TagType::Unknown => { 338 TagType::Unknown => {
339 return Err(CrimError::broken(base.start_pos(), "Found unknown tag when looking for something else.")); 339 return Err(DeepCrowError::broken(base.start_pos(), "Found unknown tag when looking for something else."));
340 } 340 }
341 } 341 }
342 } 342 }
@@ -344,7 +344,7 @@ impl Parser {
344 return self.lex_error( &ctx.cur().unwrap() ); 344 return self.lex_error( &ctx.cur().unwrap() );
345 } 345 }
346 _ => { 346 _ => {
347 return Err(CrimError::parse( 347 return Err(DeepCrowError::parse(
348 *ctx.cur().unwrap().start(), 348 *ctx.cur().unwrap().start(),
349 format!("Unexpected token: {:?}", ctx.cur().unwrap().symbol()), 349 format!("Unexpected token: {:?}", ctx.cur().unwrap().symbol()),
350 )); 350 ));
@@ -353,10 +353,10 @@ impl Parser {
353 } 353 }
354 } 354 }
355 355
356 fn parse_tag_params(&self, ctx: &mut Context, tb: &mut TagBuilder ) -> CrimResult<()> { 356 fn parse_tag_params(&self, ctx: &mut Context, tb: &mut TagBuilder ) -> Result<()> {
357 loop { 357 loop {
358 if ctx.cur().is_none() { 358 if ctx.cur().is_none() {
359 return Err(CrimError::eos("tag parameters")); 359 return Err(DeepCrowError::eos("tag parameters"));
360 } 360 }
361 match ctx.cur().unwrap().symbol() { 361 match ctx.cur().unwrap().symbol() {
362 SymbolType::Literal(s) => { 362 SymbolType::Literal(s) => {
@@ -377,7 +377,7 @@ impl Parser {
377 Ok(()) 377 Ok(())
378 } 378 }
379 379
380 fn parse_identifier(&self, ctx: &mut Context ) -> CrimResult<ParamValue> { 380 fn parse_identifier(&self, ctx: &mut Context ) -> Result<ParamValue> {
381 let mut id = Identifier::new(); 381 let mut id = Identifier::new();
382 382
383 if ctx.cur().is("identifier",|s| matches!( s, SymbolType::Sharp))? { 383 if ctx.cur().is("identifier",|s| matches!( s, SymbolType::Sharp))? {
@@ -390,7 +390,7 @@ impl Parser {
390 id.push( IdentifierValue::Name(s.to_string()) ); 390 id.push( IdentifierValue::Name(s.to_string()) );
391 } 391 }
392 } else { 392 } else {
393 return Err(CrimError::parse( ctx.cur().unwrap().start().clone(), format!("Expeceted identifier, found {:?}", ctx.cur().unwrap().symbol() ) ) ); 393 return Err(DeepCrowError::parse( ctx.cur().unwrap().start().clone(), format!("Expeceted identifier, found {:?}", ctx.cur().unwrap().symbol() ) ) );
394 } 394 }
395 395
396 if !ctx.next().is("identifier seperator",|s| *s == SymbolType::Period )? { 396 if !ctx.next().is("identifier seperator",|s| *s == SymbolType::Period )? {
@@ -402,10 +402,10 @@ impl Parser {
402 Ok(ParamValue::Identifier(id)) 402 Ok(ParamValue::Identifier(id))
403 } 403 }
404 404
405 fn parse_tag_props(&self, ctx: &mut Context, tb: &mut TagBuilder ) -> CrimResult<()> { 405 fn parse_tag_props(&self, ctx: &mut Context, tb: &mut TagBuilder ) -> Result<()> {
406 loop { 406 loop {
407 if ctx.cur().is_none() { 407 if ctx.cur().is_none() {
408 return Err(CrimError::eos("tag properties")); 408 return Err(DeepCrowError::eos("tag properties"));
409 } 409 }
410 if let SymbolType::Token(s) = ctx.cur().unwrap().symbol() { 410 if let SymbolType::Token(s) = ctx.cur().unwrap().symbol() {
411 if ctx.peek().is_some_and(|s|s.check_type(|t| matches!(t,SymbolType::Equals))) { 411 if ctx.peek().is_some_and(|s|s.check_type(|t| matches!(t,SymbolType::Equals))) {
@@ -414,7 +414,7 @@ impl Parser {
414 let SymbolType::Literal(lv) = sym.symbol() { 414 let SymbolType::Literal(lv) = sym.symbol() {
415 tb.add_prop( s.to_string(), lv.to_string() ); 415 tb.add_prop( s.to_string(), lv.to_string() );
416 } else { 416 } else {
417 return Err(CrimError::parse(Position::none(),"Expected quoted literal string".to_string())); 417 return Err(DeepCrowError::parse(Position::none(),"Expected quoted literal string".to_string()));
418 } 418 }
419 } else { 419 } else {
420 break; 420 break;
@@ -447,8 +447,8 @@ type EntryList<'a> = Vec<Entry<'a>>;
447 447
448trait EntryListConverter { 448trait EntryListConverter {
449 fn has_outputs(&self) -> bool; 449 fn has_outputs(&self) -> bool;
450 fn to_outputs(&mut self, ctx: &mut Context ) -> CrimResult<Vec<Output>>; 450 fn to_outputs(&mut self, ctx: &mut Context ) -> Result<Vec<Output>>;
451 fn to_tokens(&mut self, ctx: &mut Context) -> CrimResult<Vec<Token>>; 451 fn to_tokens(&mut self, ctx: &mut Context) -> Result<Vec<Token>>;
452} 452}
453 453
454impl<'a> EntryListConverter for EntryList<'a> { 454impl<'a> EntryListConverter for EntryList<'a> {
@@ -463,7 +463,7 @@ impl<'a> EntryListConverter for EntryList<'a> {
463 ) 463 )
464 } 464 }
465 465
466 fn to_outputs(&mut self, ctx: &mut Context) -> CrimResult<Vec<Output>> { 466 fn to_outputs(&mut self, ctx: &mut Context) -> Result<Vec<Output>> {
467 let mut outputs = Vec::new(); 467 let mut outputs = Vec::new();
468 468
469 if self.has_outputs() { 469 if self.has_outputs() {
@@ -489,7 +489,7 @@ impl<'a> EntryListConverter for EntryList<'a> {
489 Ok(outputs) 489 Ok(outputs)
490 } 490 }
491 491
492 fn to_tokens(&mut self, ctx: &mut Context) -> CrimResult<Vec<Token>> { 492 fn to_tokens(&mut self, ctx: &mut Context) -> Result<Vec<Token>> {
493 let mut tokens : Vec<Token> = Vec::new(); 493 let mut tokens : Vec<Token> = Vec::new();
494 for e in self.drain(..) { 494 for e in self.drain(..) {
495 match e { 495 match e {
@@ -500,7 +500,7 @@ impl<'a> EntryListConverter for EntryList<'a> {
500 if let BuildResult::Token(token) = tb.build(ctx)? { 500 if let BuildResult::Token(token) = tb.build(ctx)? {
501 tokens.push( token ); 501 tokens.push( token );
502 } else { 502 } else {
503 return Err(CrimError::broken( Position::none(), "Non-token result built.")); 503 return Err(DeepCrowError::broken( Position::none(), "Non-token result built."));
504 } 504 }
505 } 505 }
506 } 506 }
@@ -545,14 +545,14 @@ impl<'a> TagBuilder<'a> {
545 } 545 }
546 } 546 }
547 547
548 pub fn set_end(&mut self, end: &Symbol) -> CrimResult<()> { 548 pub fn set_end(&mut self, end: &Symbol) -> Result<()> {
549 if *self.start.symbol() == SymbolType::StartFlat { 549 if *self.start.symbol() == SymbolType::StartFlat {
550 if *end.symbol() == SymbolType::EndFlat { 550 if *end.symbol() == SymbolType::EndFlat {
551 self.tag_type = TagType::Unary; 551 self.tag_type = TagType::Unary;
552 } else if *end.symbol() == SymbolType::EndPoint { 552 } else if *end.symbol() == SymbolType::EndPoint {
553 self.tag_type = TagType::MultinaryOpen; 553 self.tag_type = TagType::MultinaryOpen;
554 } else { 554 } else {
555 return Err(CrimError::broken( *end.start(), "Invalid bracket token type.")); 555 return Err(DeepCrowError::broken( *end.start(), "Invalid bracket token type."));
556 } 556 }
557 } else if *self.start.symbol() == SymbolType::StartPoint { 557 } else if *self.start.symbol() == SymbolType::StartPoint {
558 if *end.symbol() == SymbolType::EndFlat { 558 if *end.symbol() == SymbolType::EndFlat {
@@ -560,10 +560,10 @@ impl<'a> TagBuilder<'a> {
560 } else if *end.symbol() == SymbolType::EndPoint { 560 } else if *end.symbol() == SymbolType::EndPoint {
561 self.tag_type = TagType::MultinaryMid; 561 self.tag_type = TagType::MultinaryMid;
562 } else { 562 } else {
563 return Err(CrimError::broken( *end.start(), "Invalid bracket token type.")); 563 return Err(DeepCrowError::broken( *end.start(), "Invalid bracket token type."));
564 } 564 }
565 } else { 565 } else {
566 return Err(CrimError::broken( *self.start.start(), "Invalid bracket token type.")); 566 return Err(DeepCrowError::broken( *self.start.start(), "Invalid bracket token type."));
567 } 567 }
568 Ok(()) 568 Ok(())
569 } 569 }
@@ -659,14 +659,14 @@ impl<'a> TagBuilder<'a> {
659 self.tag_type 659 self.tag_type
660 } 660 }
661 661
662 pub fn build(mut self, ctx: &mut Context ) -> CrimResult<BuildResult> { 662 pub fn build(mut self, ctx: &mut Context ) -> Result<BuildResult> {
663 if let Some(sym) = self.name { 663 if let Some(sym) = self.name {
664 match sym.symbol() { 664 match sym.symbol() {
665 SymbolType::View => { 665 SymbolType::View => {
666 let name = if let ParamValue::Literal(s) = self.params.swap_remove(0) { 666 let name = if let ParamValue::Literal(s) = self.params.swap_remove(0) {
667 s.to_string() 667 s.to_string()
668 } else { 668 } else {
669 return Err(CrimError::parse(Position::none(), "Expected string literal for view name.".to_string())); 669 return Err(DeepCrowError::parse(Position::none(), "Expected string literal for view name.".to_string()));
670 }; 670 };
671 Ok(BuildResult::View(View { 671 Ok(BuildResult::View(View {
672 name: name, 672 name: name,
@@ -680,7 +680,7 @@ impl<'a> TagBuilder<'a> {
680 let name = if let ParamValue::Literal(s) = self.params.swap_remove(0) { 680 let name = if let ParamValue::Literal(s) = self.params.swap_remove(0) {
681 s.to_string() 681 s.to_string()
682 } else { 682 } else {
683 return Err(CrimError::parse(Position::none(), "Expected string literal for output name.".into())); 683 return Err(DeepCrowError::parse(Position::none(), "Expected string literal for output name.".into()));
684 }; 684 };
685 Ok(BuildResult::Output(Output { 685 Ok(BuildResult::Output(Output {
686 name: name, 686 name: name,
@@ -692,7 +692,7 @@ impl<'a> TagBuilder<'a> {
692 = self.params.swap_remove(0) { 692 = self.params.swap_remove(0) {
693 id 693 id
694 } else { 694 } else {
695 return Err(CrimError::parse( 695 return Err(DeepCrowError::parse(
696 Position::none(), 696 Position::none(),
697 "Identifier for loop variable name.".into()) 697 "Identifier for loop variable name.".into())
698 ); 698 );
@@ -706,7 +706,7 @@ impl<'a> TagBuilder<'a> {
706 = self.params.swap_remove(0) { 706 = self.params.swap_remove(0) {
707 id 707 id
708 } else { 708 } else {
709 return Err(CrimError::parse( 709 return Err(DeepCrowError::parse(
710 Position::none(), 710 Position::none(),
711 "Identifier for show variable name.".into()) 711 "Identifier for show variable name.".into())
712 ); 712 );
@@ -718,7 +718,7 @@ impl<'a> TagBuilder<'a> {
718 = self.params.swap_remove(0) { 718 = self.params.swap_remove(0) {
719 id 719 id
720 } else { 720 } else {
721 return Err(CrimError::parse( 721 return Err(DeepCrowError::parse(
722 Position::none(), 722 Position::none(),
723 "Identifier for if variable name.".into()) 723 "Identifier for if variable name.".into())
724 ); 724 );
@@ -744,7 +744,7 @@ impl<'a> TagBuilder<'a> {
744 let id = if let ParamValue::Identifier(id) = self.params.swap_remove(0) { 744 let id = if let ParamValue::Identifier(id) = self.params.swap_remove(0) {
745 id 745 id
746 } else { 746 } else {
747 return Err(CrimError::parse( 747 return Err(DeepCrowError::parse(
748 Position::none(), 748 Position::none(),
749 "Identifier for elif variable name.".into()) 749 "Identifier for elif variable name.".into())
750 ); 750 );
@@ -775,11 +775,11 @@ impl<'a> TagBuilder<'a> {
775 Ok(BuildResult::Token(Token::If(Identifier::new(), self.children.to_tokens(ctx)?, self.chain.to_tokens(ctx)?))) 775 Ok(BuildResult::Token(Token::If(Identifier::new(), self.children.to_tokens(ctx)?, self.chain.to_tokens(ctx)?)))
776 } 776 }
777 _ => { 777 _ => {
778 Err(CrimError::parse( self.start_pos(), "Bad tag type".into())) 778 Err(DeepCrowError::parse( self.start_pos(), "Bad tag type".into()))
779 } 779 }
780 } 780 }
781 } else { 781 } else {
782 Err(CrimError::parse(self.start_pos(), "Bad tag type".into())) 782 Err(DeepCrowError::parse(self.start_pos(), "Bad tag type".into()))
783 } 783 }
784 } 784 }
785} 785}
diff --git a/crimtag/src/position.rs b/deepcrow/src/position.rs
index 24f5309..24f5309 100644
--- a/crimtag/src/position.rs
+++ b/deepcrow/src/position.rs