From ad27f34620e3532e19c91ce2cffe1c7d0954fb07 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 21 Apr 2023 19:21:42 -0400 Subject: [PATCH] Add parsers for inactive timestamp range duration and inactive timestamp. --- src/parser/clock.rs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/parser/clock.rs b/src/parser/clock.rs index 5b71e01..d15e69a 100644 --- a/src/parser/clock.rs +++ b/src/parser/clock.rs @@ -1,7 +1,15 @@ use nom::branch::alt; +use nom::bytes::complete::is_not; +use nom::bytes::complete::tag; use nom::bytes::complete::tag_no_case; +use nom::character::complete::digit1; +use nom::character::complete::line_ending; use nom::character::complete::space0; use nom::character::complete::space1; +use nom::combinator::eof; +use nom::combinator::recognize; +use nom::combinator::verify; +use nom::sequence::tuple; use super::Context; use crate::error::Res; @@ -35,10 +43,30 @@ fn inactive_timestamp_range_duration<'r, 's>( context: Context<'r, 's>, input: &'s str, ) -> Res<&'s str, &'s str> { - todo!() + recognize(tuple(( + tag("["), + is_not("\r\n]"), + tag("]--["), + is_not("\r\n]"), + tag("]"), + space1, + tag("=>"), + space1, + digit1, + tag(":"), + verify(digit1, |mm: &str| mm.len() == 2), + space0, + alt((line_ending, eof)), + )))(input) } #[tracing::instrument(ret, level = "debug")] fn inactive_timestamp<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { - todo!() + recognize(tuple(( + tag("["), + is_not("\r\n]"), + tag("]"), + space0, + alt((line_ending, eof)), + )))(input) }