Implement parser for inactive timestamps.

This commit is contained in:
Tom Alexander 2023-07-27 19:54:33 -04:00
parent c5f81298ba
commit b5a029e2bf
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -108,8 +108,27 @@ fn inactive_timestamp<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, Timestamp<'s>> {
not_yet_implemented()?;
todo!()
let (remaining, _) = tag("[")(input)?;
let (remaining, _date) = date(context, remaining)?;
let time_context =
context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode {
class: ExitClass::Beta,
exit_matcher: &inactive_time_rest_end,
}));
let (remaining, _time) =
opt(tuple((space1, parser_with_context!(time)(&time_context))))(remaining)?;
let (remaining, _repeater) =
opt(tuple((space1, parser_with_context!(repeater)(context))))(remaining)?;
let (remaining, _warning_delay) = opt(tuple((
space1,
parser_with_context!(warning_delay)(context),
)))(remaining)?;
let (remaining, _) = tag("]")(remaining)?;
let (remaining, _) = space0(remaining)?;
let source = get_consumed(input, remaining);
Ok((remaining, Timestamp { source }))
}
#[tracing::instrument(ret, level = "debug")]
@ -218,6 +237,18 @@ fn active_time_rest_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res
))(input)
}
#[tracing::instrument(ret, level = "debug")]
fn inactive_time_rest_end<'r, 's>(
context: Context<'r, 's>,
input: &'s str,
) -> Res<&'s str, &'s str> {
alt((
recognize(verify(anychar, |c| "]\n".contains(*c))),
parser_with_context!(repeater)(context),
parser_with_context!(warning_delay)(context),
))(input)
}
#[tracing::instrument(ret, level = "debug")]
fn repeater<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> {
// + for cumulative type