summaryrefslogtreecommitdiff
path: root/deepcrow/src/lib.rs
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2026-08-20 08:16:58 -0700
committerMike Buland <mike@xagasoft.com>2026-08-20 08:16:58 -0700
commit12c7b851d866401ac4a32c746ed237b051aa3dd3 (patch)
treed8c13033a295f9caa7d9ee388ca64272d5dcfa15 /deepcrow/src/lib.rs
parentd1e78b4a3454984db74ebf2a302a64b985ce6de4 (diff)
downloaddeepcrow-main.tar.gz
deepcrow-main.tar.bz2
deepcrow-main.tar.xz
deepcrow-main.zip
Making progress cleaning up.HEADmain
Diffstat (limited to 'deepcrow/src/lib.rs')
-rw-r--r--deepcrow/src/lib.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/deepcrow/src/lib.rs b/deepcrow/src/lib.rs
index b9a4ffe..969adf0 100644
--- a/deepcrow/src/lib.rs
+++ b/deepcrow/src/lib.rs
@@ -58,16 +58,16 @@ impl View {
58#[derive(Debug)] 58#[derive(Debug)]
59struct Output { 59struct Output {
60 name: String, 60 name: String,
61 code: Vec<Token>, 61 code: Vec<Symbol>,
62} 62}
63 63
64type Properties = HashMap<String, String>; 64type Properties = HashMap<String, String>;
65 65
66#[derive(Debug)] 66#[derive(Debug)]
67enum Token { 67enum Symbol {
68 Loop(Identifier, Vec<Token>), 68 Loop(Identifier, Vec<Symbol>),
69 Show(Identifier,Properties), 69 Show(Identifier,Properties),
70 If(Identifier, Vec<Token>, Vec<Token>), 70 If(Identifier, Vec<Symbol>, Vec<Symbol>),
71 Text(String), 71 Text(String),
72} 72}
73 73
@@ -175,7 +175,7 @@ impl DeepCrow {
175 175
176 pub fn render(&self, view: &str, input: &dyn for<'a> MappedStructure<'a> ) -> Result<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!("::Symbol tree::\n{:?}", view );
179 let mut output = view.process( input )?; 179 let mut output = view.process( input )?;
180 if let Some(l) = &view.layout { 180 if let Some(l) = &view.layout {
181 self.render( l, &output ) 181 self.render( l, &output )
@@ -195,10 +195,10 @@ impl DeepCrow {
195 } 195 }
196} 196}
197 197
198fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Token>, buf: &mut String) -> Result<()> { 198fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Symbol>, 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 Symbol::Loop(ident,code) => {
202 //println!("!!! Loop over: {:?} {:?}", ident, input.get_value( &ident )); 202 //println!("!!! Loop over: {:?} {:?}", ident, input.get_value( &ident ));
203 if let Some(value) = input.get_value( &ident ) && 203 if let Some(value) = input.get_value( &ident ) &&
204 let MappedValue::List(list) = value { 204 let MappedValue::List(list) = value {
@@ -213,7 +213,7 @@ fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Token>, buf: &mut String)
213 buf.push_str( &output ); 213 buf.push_str( &output );
214 } 214 }
215 } 215 }
216 Token::If(ident,code,other) => { 216 Symbol::If(ident,code,other) => {
217 if let Some(value) = input.get_value( &ident ) && 217 if let Some(value) = input.get_value( &ident ) &&
218 let MappedValue::Bool(b) = value && b { 218 let MappedValue::Bool(b) = value && b {
219 exec(input, code, buf)? 219 exec(input, code, buf)?
@@ -221,7 +221,7 @@ fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Token>, buf: &mut String)
221 exec(input, other, buf)? 221 exec(input, other, buf)?
222 } 222 }
223 } 223 }
224 Token::Show(ident,p) => { 224 Symbol::Show(ident,p) => {
225 let format = if let Some(s) = p.get("format") { 225 let format = if let Some(s) = p.get("format") {
226 s 226 s
227 } else { 227 } else {
@@ -289,7 +289,7 @@ fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec<Token>, buf: &mut String)
289 } 289 }
290 } 290 }
291 } 291 }
292 Token::Text(s) => { 292 Symbol::Text(s) => {
293 buf.push_str( s ); 293 buf.push_str( s );
294 } 294 }
295 //_ => {} 295 //_ => {}