diff --git a/src/compare/diff.rs b/src/compare/diff.rs index 0ed1a7f..5c63d1c 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -4,6 +4,7 @@ use super::util::assert_name; use crate::parser::Clock; use crate::parser::Comment; use crate::parser::CommentBlock; +use crate::parser::DiarySexp; use crate::parser::Document; use crate::parser::DocumentElement; use crate::parser::Drawer; @@ -215,6 +216,7 @@ fn compare_element<'s>( Element::ExportBlock(obj) => compare_export_block(source, emacs, obj), Element::SrcBlock(obj) => compare_src_block(source, emacs, obj), Element::Clock(obj) => compare_clock(source, emacs, obj), + Element::DiarySexp(obj) => compare_diary_sexp(source, emacs, obj), } } @@ -702,3 +704,26 @@ fn compare_clock<'s>( children: Vec::new(), }) } + +fn compare_diary_sexp<'s>( + source: &'s str, + emacs: &'s Token<'s>, + rust: &'s DiarySexp<'s>, +) -> Result> { + let mut this_status = DiffStatus::Good; + let emacs_name = "diary-sexp"; + if assert_name(emacs, emacs_name).is_err() { + this_status = DiffStatus::Bad; + } + + if assert_bounds(source, emacs, rust).is_err() { + this_status = DiffStatus::Bad; + } + + Ok(DiffResult { + status: this_status, + name: emacs_name.to_owned(), + message: None, + children: Vec::new(), + }) +} diff --git a/src/parser/diary_sexp.rs b/src/parser/diary_sexp.rs new file mode 100644 index 0000000..ed528d1 --- /dev/null +++ b/src/parser/diary_sexp.rs @@ -0,0 +1,8 @@ +use super::Context; +use crate::error::Res; +use crate::parser::DiarySexp; + +#[tracing::instrument(ret, level = "debug")] +pub fn diary_sexp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, DiarySexp<'s>> { + todo!() +} diff --git a/src/parser/element.rs b/src/parser/element.rs index fd132f8..bfc19d1 100644 --- a/src/parser/element.rs +++ b/src/parser/element.rs @@ -7,6 +7,7 @@ use super::greater_element::Table; use super::lesser_element::Clock; use super::lesser_element::Comment; use super::lesser_element::CommentBlock; +use super::lesser_element::DiarySexp; use super::lesser_element::ExampleBlock; use super::lesser_element::ExportBlock; use super::lesser_element::Paragraph; @@ -32,6 +33,7 @@ pub enum Element<'s> { ExportBlock(ExportBlock<'s>), SrcBlock(SrcBlock<'s>), Clock(Clock<'s>), + DiarySexp(DiarySexp<'s>), } impl<'s> Source<'s> for Element<'s> { @@ -52,6 +54,7 @@ impl<'s> Source<'s> for Element<'s> { Element::ExportBlock(obj) => obj.source, Element::SrcBlock(obj) => obj.source, Element::Clock(obj) => obj.source, + Element::DiarySexp(obj) => obj.source, } } } diff --git a/src/parser/element_parser.rs b/src/parser/element_parser.rs index 8e24d1a..c153e9f 100644 --- a/src/parser/element_parser.rs +++ b/src/parser/element_parser.rs @@ -1,5 +1,6 @@ use super::clock::clock; use super::comment::comment; +use super::diary_sexp::diary_sexp; use super::drawer::drawer; use super::dynamic_block::dynamic_block; use super::element::Element; @@ -47,6 +48,7 @@ pub fn non_paragraph_element<'r, 's>( let export_block_matcher = parser_with_context!(export_block)(context); let src_block_matcher = parser_with_context!(src_block)(context); let clock_matcher = parser_with_context!(clock)(context); + let diary_sexp_matcher = parser_with_context!(diary_sexp)(context); alt(( map(plain_list_matcher, Element::PlainList), map(greater_block_matcher, Element::GreaterBlock), @@ -61,5 +63,6 @@ pub fn non_paragraph_element<'r, 's>( map(export_block_matcher, Element::ExportBlock), map(src_block_matcher, Element::SrcBlock), map(clock_matcher, Element::Clock), + map(diary_sexp_matcher, Element::DiarySexp), ))(input) } diff --git a/src/parser/lesser_element.rs b/src/parser/lesser_element.rs index b7cd106..d210b62 100644 --- a/src/parser/lesser_element.rs +++ b/src/parser/lesser_element.rs @@ -64,6 +64,11 @@ pub struct Clock<'s> { pub source: &'s str, } +#[derive(Debug)] +pub struct DiarySexp<'s> { + pub source: &'s str, +} + impl<'s> Paragraph<'s> { pub fn of_text(input: &'s str) -> Self { let mut objects = Vec::with_capacity(1); @@ -124,3 +129,9 @@ impl<'s> Source<'s> for Clock<'s> { self.source } } + +impl<'s> Source<'s> for DiarySexp<'s> { + fn get_source(&'s self) -> &'s str { + self.source + } +} diff --git a/src/parser/mod.rs b/src/parser/mod.rs index d8d4e60..5d97c93 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1,5 +1,6 @@ mod clock; mod comment; +mod diary_sexp; mod document; mod drawer; mod dynamic_block; @@ -41,6 +42,7 @@ pub use greater_element::TableRow; pub use lesser_element::Clock; pub use lesser_element::Comment; pub use lesser_element::CommentBlock; +pub use lesser_element::DiarySexp; pub use lesser_element::ExampleBlock; pub use lesser_element::ExportBlock; pub use lesser_element::Paragraph;