26 lines
731 B
Rust
26 lines
731 B
Rust
![]() |
use super::sexp::Token;
|
||
|
use crate::parser::Document;
|
||
|
|
||
|
pub fn compare_document<'s>(
|
||
|
emacs: &'s Token<'s>,
|
||
|
rust: &'s Document<'s>,
|
||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||
|
compare_document_indented(0, emacs, rust)
|
||
|
}
|
||
|
|
||
|
fn compare_document_indented<'s>(
|
||
|
indentation: usize,
|
||
|
emacs: &'s Token<'s>,
|
||
|
rust: &'s Document<'s>,
|
||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||
|
let children = emacs.as_list()?;
|
||
|
let first_child = children.first().ok_or("Should have at least one child")?;
|
||
|
let first_child_text = first_child.as_atom()?;
|
||
|
if first_child_text != "org-data" {
|
||
|
return Err("Document should correspond to an org-data cell.".into());
|
||
|
}
|
||
|
// TODO: compare the children
|
||
|
|
||
|
Ok(())
|
||
|
}
|