Ran into a lifetime issue.
This commit is contained in:
parent
5c8a064eca
commit
02d04b59db
@ -1,12 +1,16 @@
|
||||
use nom::branch::alt;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::character::complete::line_ending;
|
||||
use nom::character::complete::space1;
|
||||
use nom::combinator::eof;
|
||||
use nom::combinator::recognize;
|
||||
use nom::multi::many1_count;
|
||||
use nom::sequence::tuple;
|
||||
|
||||
use crate::parser::combinator::context_many1;
|
||||
use crate::parser::error::CustomError;
|
||||
use crate::parser::error::MyError;
|
||||
use crate::parser::object::standard_set_object;
|
||||
use crate::parser::parser_context::ChainBehavior;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
use crate::parser::parser_context::ContextTree;
|
||||
@ -82,13 +86,17 @@ fn section_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str,
|
||||
}
|
||||
|
||||
fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Heading<'s>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn headline<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
let document_root = context.get_document_root().unwrap();
|
||||
let preceding_character = get_one_before(document_root, input)
|
||||
.map(|slice| slice.chars().next())
|
||||
.flatten();
|
||||
match preceding_character {
|
||||
Some('\n') => {}
|
||||
Some(_) => {
|
||||
Some(_) => {
|
||||
// Not at start of line, cannot be a heading
|
||||
return Err(nom::Err::Error(CustomError::MyError(MyError(
|
||||
"Heading not at start of line",
|
||||
@ -98,14 +106,25 @@ fn heading<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Hea
|
||||
None => {}
|
||||
};
|
||||
|
||||
tuple((
|
||||
let parser_context =
|
||||
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
|
||||
exit_matcher: ChainBehavior::AndParent(Some(&headline_end)),
|
||||
}));
|
||||
let title_matcher = parser_with_context!(context_many1)(&parser_context);
|
||||
|
||||
let foo = tuple((
|
||||
many1_count(tag("*")),
|
||||
// standard set of objects
|
||||
space1,
|
||||
title_matcher(standard_set_object),
|
||||
))(input)?;
|
||||
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn headline_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
|
||||
line_ending(input)
|
||||
}
|
||||
|
||||
fn get_one_before<'s>(document: &'s str, current_position: &'s str) -> Option<&'s str> {
|
||||
assert!(is_slice_of(document, current_position));
|
||||
if document.as_ptr() as usize == current_position.as_ptr() as usize {
|
||||
|
@ -1,4 +1,6 @@
|
||||
use super::error::Res;
|
||||
use super::source::Source;
|
||||
use super::Context;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Object<'s> {
|
||||
@ -31,3 +33,10 @@ impl<'s> Source<'s> for Object<'s> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn standard_set_object<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, Object<'s>> {
|
||||
todo!()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user