summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2026-06-09 16:18:11 -0700
committerMike Buland <mike@xagasoft.com>2026-06-09 16:18:11 -0700
commit887943e3f1908583d6888c8375f345b33b74fdb5 (patch)
tree61578ef78993a455ab1a122b6d9ad2a95ede3bc1
parent5d014484a4a34146bc13a578e81ed0a0080d4697 (diff)
downloadcrimtag-887943e3f1908583d6888c8375f345b33b74fdb5.tar.gz
crimtag-887943e3f1908583d6888c8375f345b33b74fdb5.tar.bz2
crimtag-887943e3f1908583d6888c8375f345b33b74fdb5.tar.xz
crimtag-887943e3f1908583d6888c8375f345b33b74fdb5.zip
Loops work!
-rw-r--r--src/lib.rs2
-rw-r--r--src/parser.rs16
2 files changed, 15 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index c900e39..feb00f0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -350,7 +350,7 @@ Now with explicit outputs:
350 let mut ct = Crimtag::new(); 350 let mut ct = Crimtag::new();
351 if let Err(e) = ct.load_static(r#"Looping code: 351 if let Err(e) = ct.load_static(r#"Looping code:
352[|view "index"|>We will enumerate people here:[|loop people|> 352[|view "index"|>We will enumerate people here:[|loop people|>
353 - [|show last_name|], [|show first_name|]: [|show title|]<|loop|] 353 - [|show last_name|], [|show first_name|]: [|show title|] [|loop tags|> [|show tag|]<|loop|] <|loop|]
354<|view|] 354<|view|]
355"#) { 355"#) {
356 println!("Error: {:?}", e ); 356 println!("Error: {:?}", e );
diff --git a/src/parser.rs b/src/parser.rs
index 6e479e4..07bbd93 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -316,7 +316,10 @@ impl Parser {
316 return self.lex_error( &ctx.cur().unwrap() ); 316 return self.lex_error( &ctx.cur().unwrap() );
317 } 317 }
318 _ => { 318 _ => {
319 ctx.next(); 319 return Err(ParseError{
320 position: *ctx.cur().unwrap().start(),
321 what: format!("Unexpected tag in view root: {:?}", ctx.cur().unwrap().symbol())
322 });
320 } 323 }
321 } 324 }
322 } 325 }
@@ -387,6 +390,7 @@ impl Parser {
387 what: "Tag should be <| |] style end tag.".to_string(), 390 what: "Tag should be <| |] style end tag.".to_string(),
388 }); 391 });
389 } 392 }
393 ctx.next();
390 Ok(name) 394 Ok(name)
391 } 395 }
392 396
@@ -425,7 +429,10 @@ impl Parser {
425 return self.lex_error( &ctx.cur().unwrap() ); 429 return self.lex_error( &ctx.cur().unwrap() );
426 } 430 }
427 _ => { 431 _ => {
428 432 return Err(ParseError{
433 position: ctx.cur().unwrap().start().clone(),
434 what: format!("Unexpected token: {:?}", ctx.cur().unwrap().symbol()),
435 });
429 } 436 }
430 } 437 }
431 } 438 }
@@ -518,6 +525,7 @@ struct TagBuilder<'a> {
518 start_pos: Position, 525 start_pos: Position,
519} 526}
520 527
528#[derive(Debug)]
521enum ParamValue { 529enum ParamValue {
522 Literal(String), 530 Literal(String),
523 Identifier(Identifier), 531 Identifier(Identifier),
@@ -567,6 +575,10 @@ impl<'a> TagBuilder<'a> {
567 self.name 575 self.name
568 } 576 }
569 577
578 pub fn params(&self) -> &Vec<ParamValue> {
579 &self.params
580 }
581
570 pub fn set_name(&mut self, name: Symbol<'a>) { 582 pub fn set_name(&mut self, name: Symbol<'a>) {
571 self.name = Some(name); 583 self.name = Some(name);
572 } 584 }