Implement Into for AstNode.

This commit is contained in:
Tom Alexander
2023-09-27 15:07:26 -04:00
parent 9111408d83
commit df5d699a39
2 changed files with 391 additions and 55 deletions

View File

@@ -1,63 +1,73 @@
use super::ast_node::AstNode;
use crate::types::Object;
pub enum AstNodeIter<'s> {
pub enum AstNodeIter<'r, 's> {
// Document Nodes
// Document(DocumentIter<'s>),
// Heading(HeadingIter<'s>),
// Section(SectionIter<'s>),
// Document(DocumentIter<'r, 's>),
// Heading(HeadingIter<'r, 's>),
// Section(SectionIter<'r, 's>),
// Elements
// Paragraph(ParagraphIter<'s>),
// PlainList(PlainListIter<'s>),
// GreaterBlock(GreaterBlockIter<'s>),
// DynamicBlock(DynamicBlockIter<'s>),
// FootnoteDefinition(FootnoteDefinitionIter<'s>),
// Comment(CommentIter<'s>),
// Drawer(DrawerIter<'s>),
// PropertyDrawer(PropertyDrawerIter<'s>),
// Table(TableIter<'s>),
// VerseBlock(VerseBlockIter<'s>),
// CommentBlock(CommentBlockIter<'s>),
// ExampleBlock(ExampleBlockIter<'s>),
// ExportBlock(ExportBlockIter<'s>),
// SrcBlock(SrcBlockIter<'s>),
// Clock(ClockIter<'s>),
// DiarySexp(DiarySexpIter<'s>),
// Planning(PlanningIter<'s>),
// FixedWidthArea(FixedWidthAreaIter<'s>),
// HorizontalRule(HorizontalRuleIter<'s>),
// Keyword(KeywordIter<'s>),
// BabelCall(BabelCallIter<'s>),
// LatexEnvironment(LatexEnvironmentIter<'s>),
// Paragraph(ParagraphIter<'r, 's>),
// PlainList(PlainListIter<'r, 's>),
// GreaterBlock(GreaterBlockIter<'r, 's>),
// DynamicBlock(DynamicBlockIter<'r, 's>),
// FootnoteDefinition(FootnoteDefinitionIter<'r, 's>),
// Comment(CommentIter<'r, 's>),
// Drawer(DrawerIter<'r, 's>),
// PropertyDrawer(PropertyDrawerIter<'r, 's>),
// Table(TableIter<'r, 's>),
// VerseBlock(VerseBlockIter<'r, 's>),
// CommentBlock(CommentBlockIter<'r, 's>),
// ExampleBlock(ExampleBlockIter<'r, 's>),
// ExportBlock(ExportBlockIter<'r, 's>),
// SrcBlock(SrcBlockIter<'r, 's>),
// Clock(ClockIter<'r, 's>),
// DiarySexp(DiarySexpIter<'r, 's>),
// Planning(PlanningIter<'r, 's>),
// FixedWidthArea(FixedWidthAreaIter<'r, 's>),
// HorizontalRule(HorizontalRuleIter<'r, 's>),
// Keyword(KeywordIter<'r, 's>),
// BabelCall(BabelCallIter<'r, 's>),
// LatexEnvironment(LatexEnvironmentIter<'r, 's>),
// Objects
Bold(BoldIter<'s>),
// Italic(ItalicIter<'s>),
// Underline(UnderlineIter<'s>),
// StrikeThrough(StrikeThroughIter<'s>),
// Code(CodeIter<'s>),
// Verbatim(VerbatimIter<'s>),
// PlainText(PlainTextIter<'s>),
// RegularLink(RegularLinkIter<'s>),
// RadioLink(RadioLinkIter<'s>),
// RadioTarget(RadioTargetIter<'s>),
// PlainLink(PlainLinkIter<'s>),
// AngleLink(AngleLinkIter<'s>),
// OrgMacro(OrgMacroIter<'s>),
// Entity(EntityIter<'s>),
// LatexFragment(LatexFragmentIter<'s>),
// ExportSnippet(ExportSnippetIter<'s>),
// FootnoteReference(FootnoteReferenceIter<'s>),
// Citation(CitationIter<'s>),
// CitationReference(CitationReferenceIter<'s>),
// InlineBabelCall(InlineBabelCallIter<'s>),
// InlineSourceBlock(InlineSourceBlockIter<'s>),
// LineBreak(LineBreakIter<'s>),
// Target(TargetIter<'s>),
// StatisticsCookie(StatisticsCookieIter<'s>),
// Subscript(SubscriptIter<'s>),
// Superscript(SuperscriptIter<'s>),
// Timestamp(TimestampIter<'s>),
Bold(BoldIter<'r, 's>),
// Italic(ItalicIter<'r, 's>),
// Underline(UnderlineIter<'r, 's>),
// StrikeThrough(StrikeThroughIter<'r, 's>),
// Code(CodeIter<'r, 's>),
// Verbatim(VerbatimIter<'r, 's>),
// PlainText(PlainTextIter<'r, 's>),
// RegularLink(RegularLinkIter<'r, 's>),
// RadioLink(RadioLinkIter<'r, 's>),
// RadioTarget(RadioTargetIter<'r, 's>),
// PlainLink(PlainLinkIter<'r, 's>),
// AngleLink(AngleLinkIter<'r, 's>),
// OrgMacro(OrgMacroIter<'r, 's>),
// Entity(EntityIter<'r, 's>),
// LatexFragment(LatexFragmentIter<'r, 's>),
// ExportSnippet(ExportSnippetIter<'r, 's>),
// FootnoteReference(FootnoteReferenceIter<'r, 's>),
// Citation(CitationIter<'r, 's>),
// CitationReference(CitationReferenceIter<'r, 's>),
// InlineBabelCall(InlineBabelCallIter<'r, 's>),
// InlineSourceBlock(InlineSourceBlockIter<'r, 's>),
// LineBreak(LineBreakIter<'r, 's>),
// Target(TargetIter<'r, 's>),
// StatisticsCookie(StatisticsCookieIter<'r, 's>),
// Subscript(SubscriptIter<'r, 's>),
// Superscript(SuperscriptIter<'r, 's>),
// Timestamp(TimestampIter<'r, 's>),
}
pub struct BoldIter<'s> {
next: std::slice::Iter<'s, Object<'s>>,
pub struct BoldIter<'r, 's> {
next: std::slice::Iter<'r, Object<'s>>,
}
impl<'r, 's> Iterator for BoldIter<'r, 's> {
type Item = AstNode<'r, 's>;
fn next(&mut self) -> Option<Self::Item> {
let foo = self.next.next();
todo!()
}
}