From 9111408d837b0a4f046ec7ef1dcea74a0e40772a Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 27 Sep 2023 14:24:08 -0400 Subject: [PATCH] Introduce AstNode and AstNodeIter enums. --- src/iter/ast_node.rs | 109 ++++++++++++++++++++++++++++++++++++++ src/iter/ast_node_iter.rs | 58 ++++++++++++++++++++ 2 files changed, 167 insertions(+) diff --git a/src/iter/ast_node.rs b/src/iter/ast_node.rs index 8b13789..da38bc2 100644 --- a/src/iter/ast_node.rs +++ b/src/iter/ast_node.rs @@ -1 +1,110 @@ +use crate::types::AngleLink; +use crate::types::BabelCall; +use crate::types::Bold; +use crate::types::Citation; +use crate::types::CitationReference; +use crate::types::Clock; +use crate::types::Code; +use crate::types::Comment; +use crate::types::CommentBlock; +use crate::types::DiarySexp; +use crate::types::Document; +use crate::types::Drawer; +use crate::types::DynamicBlock; +use crate::types::Entity; +use crate::types::ExampleBlock; +use crate::types::ExportBlock; +use crate::types::ExportSnippet; +use crate::types::FixedWidthArea; +use crate::types::FootnoteDefinition; +use crate::types::FootnoteReference; +use crate::types::GreaterBlock; +use crate::types::Heading; +use crate::types::HorizontalRule; +use crate::types::InlineBabelCall; +use crate::types::InlineSourceBlock; +use crate::types::Italic; +use crate::types::Keyword; +use crate::types::LatexEnvironment; +use crate::types::LatexFragment; +use crate::types::LineBreak; +use crate::types::OrgMacro; +use crate::types::Paragraph; +use crate::types::PlainLink; +use crate::types::PlainList; +use crate::types::PlainText; +use crate::types::Planning; +use crate::types::PropertyDrawer; +use crate::types::RadioLink; +use crate::types::RadioTarget; +use crate::types::RegularLink; +use crate::types::Section; +use crate::types::SrcBlock; +use crate::types::StatisticsCookie; +use crate::types::StrikeThrough; +use crate::types::Subscript; +use crate::types::Superscript; +use crate::types::Table; +use crate::types::Target; +use crate::types::Timestamp; +use crate::types::Underline; +use crate::types::Verbatim; +use crate::types::VerseBlock; +pub enum AstNode<'r, 's> { + // Document Nodes + Document(&'r Document<'s>), + Heading(&'r Heading<'s>), + Section(&'r Section<'s>), + // Elements + Paragraph(&'r Paragraph<'s>), + PlainList(&'r PlainList<'s>), + GreaterBlock(&'r GreaterBlock<'s>), + DynamicBlock(&'r DynamicBlock<'s>), + FootnoteDefinition(&'r FootnoteDefinition<'s>), + Comment(&'r Comment<'s>), + Drawer(&'r Drawer<'s>), + PropertyDrawer(&'r PropertyDrawer<'s>), + Table(&'r Table<'s>), + VerseBlock(&'r VerseBlock<'s>), + CommentBlock(&'r CommentBlock<'s>), + ExampleBlock(&'r ExampleBlock<'s>), + ExportBlock(&'r ExportBlock<'s>), + SrcBlock(&'r SrcBlock<'s>), + Clock(&'r Clock<'s>), + DiarySexp(&'r DiarySexp<'s>), + Planning(&'r Planning<'s>), + FixedWidthArea(&'r FixedWidthArea<'s>), + HorizontalRule(&'r HorizontalRule<'s>), + Keyword(&'r Keyword<'s>), + BabelCall(&'r BabelCall<'s>), + LatexEnvironment(&'r LatexEnvironment<'s>), + // Objects + Bold(&'r Bold<'s>), + Italic(&'r Italic<'s>), + Underline(&'r Underline<'s>), + StrikeThrough(&'r StrikeThrough<'s>), + Code(&'r Code<'s>), + Verbatim(&'r Verbatim<'s>), + PlainText(&'r PlainText<'s>), + RegularLink(&'r RegularLink<'s>), + RadioLink(&'r RadioLink<'s>), + RadioTarget(&'r RadioTarget<'s>), + PlainLink(&'r PlainLink<'s>), + AngleLink(&'r AngleLink<'s>), + OrgMacro(&'r OrgMacro<'s>), + Entity(&'r Entity<'s>), + LatexFragment(&'r LatexFragment<'s>), + ExportSnippet(&'r ExportSnippet<'s>), + FootnoteReference(&'r FootnoteReference<'s>), + Citation(&'r Citation<'s>), + CitationReference(&'r CitationReference<'s>), + InlineBabelCall(&'r InlineBabelCall<'s>), + InlineSourceBlock(&'r InlineSourceBlock<'s>), + LineBreak(&'r LineBreak<'s>), + Target(&'r Target<'s>), + StatisticsCookie(&'r StatisticsCookie<'s>), + Subscript(&'r Subscript<'s>), + Superscript(&'r Superscript<'s>), + Timestamp(&'r Timestamp<'s>), +} diff --git a/src/iter/ast_node_iter.rs b/src/iter/ast_node_iter.rs index 136814a..dcd79bc 100644 --- a/src/iter/ast_node_iter.rs +++ b/src/iter/ast_node_iter.rs @@ -1,5 +1,63 @@ use crate::types::Object; +pub enum AstNodeIter<'s> { + // Document Nodes + // Document(DocumentIter<'s>), + // Heading(HeadingIter<'s>), + // Section(SectionIter<'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>), + // 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>), +} + pub struct BoldIter<'s> { next: std::slice::Iter<'s, Object<'s>>, }