Fixing more errors.

This commit is contained in:
Tom Alexander
2023-09-03 12:45:12 -04:00
parent 0b009511ff
commit 0d438a8e0f
3 changed files with 17 additions and 8 deletions

View File

@@ -17,7 +17,6 @@ use nom::multi::many_till;
use nom::multi::separated_list1;
use nom::sequence::tuple;
use super::org_source::convert_error;
use super::org_source::OrgSource;
use super::token::AllTokensIterator;
use super::token::Token;
@@ -54,9 +53,18 @@ pub fn document(input: &str) -> Res<&str, Document> {
let initial_context = ContextElement::document_context();
let initial_context = Context::new(&global_settings, List::new(&initial_context));
let wrapped_input = OrgSource::new(input);
let (remaining, document) = _document(&initial_context, wrapped_input)
.map(|(rem, out)| (Into::<&str>::into(rem), out))
.map_err(convert_error)?;
let _foo = double_pass_document(&initial_context, wrapped_input);
todo!()
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
#[allow(dead_code)]
fn double_pass_document<'r, 's>(
context: RefContext<'_, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Document<'s>> {
let (remaining, document) =
_document(context, input).map(|(rem, out)| (Into::<&str>::into(rem), out))?;
{
// If there are radio targets in this document then we need to parse the entire document again with the knowledge of the radio targets.
let all_radio_targets: Vec<&Vec<Object<'_>>> = document
@@ -73,10 +81,9 @@ pub fn document(input: &str) -> Res<&str, Document> {
.collect();
if !all_radio_targets.is_empty() {
let parser_context = ContextElement::RadioTarget(all_radio_targets);
let parser_context = initial_context.with_additional_node(&parser_context);
let (remaining, document) = _document(&parser_context, wrapped_input)
.map(|(rem, out)| (Into::<&str>::into(rem), out))
.map_err(convert_error)?;
let parser_context = context.with_additional_node(&parser_context);
let (remaining, document) = _document(&parser_context, input)
.map(|(rem, out)| (Into::<&str>::into(rem), out))?;
return Ok((remaining.into(), document));
}
}