Rename nom context to parser context.

This commit is contained in:
Tom Alexander 2022-12-18 02:16:28 -05:00
parent 279b9dceb4
commit 6352f92ebc
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
4 changed files with 12 additions and 12 deletions

View File

@ -1,5 +1,5 @@
use super::nom_context::ContextElement; use super::parser_context::ContextElement;
use super::nom_context::PreviousElementNode; use super::parser_context::PreviousElementNode;
use super::token::Token; use super::token::Token;
use super::Context; use super::Context;
use nom::error::ErrorKind; use nom::error::ErrorKind;

View File

@ -1,10 +1,10 @@
mod combinator; mod combinator;
mod error; mod error;
mod list; mod list;
mod nom_context; mod parser_context;
mod parser_with_context; mod parser_with_context;
mod text; mod text;
mod text_element_parser; mod text_element_parser;
mod token; mod token;
pub use text_element_parser::document; pub use text_element_parser::document;
type Context<'r, 's> = &'r nom_context::ContextTree<'r, 's>; type Context<'r, 's> = &'r parser_context::ContextTree<'r, 's>;

View File

@ -6,10 +6,10 @@ use super::combinator::context_many1;
use super::combinator::context_many_till; use super::combinator::context_many_till;
use super::error::CustomError; use super::error::CustomError;
use super::error::MyError; use super::error::MyError;
use super::nom_context::ChainBehavior; use super::parser_context::ChainBehavior;
use super::nom_context::ContextElement; use super::parser_context::ContextElement;
use super::nom_context::ContextTree; use super::parser_context::ContextTree;
use super::nom_context::ExitMatcherNode; use super::parser_context::ExitMatcherNode;
use super::text::bold_end; use super::text::bold_end;
use super::text::bold_start; use super::text::bold_start;
use super::text::line_break; use super::text::line_break;
@ -206,13 +206,13 @@ fn flat_text_element<'s, 'r>(
fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> { fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> {
let bold_start = parser_with_context!(context_bold_start)(&context); let bold_start = parser_with_context!(context_bold_start)(&context);
let nom_context = context let parser_context = context
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { .with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
exit_matcher: ChainBehavior::AndParent(Some(&context_bold_end)), exit_matcher: ChainBehavior::AndParent(Some(&context_bold_end)),
})) }))
.with_additional_node(ContextElement::Context("bold")); .with_additional_node(ContextElement::Context("bold"));
let (remaining, captured) = recognize(tuple((bold_start, |i| { let (remaining, captured) = recognize(tuple((bold_start, |i| {
context_many_till(&nom_context, flat_text_element, context_bold_end)(i) context_many_till(&parser_context, flat_text_element, context_bold_end)(i)
})))(i)?; })))(i)?;
let ret = Bold { contents: captured }; let ret = Bold { contents: captured };
Ok((remaining, ret)) Ok((remaining, ret))
@ -220,13 +220,13 @@ fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<
fn flat_link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'s>> { fn flat_link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'s>> {
let link_start = parser_with_context!(context_link_start)(&context); let link_start = parser_with_context!(context_link_start)(&context);
let nom_context = context let parser_context = context
.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { .with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
exit_matcher: ChainBehavior::AndParent(Some(&context_link_end)), exit_matcher: ChainBehavior::AndParent(Some(&context_link_end)),
})) }))
.with_additional_node(ContextElement::Context("link")); .with_additional_node(ContextElement::Context("link"));
let (remaining, captured) = recognize(tuple((link_start, |i| { let (remaining, captured) = recognize(tuple((link_start, |i| {
context_many_till(&nom_context, flat_text_element, context_link_end)(i) context_many_till(&parser_context, flat_text_element, context_link_end)(i)
})))(i)?; })))(i)?;
let ret = Link { contents: captured }; let ret = Link { contents: captured };
Ok((remaining, ret)) Ok((remaining, ret))