From f5a6a26c4389b7c0c74d1823a310465b50262c0b Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 15 Oct 2023 20:31:14 -0400 Subject: [PATCH] Disable the existing handling of affiliated keywords. --- src/compare/util.rs | 66 +++++++-------- src/parser/affiliated_keyword.rs | 134 +++++++++++++++---------------- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/compare/util.rs b/src/compare/util.rs index 5dcc0ed..4bfefa0 100644 --- a/src/compare/util.rs +++ b/src/compare/util.rs @@ -354,39 +354,39 @@ where let mut ret = Vec::new(); let affiliated_keywords = rust.get_affiliated_keywords(); for (rust_name, rust_value) in affiliated_keywords.keywords.iter() { - let emacs_property_name = format!(":{}", rust_name); - match rust_value { - AffiliatedKeywordValue::SingleString(rust_value) => { - let diff = compare_property_quoted_string( - source, - emacs, - rust, - emacs_property_name.as_str(), - |_| Some(*rust_value), - )?; - ret.push(diff); - } - AffiliatedKeywordValue::ListOfStrings(rust_value) => { - let diff = compare_property_list_of_quoted_string( - source, - emacs, - rust, - emacs_property_name.as_str(), - |_| Some(rust_value.iter()), - )?; - ret.push(diff); - } - AffiliatedKeywordValue::ListOfListsOfObjects(rust_value) => { - let diff = compare_property_list_of_list_of_list_of_ast_nodes( - source, - emacs, - rust, - emacs_property_name.as_str(), - |_| Some(rust_value), - )?; - ret.push(diff); - } - }; + // let emacs_property_name = format!(":{}", rust_name); + // match rust_value { + // AffiliatedKeywordValue::SingleString(rust_value) => { + // let diff = compare_property_quoted_string( + // source, + // emacs, + // rust, + // emacs_property_name.as_str(), + // |_| Some(*rust_value), + // )?; + // ret.push(diff); + // } + // AffiliatedKeywordValue::ListOfStrings(rust_value) => { + // let diff = compare_property_list_of_quoted_string( + // source, + // emacs, + // rust, + // emacs_property_name.as_str(), + // |_| Some(rust_value.iter()), + // )?; + // ret.push(diff); + // } + // AffiliatedKeywordValue::ListOfListsOfObjects(rust_value) => { + // let diff = compare_property_list_of_list_of_list_of_ast_nodes( + // source, + // emacs, + // rust, + // emacs_property_name.as_str(), + // |_| Some(rust_value), + // )?; + // ret.push(diff); + // } + // }; } Ok(ret) } diff --git a/src/parser/affiliated_keyword.rs b/src/parser/affiliated_keyword.rs index 92b59fc..27efe6a 100644 --- a/src/parser/affiliated_keyword.rs +++ b/src/parser/affiliated_keyword.rs @@ -35,75 +35,75 @@ where let mut ret = BTreeMap::new(); for kw in input { let translated_name = translate_name(global_settings, kw.key); - if is_single_string_keyword(global_settings, translated_name.as_str()) { - ret.insert( - translated_name, - AffiliatedKeywordValue::SingleString(kw.value), - ); - } else if is_list_of_single_string_keyword(global_settings, translated_name.as_str()) { - let list_of_strings = ret - .entry(translated_name) - .or_insert_with(|| AffiliatedKeywordValue::ListOfStrings(Vec::with_capacity(1))); - match list_of_strings { - AffiliatedKeywordValue::ListOfStrings(list_of_strings) - if list_of_strings.is_empty() => - { - list_of_strings.push(kw.value); - } - AffiliatedKeywordValue::ListOfStrings(list_of_strings) => { - list_of_strings.clear(); - list_of_strings.push(kw.value); - } - _ => panic!("Invalid AffiliatedKeywordValue type."), - } - } else if is_list_of_objects_keyword(global_settings, translated_name.as_str()) { - let initial_context = ContextElement::document_context(); - let initial_context = Context::new(global_settings, List::new(&initial_context)); + // if is_single_string_keyword(global_settings, translated_name.as_str()) { + // ret.insert( + // translated_name, + // AffiliatedKeywordValue::SingleString(kw.value), + // ); + // } else if is_list_of_single_string_keyword(global_settings, translated_name.as_str()) { + // let list_of_strings = ret + // .entry(translated_name) + // .or_insert_with(|| AffiliatedKeywordValue::ListOfStrings(Vec::with_capacity(1))); + // match list_of_strings { + // AffiliatedKeywordValue::ListOfStrings(list_of_strings) + // if list_of_strings.is_empty() => + // { + // list_of_strings.push(kw.value); + // } + // AffiliatedKeywordValue::ListOfStrings(list_of_strings) => { + // list_of_strings.clear(); + // list_of_strings.push(kw.value); + // } + // _ => panic!("Invalid AffiliatedKeywordValue type."), + // } + // } else if is_list_of_objects_keyword(global_settings, translated_name.as_str()) { + // let initial_context = ContextElement::document_context(); + // let initial_context = Context::new(global_settings, List::new(&initial_context)); - let (_remaining, optional_objects) = opt(all_consuming(map( - tuple(( - take_until("["), - tag("["), - map_parser( - recognize(many_till(anychar, peek(tuple((tag("]"), eof))))), - confine_context(|i| { - all_consuming(many0(parser_with_context!(standard_set_object)( - &initial_context, - )))(i) - }), - ), - tag("]"), - eof, - )), - |(_, _, objects, _, _)| objects, - )))(kw.key.into()) - .expect("Object parser should always succeed."); + // let (_remaining, optional_objects) = opt(all_consuming(map( + // tuple(( + // take_until("["), + // tag("["), + // map_parser( + // recognize(many_till(anychar, peek(tuple((tag("]"), eof))))), + // confine_context(|i| { + // all_consuming(many0(parser_with_context!(standard_set_object)( + // &initial_context, + // )))(i) + // }), + // ), + // tag("]"), + // eof, + // )), + // |(_, _, objects, _, _)| objects, + // )))(kw.key.into()) + // .expect("Object parser should always succeed."); - // TODO: This should be omitting footnote references - let (_remaining, objects) = all_consuming(many0(parser_with_context!( - standard_set_object - )(&initial_context)))(kw.value.into()) - .expect("Object parser should always succeed."); - let list_of_lists = ret.entry(translated_name).or_insert_with(|| { - AffiliatedKeywordValue::ListOfListsOfObjects(Vec::with_capacity(1)) - }); - match list_of_lists { - AffiliatedKeywordValue::ListOfListsOfObjects(list_of_lists) => { - list_of_lists.push((optional_objects, objects)); - } - _ => panic!("Invalid AffiliatedKeywordValue type."), - } - } else { - let list_of_strings = ret - .entry(translated_name) - .or_insert_with(|| AffiliatedKeywordValue::ListOfStrings(Vec::with_capacity(1))); - match list_of_strings { - AffiliatedKeywordValue::ListOfStrings(list_of_strings) => { - list_of_strings.push(kw.value); - } - _ => panic!("Invalid AffiliatedKeywordValue type."), - } - } + // // TODO: This should be omitting footnote references + // let (_remaining, objects) = all_consuming(many0(parser_with_context!( + // standard_set_object + // )(&initial_context)))(kw.value.into()) + // .expect("Object parser should always succeed."); + // let list_of_lists = ret.entry(translated_name).or_insert_with(|| { + // AffiliatedKeywordValue::ListOfListsOfObjects(Vec::with_capacity(1)) + // }); + // match list_of_lists { + // AffiliatedKeywordValue::ListOfListsOfObjects(list_of_lists) => { + // list_of_lists.push((optional_objects, objects)); + // } + // _ => panic!("Invalid AffiliatedKeywordValue type."), + // } + // } else { + // let list_of_strings = ret + // .entry(translated_name) + // .or_insert_with(|| AffiliatedKeywordValue::ListOfStrings(Vec::with_capacity(1))); + // match list_of_strings { + // AffiliatedKeywordValue::ListOfStrings(list_of_strings) => { + // list_of_strings.push(kw.value); + // } + // _ => panic!("Invalid AffiliatedKeywordValue type."), + // } + // } } AffiliatedKeywords { keywords: ret } }