Filling in more of the iter_tokens tree.

This commit is contained in:
Tom Alexander 2023-07-14 20:18:30 -04:00
parent 0e73b83bf3
commit 08e6efe5f5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -4,6 +4,8 @@ use super::Heading;
use super::Object;
use super::PlainListItem;
use super::Section;
use super::TableCell;
use super::TableRow;
use crate::parser::DocumentElement;
pub enum Token<'r, 's> {
@ -13,6 +15,8 @@ pub enum Token<'r, 's> {
Object(&'r Object<'s>),
Element(&'r Element<'s>),
PlainListItem(&'r PlainListItem<'s>),
TableRow(&'r TableRow<'s>),
TableCell(&'r TableCell<'s>),
}
impl<'r, 's> Token<'r, 's> {
@ -53,26 +57,30 @@ impl<'r, 's> Token<'r, 's> {
Box::new(inner.children.iter().map(Token::PlainListItem))
}
Element::GreaterBlock(inner) => Box::new(inner.children.iter().map(Token::Element)),
Element::DynamicBlock(_) => todo!(),
Element::FootnoteDefinition(_) => todo!(),
Element::Comment(_) => todo!(),
Element::Drawer(_) => todo!(),
Element::PropertyDrawer(_) => todo!(),
Element::Table(_) => todo!(),
Element::VerseBlock(_) => todo!(),
Element::CommentBlock(_) => todo!(),
Element::ExampleBlock(_) => todo!(),
Element::ExportBlock(_) => todo!(),
Element::SrcBlock(_) => todo!(),
Element::Clock(_) => todo!(),
Element::DiarySexp(_) => todo!(),
Element::Planning(_) => todo!(),
Element::FixedWidthArea(_) => todo!(),
Element::HorizontalRule(_) => todo!(),
Element::Keyword(_) => todo!(),
Element::LatexEnvironment(_) => todo!(),
Element::DynamicBlock(inner) => Box::new(inner.children.iter().map(Token::Element)),
Element::FootnoteDefinition(inner) => {
Box::new(inner.children.iter().map(Token::Element))
}
Element::Comment(_) => Box::new(std::iter::empty()),
Element::Drawer(inner) => Box::new(inner.children.iter().map(Token::Element)),
Element::PropertyDrawer(_) => Box::new(std::iter::empty()),
Element::Table(inner) => Box::new(inner.children.iter().map(Token::TableRow)),
Element::VerseBlock(inner) => Box::new(inner.children.iter().map(Token::Object)),
Element::CommentBlock(_) => Box::new(std::iter::empty()),
Element::ExampleBlock(_) => Box::new(std::iter::empty()),
Element::ExportBlock(_) => Box::new(std::iter::empty()),
Element::SrcBlock(_) => Box::new(std::iter::empty()),
Element::Clock(_) => Box::new(std::iter::empty()),
Element::DiarySexp(_) => Box::new(std::iter::empty()),
Element::Planning(_) => Box::new(std::iter::empty()),
Element::FixedWidthArea(_) => Box::new(std::iter::empty()),
Element::HorizontalRule(_) => Box::new(std::iter::empty()),
Element::Keyword(_) => Box::new(std::iter::empty()),
Element::LatexEnvironment(_) => Box::new(std::iter::empty()),
},
Token::PlainListItem(elem) => Box::new(elem.children.iter().map(Token::Element)),
Token::TableRow(elem) => Box::new(elem.children.iter().map(Token::TableCell)),
Token::TableCell(elem) => Box::new(elem.children.iter().map(Token::Object)),
}
}
}