Switch to RefContext.
This commit is contained in:
@@ -19,7 +19,7 @@ use crate::parser::Timestamp;
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
// TODO: This would be more efficient if we didn't throw away the parse result of the first half of an active/inactive date range timestamp if the parse fails (as in, the first thing active_date_range_timestamp parses is a active_timestamp but then we throw that away if it doesn't turn out to be a full active_date_range_timestamp despite the active_timestamp parse being completely valid). I am going with the simplest/cleanest approach for the first implementation.
|
||||
@@ -37,7 +37,7 @@ pub fn timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn diary_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("<%%(")(input)?;
|
||||
@@ -57,7 +57,7 @@ fn diary_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn sexp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let parser_context =
|
||||
@@ -79,7 +79,7 @@ fn sexp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn sexp_end<'r, 's>(
|
||||
_context: Context<'r, 's>,
|
||||
_context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
alt((tag(")>"), recognize(one_of(">\n"))))(input)
|
||||
@@ -87,7 +87,7 @@ fn sexp_end<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn active_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("<")(input)?;
|
||||
@@ -121,7 +121,7 @@ fn active_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn inactive_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("[")(input)?;
|
||||
@@ -155,7 +155,7 @@ fn inactive_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn active_date_range_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _first_timestamp) = active_timestamp(context, input)?;
|
||||
@@ -177,7 +177,7 @@ fn active_date_range_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn active_time_range_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("<")(input)?;
|
||||
@@ -218,7 +218,7 @@ fn active_time_range_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn inactive_date_range_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _first_timestamp) = inactive_timestamp(context, input)?;
|
||||
@@ -240,7 +240,7 @@ fn inactive_date_range_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn inactive_time_range_timestamp<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||
let (remaining, _) = tag("[")(input)?;
|
||||
@@ -281,7 +281,7 @@ fn inactive_time_range_timestamp<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn date<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let (remaining, _year) = verify(digit1, |year: &OrgSource<'_>| year.len() == 4)(input)?;
|
||||
@@ -299,7 +299,7 @@ fn date<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn dayname<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let parser_context =
|
||||
@@ -321,7 +321,7 @@ fn dayname<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn dayname_end<'r, 's>(
|
||||
_context: Context<'r, 's>,
|
||||
_context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
recognize(verify(anychar, |c| {
|
||||
@@ -331,7 +331,7 @@ fn dayname_end<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn time<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let (remaining, _hour) = verify(digit1, |hour: &OrgSource<'_>| {
|
||||
@@ -347,7 +347,7 @@ fn time<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn time_rest<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let (remaining, body) = recognize(verify(
|
||||
@@ -360,7 +360,7 @@ fn time_rest<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn active_time_rest_end<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
alt((
|
||||
@@ -375,7 +375,7 @@ fn active_time_rest_end<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn inactive_time_rest_end<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
alt((
|
||||
@@ -390,7 +390,7 @@ fn inactive_time_rest_end<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn time_range_rest_end<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
// We pop off the most recent context element to get a context tree with just the active/inactive_time_rest_end exit matcher (removing this function from the exit matcher chain) because the 2nd time in the range does not end when a "-TIME" pattern is found.
|
||||
@@ -403,7 +403,7 @@ fn time_range_rest_end<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn repeater<'r, 's>(
|
||||
_context: Context<'r, 's>,
|
||||
_context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
// + for cumulative type
|
||||
@@ -419,7 +419,7 @@ fn repeater<'r, 's>(
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn warning_delay<'r, 's>(
|
||||
_context: Context<'r, 's>,
|
||||
_context: RefContext<'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
// - for all type
|
||||
|
||||
Reference in New Issue
Block a user