Populate the name field on elements.

This commit is contained in:
Tom Alexander
2023-10-04 21:21:26 -04:00
parent 5b308ea76f
commit 93fe46e4e7
15 changed files with 73 additions and 28 deletions

View File

@@ -19,6 +19,7 @@ use nom::sequence::tuple;
use super::org_source::BracketDepth;
use super::org_source::OrgSource;
use super::util::get_name;
use crate::context::Matcher;
use crate::context::RefContext;
use crate::error::CustomError;
@@ -62,7 +63,7 @@ fn _filtered_keyword<'s, F: Matcher>(
remaining,
Keyword {
source: consumed_input.into(),
name: None, // TODO
name: None, // To be populated by the caller if this keyword is in a context to support affiliated keywords.
key: parsed_key.into(),
value: "".into(),
},
@@ -80,7 +81,7 @@ fn _filtered_keyword<'s, F: Matcher>(
remaining,
Keyword {
source: consumed_input.into(),
name: None, // TODO
name: None, // To be populated by the caller if this keyword is in a context to support affiliated keywords.
key: parsed_key.into(),
value: parsed_value.into(),
},
@@ -93,7 +94,9 @@ pub(crate) fn keyword<'b, 'g, 'r, 's>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Keyword<'s>> {
let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?;
filtered_keyword(regular_keyword_key)(input)
let (remaining, mut kw) = filtered_keyword(regular_keyword_key)(input)?;
kw.name = get_name(&affiliated_keywords);
Ok((remaining, kw))
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
@@ -112,7 +115,7 @@ pub(crate) fn babel_call_keyword<'b, 'g, 'r, 's>(
remaining,
BabelCall {
source: kw.source,
name: None, // TODO
name: get_name(&affiliated_keywords),
key: kw.key,
value: kw.value,
},