From d1e78b4a3454984db74ebf2a302a64b985ce6de4 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 19 Aug 2026 13:05:01 -0700 Subject: Rearranged and renamed some bits. --- deepcrow/src/lexer.rs | 48 +++++----- deepcrow/src/lib.rs | 246 ------------------------------------------------- deepcrow/src/parser.rs | 118 ++++++++++++------------ 3 files changed, 83 insertions(+), 329 deletions(-) (limited to 'deepcrow/src') diff --git a/deepcrow/src/lexer.rs b/deepcrow/src/lexer.rs index d4d39e9..2528cb6 100644 --- a/deepcrow/src/lexer.rs +++ b/deepcrow/src/lexer.rs @@ -11,7 +11,7 @@ pub enum ErrorType { } #[derive(Debug,Copy,Clone,PartialEq,Eq)] -pub enum SymbolType<'a> { +pub enum TokenType<'a> { StartFlat, StartPoint, EndFlat, @@ -28,7 +28,7 @@ pub enum SymbolType<'a> { Sharp, Equals, Period, - Token(&'a str), + Identifier(&'a str), Literal(&'a str), Text(&'a str), Error{ what: ErrorType }, @@ -36,7 +36,7 @@ pub enum SymbolType<'a> { #[derive(Copy,Clone)] pub struct Symbol<'a> { - symbol: SymbolType<'a>, + symbol: TokenType<'a>, start: Position, end: Position, } @@ -48,17 +48,17 @@ impl<'a> fmt::Debug for Symbol<'a> { } impl<'a> Symbol<'a> { - pub fn new( symbol: SymbolType<'a>, start: Position, end: Position ) -> Self { + pub fn new( symbol: TokenType<'a>, start: Position, end: Position ) -> Self { Self { symbol, start, end, } } - pub fn check_type bool>(&self, f: T ) -> bool { + pub fn check_type bool>(&self, f: T ) -> bool { f( &self.symbol ) } - pub fn symbol(&self) -> &SymbolType<'a> { + pub fn symbol(&self) -> &TokenType<'a> { &self.symbol } @@ -171,7 +171,7 @@ impl<'a> Lexer<'a> { } fn error( &self, what: ErrorType ) -> Option> { - Some(Symbol::new( SymbolType::Error { + Some(Symbol::new( TokenType::Error { what: what }, self.pos, self.pos )) } @@ -217,7 +217,7 @@ impl<'a> Lexer<'a> { if start == end { None } else { - Some(Symbol::new( SymbolType::Text(s), start_pos, end_pos )) + Some(Symbol::new( TokenType::Text(s), start_pos, end_pos )) } } @@ -229,15 +229,15 @@ impl<'a> Lexer<'a> { } Some('#') => { self.next(); - return Some(Symbol::new(SymbolType::Sharp, self.pos, self.pos)); + return Some(Symbol::new(TokenType::Sharp, self.pos, self.pos)); } Some('=') => { self.next(); - return Some(Symbol::new(SymbolType::Equals, self.pos, self.pos)); + return Some(Symbol::new(TokenType::Equals, self.pos, self.pos)); } Some('.') => { self.next(); - return Some(Symbol::new(SymbolType::Period, self.pos, self.pos)); + return Some(Symbol::new(TokenType::Period, self.pos, self.pos)); } _ => {} } @@ -254,14 +254,14 @@ impl<'a> Lexer<'a> { None } else { Some(Symbol::new( match s { - "view" => SymbolType::View, - "show" => SymbolType::Show, - "output" => SymbolType::Output, - "loop" => SymbolType::Loop, - "if" => SymbolType::If, - "elif" => SymbolType::ElIf, - "else" => SymbolType::Else, - _ => SymbolType::Token(s) + "view" => TokenType::View, + "show" => TokenType::Show, + "output" => TokenType::Output, + "loop" => TokenType::Loop, + "if" => TokenType::If, + "elif" => TokenType::ElIf, + "else" => TokenType::Else, + _ => TokenType::Identifier(s) }, start_pos, end_pos )) } } @@ -277,7 +277,7 @@ impl<'a> Lexer<'a> { let end_pos = self.pos.clone(); self.next(); let s = &self.data[start..end]; - Some(Symbol::new(SymbolType::Literal(s), start_pos, end_pos )) + Some(Symbol::new(TokenType::Literal(s), start_pos, end_pos )) } fn is_start_tag(&mut self) -> bool { @@ -298,7 +298,7 @@ impl<'a> Lexer<'a> { let end_pos = self.pos.clone(); self.next(); self.mode = Mode::InTag; - Some(Symbol::new( SymbolType::StartFlat, start_pos, end_pos ) ) + Some(Symbol::new( TokenType::StartFlat, start_pos, end_pos ) ) } else { None } @@ -309,7 +309,7 @@ impl<'a> Lexer<'a> { let end_pos = self.pos.clone(); self.next(); self.mode = Mode::InTag; - Some(Symbol::new(SymbolType::StartPoint, start_pos, end_pos ) ) + Some(Symbol::new(TokenType::StartPoint, start_pos, end_pos ) ) } else { None } @@ -339,14 +339,14 @@ impl<'a> Lexer<'a> { let end_pos = self.pos.clone(); self.next(); self.mode = Mode::Text; - Some(Symbol::new( SymbolType::EndFlat, start_pos, end_pos)) + Some(Symbol::new( TokenType::EndFlat, start_pos, end_pos)) } Some('>') => { self.next(); let end_pos = self.pos.clone(); self.next(); self.mode = Mode::Text; - Some(Symbol::new( SymbolType::EndPoint, start_pos, end_pos)) + Some(Symbol::new( TokenType::EndPoint, start_pos, end_pos)) } _ => { None diff --git a/deepcrow/src/lib.rs b/deepcrow/src/lib.rs index b10cd03..b9a4ffe 100644 --- a/deepcrow/src/lib.rs +++ b/deepcrow/src/lib.rs @@ -298,249 +298,3 @@ fn exec<'a>(input: &StatefulContext<'a>, tokens: &Vec, buf: &mut String) Ok(()) } -#[cfg(test)] -mod tests { - use super::*; - - use crate::lexer::*; - - #[test] - fn lexing() { - let data = r#"Leading comment: [|view "basic" something="yeup"|>Hello there <|view|] Trailing text"#; - let ll = lexer::Lexer::new( &data ); - for sym in ll { - if let SymbolType::Error{what} = sym.symbol() { - println!("Error {}:{}: {:?}", sym.start().line, sym.start().column, what ); - break; - } else { - println!("Symbol: {:?}", sym ); - } - } - } - - #[test] - fn parsing() { - let mut ct = DeepCrow::new(); - if let Err(e) = ct.load_static(r#"Here is a sample -[|view "index" theme="standard"|>Hi<|view|] -That was fun! now a placeholder: [|view "placeholder"|] and now one with an implicit [|view "simple"|>Body -> [|show content|] <- and end<|view|] aoeu - -[|view "person" layout="simple"|>Welcome [|show person.last_name|], [|show person.first_name|]! It's lovely to see you again.<|view|] - -Now with explicit outputs: -[|view "complex"|> - [|output "content"|> - Here's a [|show name|]. - <|output|] - [|output "sidebar"|> - What's up world? - <|output|] - [|output "footer"|> - Same, I guess! - <|output|] -<|view|]"#) { - println!("Error: {:?}", e ); - } else { - println!("It finished"); - if let Ok(v) = ct.render( - "person", - &Context::from([ - ("hi".to_string(),Value::String("hi".to_string())), - ("person".to_string(),Value::Dictionary(HashMap::from([ - ("first_name".to_string(), Value::String("Bob".to_string())), - ("last_name".to_string(), Value::String("Smith".to_string())), - ]))), - ]) - ) { - println!("View result: {:?}", v ); - } else { - println!("Error?"); - } - } - } - - #[test] - fn loops() -> Result<()> { - let mut ct = DeepCrow::new(); - ct.load_static(r#"Looping code: -[|view "index"|>We will enumerate people here:[|loop people|> - - [|show last_name|], [|show first_name|][|if show_title |>: [|show title|] <|else|> **title redacted** <|if|] ::>[|loop tags|> [|show tag|]<|loop|] <:: <|loop|] -<|view|] -"#)?; - - let ctx = Context::from([ - ("people".to_string(), vec![ - [ - ("first_name".into(), "Joe".into()), - ("last_name".into(), "Smith".into()), - ("show_title".into(), true.into()), - ("title".into(), "CEO".into()), - ("tags".into(), vec![ - Context::from([("tag".into(), "jerk".into()),]).into(), - Context::from([("tag".into(), "ugly".into()),]).into(), - ].into()), - ].into(), - [ - ("first_name".into(), "Chris".into()), - ("last_name".into(), "Perkens".into()), - ("show_title".into(), false.into()), - ("title".into(), "Baconeer".into()), - ("tags".into(), vec![ - Context::from([("tag".into(), "jerk".into()),]).into(), - Context::from([("tag".into(), "ugly".into()),]).into(), - ].into()), - ].into(), - [ - ("first_name".into(), "Will".into()), - ("last_name".into(), "Power".into()), - ("show_title".into(), false.into()), - ("title".into(), "CFO".into()), - ("tags".into(), vec![ - Context::from([("tag".into(), "jerk".into()),]).into(), - Context::from([("tag".into(), "ugly".into()),]).into(), - ].into()), - ].into(), - [ - ("first_name".into(), "Justin".into()), - ("last_name".into(), "Time".into()), - ("show_title".into(), true.into()), - ("title".into(), "CIO".into()), - ("tags".into(), vec![ - Context::from([("tag".into(), "jerk".into()),]).into(), - Context::from([("tag".into(), "ugly".into()),]).into(), - ].into()), - ].into(), - ].into()), - ]); - - println!("View result: {}", ct.render("index", &ctx)? ); - - Ok(()) - } - - #[test] - fn conditional() -> Result<()> { - let mut ct = DeepCrow::new(); - ct.load_static(r#"Hi there -[|view "index"|> - Color: [|if is_red|> red <|elif is_blue |> blue <|else|> green <|if|] -<|view|]"#)?; - - let ctx = Context::from([ - ("is_red".into(), false.into()), - ("is_blue".into(), false.into()), - ("color".into(), "purple".into()), - ]); - - println!("View result: {}", ct.render("index", &ctx)? ); - - Ok(()) - } - - struct Item { - pub id: i32, - pub title: String, - pub body: String, - } - - struct Person { - pub id: i32, - pub username: String, - pub name: String, - } - - struct Page { - pub user: Person, - pub total_items: i32, - pub total_pages: i32, - pub cur_page: i32, - pub items: Vec, - } - - impl Page { - fn new() -> Page { - Page { - user: Person { - id: 443, - username: "eichlan".into(), - name: "Mike".into(), - }, - total_items: 4000, - total_pages: 400, - cur_page: 35, - items: vec![ - Item{ - id: 123, - title: "hi".into(), - body: "body".into(), - }, - Item{ - id: 124, - title: "bye".into(), - body: "wooo".into(), - }, - Item{ - id: 125, - title: "ciao".into(), - body: "whatever".into(), - } - ], - } - } - } - - impl<'a> MappedStructure<'a> for Page { - fn get_value(&'a self, id: &str) -> Option> { - match id { - "user" => Some(MappedValue::Struct(&self.user)), - "total_items" => Some(MappedValue::Int32(self.total_items)), - "total_pages" => Some(MappedValue::Int32(self.total_pages)), - "cur_page" => Some(MappedValue::Int32(self.cur_page)), - "items" => Some(MappedValue::<'a>::List(&self.items)), - _ => None, - } - } - } - - impl<'a> MappedStructure<'a> for Person { - fn get_value(&'a self, id: &str) -> Option> { - match id { - "id" => Some(MappedValue::Int32(self.id)), - "username" => Some(MappedValue::String(&self.username)), - "name" => Some(MappedValue::String(&self.name)), - _ => None, - } - } - } - - impl<'a> MappedStructure<'a> for Item { - fn get_value(&'a self, id: &str) -> Option> { - match id { - "id" => Some(MappedValue::Int32(self.id)), - "title" => Some(MappedValue::String(&self.title)), - "body" => Some(MappedValue::String(&self.body)), - _ => None, - } - } - } - - #[test] - fn custom() -> Result<()> { - let page = Page::new(); - - println!("{:?}", - page.get_value(&"total_pages") - ); - - if let Some(MappedValue::List(l)) = page.get_value(&"items") { - l.for_each(&|x: &MappedValue, buf: &mut String| { - if let MappedValue::Struct(s) = x { - println!(" - {:?}", s.get_value(&"title")); - buf.push_str(&format!("{:?}",s.get_value(&"title"))); - } - Ok(()) - }).expect("loop"); - } - Ok(()) - } -} diff --git a/deepcrow/src/parser.rs b/deepcrow/src/parser.rs index fbfc44e..529c58e 100644 --- a/deepcrow/src/parser.rs +++ b/deepcrow/src/parser.rs @@ -36,7 +36,7 @@ impl<'a> Context<'a> { } /* - pub fn check_unwrapped bool>(&self, context: &str, f: T) -> Result { + pub fn check_unwrapped bool>(&self, context: &str, f: T) -> Result { if self.cur().is_none() || self.peek().is_none() { Err(DeepCrowError::eos( context )) } else { @@ -51,13 +51,13 @@ impl<'a> Context<'a> { } trait SymbolHelper { - fn is bool>(&self, context: &str, f: T ) -> Result; + fn is bool>(&self, context: &str, f: T ) -> Result; #[allow(dead_code)] fn is_valid_tag_name(&self) -> Result; } impl<'a> SymbolHelper for Option> { - fn is bool>(&self, context: &str, f: T ) -> Result { + fn is bool>(&self, context: &str, f: T ) -> Result { if let Some(st) = self { Ok(f( &st.symbol() )) } else { @@ -68,14 +68,14 @@ impl<'a> SymbolHelper for Option> { fn is_valid_tag_name(&self) -> Result { if let Some(st) = self { Ok(match st.symbol() { - SymbolType::Token(_) | - SymbolType::View | - SymbolType::Output | - SymbolType::Loop | - SymbolType::If | - SymbolType::ElIf | - SymbolType::Else | - SymbolType::Show => true, + TokenType::Identifier(_) | + TokenType::View | + TokenType::Output | + TokenType::Loop | + TokenType::If | + TokenType::ElIf | + TokenType::Else | + TokenType::Show => true, _ => false }) } else { @@ -184,7 +184,7 @@ impl Parser { } fn lex_error(&self, error: &Symbol) -> Result { - if let SymbolType::Error{what} = error.symbol() { + if let TokenType::Error{what} = error.symbol() { Err(DeepCrowError::parse( *error.start(), format!("What: {:?}", *what) )) @@ -208,13 +208,13 @@ impl Parser { break; } match ctx.cur().unwrap().symbol() { - SymbolType::Text(_) => { /* Skip top level text */ } - SymbolType::StartFlat => { + TokenType::Text(_) => { /* Skip top level text */ } + TokenType::StartFlat => { let tb = self.parse_tag( ctx )?; let tb = self.parse_tag_set( ctx, tb )?; tags.push( tb ); } - SymbolType::Error{..} => { + TokenType::Error{..} => { self.lex_error( &ctx.cur().unwrap() )?; } _ => { @@ -231,7 +231,7 @@ impl Parser { for tag in tags { let start_pos = tag.start_pos(); let name = tag.name().clone(); - if tag.is_name(&SymbolType::View) && + if tag.is_name(&TokenType::View) && let BuildResult::View(view) = tag.build( ctx )? { views.push( view ); } else { @@ -250,9 +250,9 @@ impl Parser { if ctx.next().is_some() { match ctx.cur().unwrap().symbol() { - SymbolType::View | SymbolType::Show | SymbolType::Loop | - SymbolType::If | SymbolType::ElIf | SymbolType::Else | - SymbolType::Output => { + TokenType::View | TokenType::Show | TokenType::Loop | + TokenType::If | TokenType::ElIf | TokenType::Else | + TokenType::Output => { let name_sym = ctx.cur().unwrap(); ctx.next(); tb.set_name( name_sym ); @@ -277,7 +277,7 @@ impl Parser { if let Some(end_sym) = ctx.cur() { match end_sym.symbol() { - SymbolType::EndPoint | SymbolType::EndFlat => { + TokenType::EndPoint | TokenType::EndFlat => { tb.set_end( &end_sym )?; } _ => { @@ -304,11 +304,11 @@ impl Parser { return Err(DeepCrowError::eos(format!("close tag for {:?}", base.name()).as_str())); } match ctx.cur().unwrap().symbol() { - SymbolType::Text(s) => { + TokenType::Text(s) => { base.add_child(Entry::Token(Token::Text(s.to_string()))); ctx.next(); } - SymbolType::StartFlat | SymbolType::StartPoint => { + TokenType::StartFlat | TokenType::StartPoint => { let tb = self.parse_tag( ctx )?; match tb.tag_type() { @@ -320,9 +320,9 @@ impl Parser { return Ok(base); } TagType::MultinaryClose => { - if (tb.is_name(&SymbolType::If) && - (base.is_name(&SymbolType::ElIf) || - base.is_name(&SymbolType::Else))) || + if (tb.is_name(&TokenType::If) && + (base.is_name(&TokenType::ElIf) || + base.is_name(&TokenType::Else))) || tb.is_name(base.name().unwrap().symbol()) { return Ok(base); } else { @@ -340,7 +340,7 @@ impl Parser { } } } - SymbolType::Error{..} => { + TokenType::Error{..} => { return self.lex_error( &ctx.cur().unwrap() ); } _ => { @@ -359,12 +359,12 @@ impl Parser { return Err(DeepCrowError::eos("tag parameters")); } match ctx.cur().unwrap().symbol() { - SymbolType::Literal(s) => { + TokenType::Literal(s) => { tb.add_param( ParamValue::Literal(s.to_string()) ); ctx.next(); } - SymbolType::Token(_) | SymbolType::Sharp => { - if ctx.peek().is("tag data", |s| *s == SymbolType::Equals)? { + TokenType::Identifier(_) | TokenType::Sharp => { + if ctx.peek().is("tag data", |s| *s == TokenType::Equals)? { break; } tb.add_param( self.parse_identifier( ctx )? ); @@ -380,20 +380,20 @@ impl Parser { fn parse_identifier(&self, ctx: &mut Context ) -> Result { let mut id = Identifier::new(); - if ctx.cur().is("identifier",|s| matches!( s, SymbolType::Sharp))? { + if ctx.cur().is("identifier",|s| matches!( s, TokenType::Sharp))? { id.push( IdentifierValue::Root ); ctx.next(); } loop { - if ctx.cur().is("identifier",|s| matches!( s, SymbolType::Token(_) ))? { - if let SymbolType::Token(s) = ctx.cur().unwrap().symbol() { + if ctx.cur().is("identifier",|s| matches!( s, TokenType::Identifier(_) ))? { + if let TokenType::Identifier(s) = ctx.cur().unwrap().symbol() { id.push( IdentifierValue::Name(s.to_string()) ); } } else { return Err(DeepCrowError::parse( ctx.cur().unwrap().start().clone(), format!("Expeceted identifier, found {:?}", ctx.cur().unwrap().symbol() ) ) ); } - if !ctx.next().is("identifier seperator",|s| *s == SymbolType::Period )? { + if !ctx.next().is("identifier seperator",|s| *s == TokenType::Period )? { break; } ctx.next(); @@ -407,11 +407,11 @@ impl Parser { if ctx.cur().is_none() { return Err(DeepCrowError::eos("tag properties")); } - if let SymbolType::Token(s) = ctx.cur().unwrap().symbol() { - if ctx.peek().is_some_and(|s|s.check_type(|t| matches!(t,SymbolType::Equals))) { + if let TokenType::Identifier(s) = ctx.cur().unwrap().symbol() { + if ctx.peek().is_some_and(|s|s.check_type(|t| matches!(t,TokenType::Equals))) { ctx.next(); if let Some(sym) = ctx.next() && - let SymbolType::Literal(lv) = sym.symbol() { + let TokenType::Literal(lv) = sym.symbol() { tb.add_prop( s.to_string(), lv.to_string() ); } else { return Err(DeepCrowError::parse(Position::none(),"Expected quoted literal string".to_string())); @@ -455,7 +455,7 @@ impl<'a> EntryListConverter for EntryList<'a> { fn has_outputs(&self) -> bool { self.iter().any(|e| if let Entry::TagBuilder(tb) = e - && tb.is_name(&SymbolType::Output) { + && tb.is_name(&TokenType::Output) { true } else { false @@ -546,18 +546,18 @@ impl<'a> TagBuilder<'a> { } pub fn set_end(&mut self, end: &Symbol) -> Result<()> { - if *self.start.symbol() == SymbolType::StartFlat { - if *end.symbol() == SymbolType::EndFlat { + if *self.start.symbol() == TokenType::StartFlat { + if *end.symbol() == TokenType::EndFlat { self.tag_type = TagType::Unary; - } else if *end.symbol() == SymbolType::EndPoint { + } else if *end.symbol() == TokenType::EndPoint { self.tag_type = TagType::MultinaryOpen; } else { return Err(DeepCrowError::broken( *end.start(), "Invalid bracket token type.")); } - } else if *self.start.symbol() == SymbolType::StartPoint { - if *end.symbol() == SymbolType::EndFlat { + } else if *self.start.symbol() == TokenType::StartPoint { + if *end.symbol() == TokenType::EndFlat { self.tag_type = TagType::MultinaryClose; - } else if *end.symbol() == SymbolType::EndPoint { + } else if *end.symbol() == TokenType::EndPoint { self.tag_type = TagType::MultinaryMid; } else { return Err(DeepCrowError::broken( *end.start(), "Invalid bracket token type.")); @@ -582,18 +582,18 @@ impl<'a> TagBuilder<'a> { */ pub fn can_have_params(&self) -> bool { match self.name.unwrap().symbol() { - SymbolType::View | SymbolType::Output | SymbolType::Loop => true, - SymbolType::Show | SymbolType::If | SymbolType::ElIf | - SymbolType::Else => false, + TokenType::View | TokenType::Output | TokenType::Loop => true, + TokenType::Show | TokenType::If | TokenType::ElIf | + TokenType::Else => false, _ => false, } } pub fn can_have_expr(&self) -> bool { match self.name.unwrap().symbol() { - SymbolType::View | SymbolType::Output | SymbolType::Loop => false, - SymbolType::Show | SymbolType::If | SymbolType::ElIf | - SymbolType::Else => true, + TokenType::View | TokenType::Output | TokenType::Loop => false, + TokenType::Show | TokenType::If | TokenType::ElIf | + TokenType::Else => true, _ => false, } } @@ -611,7 +611,7 @@ impl<'a> TagBuilder<'a> { } } */ - pub fn is_name(&self, name: &SymbolType<'a>) -> bool { + pub fn is_name(&self, name: &TokenType<'a>) -> bool { if let Some(a) = self.name { a.symbol() == name } else { @@ -662,7 +662,7 @@ impl<'a> TagBuilder<'a> { pub fn build(mut self, ctx: &mut Context ) -> Result { if let Some(sym) = self.name { match sym.symbol() { - SymbolType::View => { + TokenType::View => { let name = if let ParamValue::Literal(s) = self.params.swap_remove(0) { s.to_string() } else { @@ -676,7 +676,7 @@ impl<'a> TagBuilder<'a> { layout: self.props.get("layout").cloned(), })) } - SymbolType::Output => { + TokenType::Output => { let name = if let ParamValue::Literal(s) = self.params.swap_remove(0) { s.to_string() } else { @@ -687,7 +687,7 @@ impl<'a> TagBuilder<'a> { code: self.children.to_tokens(ctx)?, })) } - SymbolType::Loop => { + TokenType::Loop => { let id = if let ParamValue::Identifier(id) = self.params.swap_remove(0) { id @@ -701,7 +701,7 @@ impl<'a> TagBuilder<'a> { Token::Loop(id, self.children.to_tokens(ctx)?) )) } - SymbolType::Show => { + TokenType::Show => { let id = if let ParamValue::Identifier(id) = self.params.swap_remove(0) { id @@ -713,7 +713,7 @@ impl<'a> TagBuilder<'a> { }; Ok(BuildResult::Token(Token::Show(id, self.props))) } - SymbolType::If => { + TokenType::If => { let id = if let ParamValue::Identifier(id) = self.params.swap_remove(0) { id @@ -726,7 +726,7 @@ impl<'a> TagBuilder<'a> { let is_else = if self.chain.len() == 1 && let Entry::TagBuilder(tb) = &self.chain[0] && - tb.is_name(&SymbolType::Else) && + tb.is_name(&TokenType::Else) && tb.params.len() == 0 { true } else { @@ -740,7 +740,7 @@ impl<'a> TagBuilder<'a> { } Ok(BuildResult::Token(Token::If(id, self.children.to_tokens(ctx)?, self.chain.to_tokens(ctx)?))) } - SymbolType::ElIf => { + TokenType::ElIf => { let id = if let ParamValue::Identifier(id) = self.params.swap_remove(0) { id } else { @@ -755,7 +755,7 @@ impl<'a> TagBuilder<'a> { // ...but I can't do that right now. let is_else = if self.chain.len() == 1 && let Entry::TagBuilder(tb) = &self.chain[0] && - tb.is_name(&SymbolType::Else) && + tb.is_name(&TokenType::Else) && tb.params.len() == 0 { true } else { @@ -771,7 +771,7 @@ impl<'a> TagBuilder<'a> { Ok(BuildResult::Token(Token::If(id, self.children.to_tokens(ctx)?, self.chain.to_tokens(ctx)?))) } - SymbolType::Else => { + TokenType::Else => { Ok(BuildResult::Token(Token::If(Identifier::new(), self.children.to_tokens(ctx)?, self.chain.to_tokens(ctx)?))) } _ => { -- cgit v1.2.3