From 887943e3f1908583d6888c8375f345b33b74fdb5 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 9 Jun 2026 16:18:11 -0700 Subject: Loops work! --- src/lib.rs | 2 +- src/parser.rs | 16 ++++++++++++++-- 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: let mut ct = Crimtag::new(); if let Err(e) = ct.load_static(r#"Looping code: [|view "index"|>We will enumerate people here:[|loop people|> - - [|show last_name|], [|show first_name|]: [|show title|]<|loop|] + - [|show last_name|], [|show first_name|]: [|show title|] [|loop tags|> [|show tag|]<|loop|] <|loop|] <|view|] "#) { 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 { return self.lex_error( &ctx.cur().unwrap() ); } _ => { - ctx.next(); + return Err(ParseError{ + position: *ctx.cur().unwrap().start(), + what: format!("Unexpected tag in view root: {:?}", ctx.cur().unwrap().symbol()) + }); } } } @@ -387,6 +390,7 @@ impl Parser { what: "Tag should be <| |] style end tag.".to_string(), }); } + ctx.next(); Ok(name) } @@ -425,7 +429,10 @@ impl Parser { return self.lex_error( &ctx.cur().unwrap() ); } _ => { - + return Err(ParseError{ + position: ctx.cur().unwrap().start().clone(), + what: format!("Unexpected token: {:?}", ctx.cur().unwrap().symbol()), + }); } } } @@ -518,6 +525,7 @@ struct TagBuilder<'a> { start_pos: Position, } +#[derive(Debug)] enum ParamValue { Literal(String), Identifier(Identifier), @@ -567,6 +575,10 @@ impl<'a> TagBuilder<'a> { self.name } + pub fn params(&self) -> &Vec { + &self.params + } + pub fn set_name(&mut self, name: Symbol<'a>) { self.name = Some(name); } -- cgit v1.2.3