Instrument the code.

This commit is contained in:
Tom Alexander
2023-03-27 15:08:29 -04:00
parent 5db4e07c99
commit a77d2655bd
6 changed files with 26 additions and 30 deletions

View File

@@ -74,6 +74,7 @@ impl<'s> Source<'s> for DocumentElement<'s> {
}
}
#[tracing::instrument(ret, level = "debug")]
#[allow(dead_code)]
pub fn document(input: &str) -> Res<&str, Document> {
let initial_context: ContextTree<'_, '_> = ContextTree::new();
@@ -82,7 +83,8 @@ pub fn document(input: &str) -> Res<&str, Document> {
let section_matcher = parser_with_context!(section)(&document_context);
let heading_matcher = parser_with_context!(heading)(&document_context);
let (remaining, zeroth_section) = opt(section_matcher)(input)?;
let (remaining, children) = many0(heading_matcher)(remaining)?;
// let (remaining, children) = many0(heading_matcher)(remaining)?;
let children = Vec::new();
let source = get_consumed(input, remaining);
Ok((
remaining,
@@ -94,6 +96,7 @@ pub fn document(input: &str) -> Res<&str, Document> {
))
}
#[tracing::instrument(ret, level = "debug")]
fn section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Section<'s>> {
// TODO: The zeroth section is specialized so it probably needs its own parser
let parser_context = context
@@ -112,11 +115,13 @@ fn section<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Sec
Ok((remaining, Section { source, children }))
}
#[tracing::instrument(ret, level = "debug")]
fn section_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
let headline_matcher = parser_with_context!(headline)(context);
alt((recognize(headline_matcher), eof))(input)
}
#[tracing::instrument(ret, level = "debug")]
fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Heading<'s>> {
not(|i| context.check_exit_matcher(i))(input)?;
let (remaining, (star_count, _ws, title, _ws2)) = headline(context, input)?;
@@ -141,6 +146,7 @@ fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Hea
))
}
#[tracing::instrument(ret, level = "debug")]
fn headline<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
@@ -162,6 +168,7 @@ fn headline<'r, 's>(
Ok((remaining, (star_count, ws, title, ws2)))
}
#[tracing::instrument(ret, level = "debug")]
fn headline_end<'r, 's>(_context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
alt((line_ending, eof))(input)
}

View File

@@ -108,6 +108,7 @@ pub fn non_whitespace_character(input: &str) -> Res<&str, char> {
}
/// Check that we are at the start of a line
#[tracing::instrument(ret, level = "debug")]
pub fn exit_matcher_parser<'r, 's>(
context: Context<'r, 's>,
input: &'s str,