I need to parse the affiliated keywords during parsing because it relies on the global settings.

This commit is contained in:
Tom Alexander
2023-10-11 11:31:20 -04:00
parent c0e462944d
commit a5129199c7
5 changed files with 48 additions and 2 deletions

View File

@@ -1,7 +1,23 @@
use std::collections::BTreeMap;
use crate::context::GlobalSettings;
use crate::types::AffiliatedKeywordValue;
use crate::types::AffiliatedKeywords;
use crate::types::Keyword;
use crate::types::Object;
use crate::types::PlainList;
pub(crate) fn parse_affiliated_keywords<'g, 's>(
global_settings: &'g GlobalSettings<'g, 's>,
input: Vec<Keyword<'s>>,
) -> AffiliatedKeywords<'s> {
let mut ret = BTreeMap::new();
for kw in input.into_iter() {
// foo
}
AffiliatedKeywords { keywords: ret }
}
// pub struct AffiliatedKeyword<'s> {
// name: &'s str,
// }

View File

@@ -18,6 +18,7 @@ use nom::multi::many1;
use nom::multi::many_till;
use nom::sequence::tuple;
use super::affiliated_keyword::parse_affiliated_keywords;
use super::element_parser::element;
use super::keyword::affiliated_keyword;
use super::object_parser::standard_set_object;
@@ -164,7 +165,10 @@ pub(crate) fn plain_list<'b, 'g, 'r, 's>(
remaining,
PlainList {
source: source.into(),
affiliated_keywords,
affiliated_keywords: parse_affiliated_keywords(
context.get_global_settings(),
affiliated_keywords,
),
name,
list_type: first_item_list_type.expect("Plain lists require at least one element."),
children: children.into_iter().map(|(_start, item)| item).collect(),