Started switching over to a stack-based context tree with global settings.

This change should hopefully allow for matchers to have captured borrowed values, it should eliminate the use of heap-allocated reference counting on the context nodes, and it adds in a global settings struct for passing around values that do not change during parsing.
This commit is contained in:
Tom Alexander
2023-09-02 18:19:52 -04:00
parent acf1205e75
commit 66d10a7a1b
3 changed files with 171 additions and 256 deletions

View File

@@ -110,4 +110,14 @@ pub use object::Timestamp;
pub use object::Underline;
pub use object::Verbatim;
pub use source::Source;
type Context<'r, 's> = &'r parser_context::ContextTree<'r, 's>;
use self::org_source::OrgSource;
use self::parser_context::Context;
use crate::error::Res;
type RefContext<'r, 's> = &'r Context<'r, 's>;
trait ContextMatcher =
for<'r, 's> Fn(RefContext<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>;
type DynContextMatcher<'c> = dyn ContextMatcher + 'c;
trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>;
type DynMatcher<'c> = dyn Matcher + 'c;