Move the affiliated keywords parser inside the specific element parsers.
We need access to the affiliated keywords to do things like set the name of the element, and only half the element parsers are allowed to have affiliated keywords, so it makes sense to move it inside the specific parsers.
This commit is contained in:
@@ -879,6 +879,16 @@ fn compare_plain_list<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
// Compare type
|
||||
// :type is an unquoted atom of either descriptive, ordered, or unordered
|
||||
let list_type = get_property_unquoted_atom(emacs, ":type")?;
|
||||
@@ -1037,8 +1047,18 @@ fn compare_center_block<'b, 's>(
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let children = emacs.as_list()?;
|
||||
let mut child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||
@@ -1062,8 +1082,18 @@ fn compare_quote_block<'b, 's>(
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let children = emacs.as_list()?;
|
||||
let mut child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||
@@ -1090,14 +1120,24 @@ fn compare_special_block<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare type
|
||||
let special_block_type =
|
||||
get_property_quoted_string(emacs, ":type")?.ok_or("Special blocks should have a name.")?;
|
||||
if special_block_type != rust.name {
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
special_block_type, rust.name
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
// Compare type
|
||||
let special_block_type =
|
||||
get_property_quoted_string(emacs, ":type")?.ok_or("Special blocks should have a name.")?;
|
||||
if special_block_type != rust.block_type {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
special_block_type, rust.block_type
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1140,14 +1180,24 @@ fn compare_dynamic_block<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare block-name
|
||||
let block_name = get_property_quoted_string(emacs, ":block-name")?
|
||||
.ok_or("Dynamic blocks should have a name.")?;
|
||||
if block_name != rust.name {
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
block_name, rust.name
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
// Compare block-name
|
||||
let block_name = get_property_quoted_string(emacs, ":block-name")?
|
||||
.ok_or("Dynamic blocks should have a name.")?;
|
||||
if block_name != rust.block_name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
block_name, rust.block_name
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1191,6 +1241,16 @@ fn compare_footnote_definition<'b, 's>(
|
||||
let mut message = None;
|
||||
// TODO: Compare :pre-blank
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
// Compare label
|
||||
let label = get_property_quoted_string(emacs, ":label")?
|
||||
.ok_or("Footnote definitions should have a name.")?;
|
||||
@@ -1259,10 +1319,9 @@ fn compare_drawer<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare drawer-name
|
||||
let name =
|
||||
get_property_quoted_string(emacs, ":drawer-name")?.ok_or("Drawers should have a name.")?;
|
||||
if name != rust.name {
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
@@ -1270,6 +1329,17 @@ fn compare_drawer<'b, 's>(
|
||||
));
|
||||
}
|
||||
|
||||
// Compare drawer-name
|
||||
let drawer_name =
|
||||
get_property_quoted_string(emacs, ":drawer-name")?.ok_or("Drawers should have a name.")?;
|
||||
if drawer_name != rust.drawer_name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Drawer name mismatch (emacs != rust) {:?} != {:?}",
|
||||
drawer_name, rust.drawer_name
|
||||
));
|
||||
}
|
||||
|
||||
for (emacs_child, rust_child) in children.iter().skip(2).zip(rust.children.iter()) {
|
||||
child_status.push(compare_ast_node(source, emacs_child, rust_child.into())?);
|
||||
}
|
||||
@@ -1322,11 +1392,11 @@ fn compare_node_property<'b, 's>(
|
||||
// Compare key
|
||||
let key =
|
||||
get_property_quoted_string(emacs, ":key")?.ok_or("Node properties should have a key.")?;
|
||||
if key != rust.name {
|
||||
if key != rust.property_name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Key mismatch (emacs != rust) {:?} != {:?}",
|
||||
key, rust.name
|
||||
key, rust.property_name
|
||||
));
|
||||
}
|
||||
|
||||
@@ -1365,6 +1435,16 @@ fn compare_table<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
// Compare formulas
|
||||
//
|
||||
// :tblfm is either nil or a list () filled with quoted strings containing the value for any tblfm keywords at the end of the table.
|
||||
@@ -2004,11 +2084,21 @@ fn compare_diary_sexp<'b, 's>(
|
||||
emacs: &'b Token<'s>,
|
||||
rust: &'b DiarySexp<'s>,
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :value
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: rust.get_elisp_name(),
|
||||
@@ -2097,11 +2187,21 @@ fn compare_fixed_width_area<'b, 's>(
|
||||
rust: &'b FixedWidthArea<'s>,
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :value
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: rust.get_elisp_name(),
|
||||
@@ -2119,8 +2219,18 @@ fn compare_horizontal_rule<'b, 's>(
|
||||
rust: &'b HorizontalRule<'s>,
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
@@ -2142,6 +2252,16 @@ fn compare_keyword<'b, 's>(
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
let key = unquote(
|
||||
get_property(emacs, ":key")?
|
||||
.ok_or("Emacs keywords should have a :key")?
|
||||
@@ -2188,6 +2308,17 @@ fn compare_babel_call<'b, 's>(
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :call :inside-header :arguments :end-header
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
let value = unquote(
|
||||
get_property(emacs, ":value")?
|
||||
.ok_or("Emacs keywords should have a :value")?
|
||||
@@ -2218,11 +2349,21 @@ fn compare_latex_environment<'b, 's>(
|
||||
rust: &'b LatexEnvironment<'s>,
|
||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||
let child_status = Vec::new();
|
||||
let this_status = DiffStatus::Good;
|
||||
let message = None;
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let mut message = None;
|
||||
|
||||
// TODO: Compare :value
|
||||
|
||||
// Compare name
|
||||
let name = get_property_quoted_string(emacs, ":name")?;
|
||||
if name.as_ref().map(String::as_str) != rust.name {
|
||||
this_status = DiffStatus::Bad;
|
||||
message = Some(format!(
|
||||
"Name mismatch (emacs != rust) {:?} != {:?}",
|
||||
name, rust.name
|
||||
));
|
||||
}
|
||||
|
||||
Ok(DiffResult {
|
||||
status: this_status,
|
||||
name: rust.get_elisp_name(),
|
||||
|
||||
Reference in New Issue
Block a user