organic/src/parser/nom_context.rs

31 lines
684 B
Rust
Raw Normal View History

2022-07-16 17:27:08 -04:00
use nom::branch::alt;
2022-07-15 23:26:49 -04:00
use nom::error::VerboseError;
use nom::IResult;
2022-07-15 23:26:49 -04:00
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone)]
pub struct NomContext<F>
where
F: for<'a> FnMut(&'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>>,
{
pub fail_matcher: F,
2022-07-15 23:26:49 -04:00
/// You can't have nested bolds in org-mode
pub can_match_bold: bool,
pub can_match_link: bool,
}
2022-07-16 21:32:23 -04:00
impl<F> NomContext<F>
where
F: for<'a> FnMut(&'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>>,
{
pub fn new(fail_matcher: F) -> Self {
NomContext {
fail_matcher: fail_matcher,
can_match_bold: true,
can_match_link: true,
}
}
}