1591 lines
44 KiB
Rust
1591 lines
44 KiB
Rust
use super::util::assert_bounds;
|
|
use super::util::assert_name;
|
|
use crate::parser::sexp::Token;
|
|
use crate::parser::AngleLink;
|
|
use crate::parser::Bold;
|
|
use crate::parser::Citation;
|
|
use crate::parser::CitationReference;
|
|
use crate::parser::Clock;
|
|
use crate::parser::Code;
|
|
use crate::parser::Comment;
|
|
use crate::parser::CommentBlock;
|
|
use crate::parser::DiarySexp;
|
|
use crate::parser::Document;
|
|
use crate::parser::DocumentElement;
|
|
use crate::parser::Drawer;
|
|
use crate::parser::DynamicBlock;
|
|
use crate::parser::Element;
|
|
use crate::parser::Entity;
|
|
use crate::parser::ExampleBlock;
|
|
use crate::parser::ExportBlock;
|
|
use crate::parser::ExportSnippet;
|
|
use crate::parser::FixedWidthArea;
|
|
use crate::parser::FootnoteDefinition;
|
|
use crate::parser::FootnoteReference;
|
|
use crate::parser::GreaterBlock;
|
|
use crate::parser::Heading;
|
|
use crate::parser::HorizontalRule;
|
|
use crate::parser::InlineBabelCall;
|
|
use crate::parser::InlineSourceBlock;
|
|
use crate::parser::Italic;
|
|
use crate::parser::Keyword;
|
|
use crate::parser::LatexEnvironment;
|
|
use crate::parser::LatexFragment;
|
|
use crate::parser::LineBreak;
|
|
use crate::parser::Object;
|
|
use crate::parser::OrgMacro;
|
|
use crate::parser::Paragraph;
|
|
use crate::parser::PlainLink;
|
|
use crate::parser::PlainList;
|
|
use crate::parser::PlainListItem;
|
|
use crate::parser::PlainText;
|
|
use crate::parser::Planning;
|
|
use crate::parser::PropertyDrawer;
|
|
use crate::parser::RadioLink;
|
|
use crate::parser::RadioTarget;
|
|
use crate::parser::RegularLink;
|
|
use crate::parser::Section;
|
|
use crate::parser::SrcBlock;
|
|
use crate::parser::StatisticsCookie;
|
|
use crate::parser::StrikeThrough;
|
|
use crate::parser::Subscript;
|
|
use crate::parser::Superscript;
|
|
use crate::parser::Table;
|
|
use crate::parser::TableCell;
|
|
use crate::parser::TableRow;
|
|
use crate::parser::Target;
|
|
use crate::parser::Timestamp;
|
|
use crate::parser::Underline;
|
|
use crate::parser::Verbatim;
|
|
use crate::parser::VerseBlock;
|
|
|
|
#[derive(Debug)]
|
|
pub struct DiffResult {
|
|
status: DiffStatus,
|
|
name: String,
|
|
#[allow(dead_code)]
|
|
message: Option<String>,
|
|
children: Vec<DiffResult>,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum DiffStatus {
|
|
Good,
|
|
Bad,
|
|
}
|
|
|
|
impl DiffResult {
|
|
pub fn print(&self) -> Result<(), Box<dyn std::error::Error>> {
|
|
self.print_indented(0)
|
|
}
|
|
|
|
fn print_indented(&self, indentation: usize) -> Result<(), Box<dyn std::error::Error>> {
|
|
let status_text = {
|
|
match self.status {
|
|
DiffStatus::Good => {
|
|
if self.has_bad_children() {
|
|
"BADCHILD"
|
|
} else {
|
|
"GOOD"
|
|
}
|
|
}
|
|
DiffStatus::Bad => "BAD",
|
|
}
|
|
};
|
|
println!(
|
|
"{}{} {} {}",
|
|
" ".repeat(indentation),
|
|
status_text,
|
|
self.name,
|
|
self.message.as_ref().map(|m| m.as_str()).unwrap_or("")
|
|
);
|
|
for child in self.children.iter() {
|
|
child.print_indented(indentation + 1)?;
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
pub fn has_bad_children(&self) -> bool {
|
|
self.children
|
|
.iter()
|
|
.any(|child| child.status == DiffStatus::Bad || child.has_bad_children())
|
|
}
|
|
|
|
pub fn is_bad(&self) -> bool {
|
|
match self.status {
|
|
DiffStatus::Good => self.has_bad_children(),
|
|
DiffStatus::Bad => true,
|
|
}
|
|
}
|
|
}
|
|
|
|
fn compare_element<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Element<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
match rust {
|
|
Element::Paragraph(obj) => compare_paragraph(source, emacs, obj),
|
|
Element::PlainList(obj) => compare_plain_list(source, emacs, obj),
|
|
Element::GreaterBlock(obj) => compare_greater_block(source, emacs, obj),
|
|
Element::DynamicBlock(obj) => compare_dynamic_block(source, emacs, obj),
|
|
Element::FootnoteDefinition(obj) => compare_footnote_definition(source, emacs, obj),
|
|
Element::Comment(obj) => compare_comment(source, emacs, obj),
|
|
Element::Drawer(obj) => compare_drawer(source, emacs, obj),
|
|
Element::PropertyDrawer(obj) => compare_property_drawer(source, emacs, obj),
|
|
Element::Table(obj) => compare_table(source, emacs, obj),
|
|
Element::VerseBlock(obj) => compare_verse_block(source, emacs, obj),
|
|
Element::CommentBlock(obj) => compare_comment_block(source, emacs, obj),
|
|
Element::ExampleBlock(obj) => compare_example_block(source, emacs, obj),
|
|
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),
|
|
Element::Planning(obj) => compare_planning(source, emacs, obj),
|
|
Element::FixedWidthArea(obj) => compare_fixed_width_area(source, emacs, obj),
|
|
Element::HorizontalRule(obj) => compare_horizontal_rule(source, emacs, obj),
|
|
Element::Keyword(obj) => compare_keyword(source, emacs, obj),
|
|
Element::LatexEnvironment(obj) => compare_latex_environment(source, emacs, obj),
|
|
}
|
|
}
|
|
|
|
fn compare_object<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Object<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
match rust {
|
|
Object::Bold(obj) => compare_bold(source, emacs, obj),
|
|
Object::Italic(obj) => compare_italic(source, emacs, obj),
|
|
Object::Underline(obj) => compare_underline(source, emacs, obj),
|
|
Object::Verbatim(obj) => compare_verbatim(source, emacs, obj),
|
|
Object::Code(obj) => compare_code(source, emacs, obj),
|
|
Object::StrikeThrough(obj) => compare_strike_through(source, emacs, obj),
|
|
Object::PlainText(obj) => compare_plain_text(source, emacs, obj),
|
|
Object::RegularLink(obj) => compare_regular_link(source, emacs, obj),
|
|
Object::RadioLink(obj) => compare_radio_link(source, emacs, obj),
|
|
Object::RadioTarget(obj) => compare_radio_target(source, emacs, obj),
|
|
Object::PlainLink(obj) => compare_plain_link(source, emacs, obj),
|
|
Object::AngleLink(obj) => compare_angle_link(source, emacs, obj),
|
|
Object::OrgMacro(obj) => compare_org_macro(source, emacs, obj),
|
|
Object::Entity(obj) => compare_entity(source, emacs, obj),
|
|
Object::LatexFragment(obj) => compare_latex_fragment(source, emacs, obj),
|
|
Object::ExportSnippet(obj) => compare_export_snippet(source, emacs, obj),
|
|
Object::FootnoteReference(obj) => compare_footnote_reference(source, emacs, obj),
|
|
Object::Citation(obj) => compare_citation(source, emacs, obj),
|
|
Object::CitationReference(obj) => compare_citation_reference(source, emacs, obj),
|
|
Object::InlineBabelCall(obj) => compare_inline_babel_call(source, emacs, obj),
|
|
Object::InlineSourceBlock(obj) => compare_inline_source_block(source, emacs, obj),
|
|
Object::LineBreak(obj) => compare_line_break(source, emacs, obj),
|
|
Object::Target(obj) => compare_target(source, emacs, obj),
|
|
Object::StatisticsCookie(obj) => compare_statistics_cookie(source, emacs, obj),
|
|
Object::Subscript(obj) => compare_subscript(source, emacs, obj),
|
|
Object::Superscript(obj) => compare_superscript(source, emacs, obj),
|
|
Object::Timestamp(obj) => compare_timestamp(source, emacs, obj),
|
|
}
|
|
}
|
|
|
|
pub fn compare_document<'s>(
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Document<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "org-data";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
// Skipping "org-data" and the first parameter which is often nil
|
|
for (i, token) in children.iter().skip(2).enumerate() {
|
|
let section_or_headline = token.as_list()?;
|
|
let first_cell = section_or_headline
|
|
.first()
|
|
.ok_or("Should have at least one child.")?
|
|
.as_atom()?;
|
|
if first_cell == "section" {
|
|
if i != 0 {
|
|
return Err("Section cannot be after the first child of document.".into());
|
|
}
|
|
child_status.push(compare_section(
|
|
rust.source,
|
|
token,
|
|
rust.zeroth_section
|
|
.as_ref()
|
|
.ok_or("No corresponding zeroth-section")?,
|
|
)?);
|
|
} else if first_cell == "headline" {
|
|
let corresponding_heading = rust
|
|
.children
|
|
.iter()
|
|
.nth(i - rust.zeroth_section.as_ref().map(|_| 1).unwrap_or(0))
|
|
.ok_or("Should have a corresponding heading.")?;
|
|
child_status.push(compare_heading(rust.source, token, corresponding_heading)?);
|
|
} else {
|
|
return Err("Document should only contain sections and headlines.".into());
|
|
}
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_section<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Section<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut this_status = DiffStatus::Good;
|
|
let mut child_status = Vec::new();
|
|
let emacs_name = "section";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_heading<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Heading<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "headline";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
let title = {
|
|
let children = emacs.as_list()?;
|
|
let attributes_child = children
|
|
.iter()
|
|
.nth(1)
|
|
.ok_or("Should have an attributes child.")?;
|
|
let attributes_map = attributes_child.as_map()?;
|
|
let title = attributes_map
|
|
.get(":title")
|
|
.ok_or("Missing :title attribute.");
|
|
*title?
|
|
};
|
|
for (emacs_child, rust_child) in title.as_list()?.iter().zip(rust.title.iter()) {
|
|
child_status.push(compare_object(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
match rust_child {
|
|
DocumentElement::Heading(rust_heading) => {
|
|
child_status.push(compare_heading(source, emacs_child, rust_heading)?);
|
|
}
|
|
DocumentElement::Section(rust_section) => {
|
|
child_status.push(compare_section(source, emacs_child, rust_section)?);
|
|
}
|
|
};
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_paragraph<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Paragraph<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "paragraph";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_object(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_plain_list<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s PlainList<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "plain-list";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_plain_list_item(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_plain_list_item<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s PlainListItem<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "item";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_greater_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s GreaterBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = match rust.name.to_lowercase().as_str() {
|
|
"center" => "center-block",
|
|
"quote" => "quote-block",
|
|
_ => todo!(),
|
|
};
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_dynamic_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s DynamicBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
if assert_name(emacs, "dynamic-block").is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: "dynamic-block".to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_footnote_definition<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s FootnoteDefinition<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "footnote-definition";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_comment<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Comment<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "comment";
|
|
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: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_drawer<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Drawer<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "drawer";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_property_drawer<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s PropertyDrawer<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "property-drawer";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
// TODO: What are node properties and are they the only legal child of property drawers?
|
|
// child_status.push(compare_element(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_table<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Table<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "table";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_table_row(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_table_row<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s TableRow<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let mut child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "table-row";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
|
child_status.push(compare_table_cell(source, emacs_child, rust_child)?);
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_table_cell<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s TableCell<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "table-cell";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_verse_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s VerseBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let children = emacs.as_list()?;
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "verse-block";
|
|
if assert_name(emacs, emacs_name).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
if assert_bounds(source, emacs, rust).is_err() {
|
|
this_status = DiffStatus::Bad;
|
|
}
|
|
|
|
for (_emacs_child, _rust_child) in children.iter().skip(2).zip(rust.children.iter()) {}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: emacs_name.to_owned(),
|
|
message: None,
|
|
children: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_comment_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s CommentBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "comment-block";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_example_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s ExampleBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "example-block";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_export_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s ExportBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "export-block";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_src_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s SrcBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "src-block";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_clock<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Clock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "clock";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_diary_sexp<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s DiarySexp<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_planning<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Planning<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "planning";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_fixed_width_area<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s FixedWidthArea<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "fixed-width";
|
|
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: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_horizontal_rule<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s HorizontalRule<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "horizontal-rule";
|
|
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: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_keyword<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Keyword<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "keyword";
|
|
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: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_latex_environment<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s LatexEnvironment<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let child_status = Vec::new();
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "latex-environment";
|
|
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: child_status,
|
|
})
|
|
}
|
|
|
|
fn compare_plain_text<'s>(
|
|
_source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s PlainText<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let mut message = None;
|
|
let text = emacs.as_text()?;
|
|
let start_ind: usize = text
|
|
.properties
|
|
.get(0)
|
|
.expect("Should have start index.")
|
|
.as_atom()?
|
|
.parse()?;
|
|
let end_ind: usize = text
|
|
.properties
|
|
.get(1)
|
|
.expect("Should have end index.")
|
|
.as_atom()?
|
|
.parse()?;
|
|
let emacs_text_length = end_ind - start_ind;
|
|
if rust.source.len() != emacs_text_length {
|
|
this_status = DiffStatus::Bad;
|
|
message = Some(format!(
|
|
"(emacs len != rust len) {:?} != {:?}",
|
|
emacs_text_length,
|
|
rust.source.len()
|
|
));
|
|
}
|
|
let unquoted_text = text.unquote()?;
|
|
if unquoted_text != rust.source {
|
|
this_status = DiffStatus::Bad;
|
|
message = Some(format!(
|
|
"(emacs != rust) {:?} != {:?}",
|
|
unquoted_text, rust.source
|
|
));
|
|
}
|
|
|
|
Ok(DiffResult {
|
|
status: this_status,
|
|
name: "plain-text".to_owned(),
|
|
message,
|
|
children: Vec::new(),
|
|
})
|
|
}
|
|
|
|
fn compare_bold<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Bold<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "bold";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_italic<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Italic<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "italic";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_underline<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Underline<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "underline";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_verbatim<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Verbatim<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "verbatim";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_code<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Code<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "code";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_strike_through<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s StrikeThrough<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "strike-through";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_regular_link<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s RegularLink<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "link";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_radio_link<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s RadioLink<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "link";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_radio_target<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s RadioTarget<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "radio-target";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_plain_link<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s PlainLink<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "link";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_angle_link<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s AngleLink<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "link";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_org_macro<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s OrgMacro<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "macro";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_entity<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Entity<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "entity";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_latex_fragment<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s LatexFragment<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "latex-fragment";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_export_snippet<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s ExportSnippet<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "export-snippet";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_footnote_reference<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s FootnoteReference<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "footnote-reference";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_citation<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Citation<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "citation";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_citation_reference<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s CitationReference<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "citation-reference";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_inline_babel_call<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s InlineBabelCall<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "inline-babel-call";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_inline_source_block<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s InlineSourceBlock<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "inline-src-block";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_line_break<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s LineBreak<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "line-break";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_target<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Target<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "target";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_statistics_cookie<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s StatisticsCookie<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "statistics-cookie";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_subscript<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Subscript<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "subscript";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_superscript<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Superscript<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "superscript";
|
|
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(),
|
|
})
|
|
}
|
|
|
|
fn compare_timestamp<'s>(
|
|
source: &'s str,
|
|
emacs: &'s Token<'s>,
|
|
rust: &'s Timestamp<'s>,
|
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
|
let mut this_status = DiffStatus::Good;
|
|
let emacs_name = "timestamp";
|
|
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(),
|
|
})
|
|
}
|