Compare commits
No commits in common. "6f0439bb6d45222e82028d7da71c6e5c68531c33" and "02af3d0081797040349037acf2740f00424aa5e7" have entirely different histories.
6f0439bb6d
...
02af3d0081
@ -1 +0,0 @@
|
|||||||
CLOCK: [2023-04-21 Fri 19:32]--[2023-04-21 Fri 19:35]
|
|
@ -1 +0,0 @@
|
|||||||
CLOCK: [2023-04-21 Fri 19:43] => 0:03
|
|
@ -1,2 +0,0 @@
|
|||||||
CLOCK: [1970-01-01 Thu 8:15-13:15otherrest +1w -1d] => 0:03
|
|
||||||
CLOCK: [1970-01-01 Thu 8:15-13:15otherrest +1w -1d]
|
|
@ -23,7 +23,6 @@ use crate::types::CheckboxType;
|
|||||||
use crate::types::Citation;
|
use crate::types::Citation;
|
||||||
use crate::types::CitationReference;
|
use crate::types::CitationReference;
|
||||||
use crate::types::Clock;
|
use crate::types::Clock;
|
||||||
use crate::types::ClockStatus;
|
|
||||||
use crate::types::Code;
|
use crate::types::Code;
|
||||||
use crate::types::Comment;
|
use crate::types::Comment;
|
||||||
use crate::types::CommentBlock;
|
use crate::types::CommentBlock;
|
||||||
@ -2098,55 +2097,16 @@ fn compare_clock<'b, 's>(
|
|||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Clock<'s>,
|
rust: &'b Clock<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let mut child_status = Vec::new();
|
let this_status = DiffStatus::Good;
|
||||||
let mut this_status = DiffStatus::Good;
|
let message = None;
|
||||||
let mut message = None;
|
|
||||||
|
|
||||||
// Compare value
|
// TODO: Compare :status :value :duration
|
||||||
let value = get_property(emacs, ":value")?;
|
|
||||||
match value {
|
|
||||||
Some(e) => {
|
|
||||||
let result = compare_ast_node(_source, e, (&rust.timestamp).into())?;
|
|
||||||
child_status.push(artificial_diff_scope("value", vec![result])?);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
value, rust.timestamp
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare duration
|
|
||||||
let duration = get_property_quoted_string(emacs, ":duration")?;
|
|
||||||
if duration.as_ref().map(String::as_str) != rust.duration {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Duration mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
duration, rust.duration
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare status
|
|
||||||
let status = get_property_unquoted_atom(emacs, ":status")?;
|
|
||||||
match (status, &rust.status) {
|
|
||||||
(Some("running"), ClockStatus::Running) => {}
|
|
||||||
(Some("closed"), ClockStatus::Closed) => {}
|
|
||||||
_ => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Status mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
status, rust.status
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(DiffResult {
|
Ok(DiffResult {
|
||||||
status: this_status,
|
status: this_status,
|
||||||
name: rust.get_elisp_name(),
|
name: rust.get_elisp_name(),
|
||||||
message,
|
message,
|
||||||
children: child_status,
|
children: Vec::new(),
|
||||||
rust_source: rust.get_source(),
|
rust_source: rust.get_source(),
|
||||||
emacs_token: emacs,
|
emacs_token: emacs,
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,23 @@
|
|||||||
use nom::branch::alt;
|
use nom::branch::alt;
|
||||||
|
use nom::bytes::complete::is_not;
|
||||||
use nom::bytes::complete::tag;
|
use nom::bytes::complete::tag;
|
||||||
use nom::bytes::complete::tag_no_case;
|
use nom::bytes::complete::tag_no_case;
|
||||||
use nom::character::complete::digit1;
|
use nom::character::complete::digit1;
|
||||||
|
use nom::character::complete::line_ending;
|
||||||
use nom::character::complete::space0;
|
use nom::character::complete::space0;
|
||||||
use nom::character::complete::space1;
|
use nom::character::complete::space1;
|
||||||
use nom::combinator::map;
|
use nom::combinator::eof;
|
||||||
use nom::combinator::opt;
|
|
||||||
use nom::combinator::recognize;
|
use nom::combinator::recognize;
|
||||||
|
use nom::combinator::verify;
|
||||||
use nom::sequence::tuple;
|
use nom::sequence::tuple;
|
||||||
|
|
||||||
use super::org_source::OrgSource;
|
use super::org_source::OrgSource;
|
||||||
use super::timestamp::inactive_date_range_timestamp;
|
|
||||||
use super::timestamp::inactive_time_range_timestamp;
|
|
||||||
use super::timestamp::inactive_timestamp;
|
|
||||||
use super::util::org_line_ending;
|
|
||||||
use crate::context::parser_with_context;
|
use crate::context::parser_with_context;
|
||||||
use crate::context::RefContext;
|
use crate::context::RefContext;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::util::get_consumed;
|
use crate::parser::util::get_consumed;
|
||||||
use crate::parser::util::start_of_line;
|
use crate::parser::util::start_of_line;
|
||||||
use crate::types::Clock;
|
use crate::types::Clock;
|
||||||
use crate::types::ClockStatus;
|
|
||||||
use crate::types::Timestamp;
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn clock<'b, 'g, 'r, 's>(
|
pub(crate) fn clock<'b, 'g, 'r, 's>(
|
||||||
@ -33,54 +29,52 @@ pub(crate) fn clock<'b, 'g, 'r, 's>(
|
|||||||
let (remaining, _clock) = tag_no_case("clock:")(remaining)?;
|
let (remaining, _clock) = tag_no_case("clock:")(remaining)?;
|
||||||
let (remaining, _gap_whitespace) = space1(remaining)?;
|
let (remaining, _gap_whitespace) = space1(remaining)?;
|
||||||
|
|
||||||
let (remaining, (timestamp, duration)) = clock_timestamp(context, remaining)?;
|
let (remaining, _timestamp_junk) = alt((
|
||||||
let (remaining, _) = tuple((space0, org_line_ending))(remaining)?;
|
parser_with_context!(inactive_timestamp_range_duration)(context),
|
||||||
|
parser_with_context!(inactive_timestamp)(context),
|
||||||
|
))(remaining)?;
|
||||||
|
|
||||||
let source = get_consumed(input, remaining);
|
let source = get_consumed(input, remaining);
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Clock {
|
Clock {
|
||||||
source: source.into(),
|
source: source.into(),
|
||||||
timestamp,
|
|
||||||
duration,
|
|
||||||
status: if duration.is_some() {
|
|
||||||
ClockStatus::Closed
|
|
||||||
} else {
|
|
||||||
ClockStatus::Running
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn clock_timestamp<'b, 'g, 'r, 's>(
|
fn inactive_timestamp_range_duration<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
_context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, (Timestamp<'s>, Option<&'s str>)> {
|
) -> Res<OrgSource<'s>, OrgSource<'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.
|
recognize(tuple((
|
||||||
alt((
|
tag("["),
|
||||||
// Order matters here. If its a date range, we need to parse the entire date range instead of just the first timestamp. If its a time range, we need to make sure thats parsed as a time range instead of as the "rest" portion of a single timestamp.
|
is_not("\r\n]"),
|
||||||
map(
|
tag("]--["),
|
||||||
parser_with_context!(inactive_time_range_timestamp)(context),
|
is_not("\r\n]"),
|
||||||
|timestamp| (timestamp, None),
|
tag("]"),
|
||||||
),
|
space1,
|
||||||
map(
|
tag("=>"),
|
||||||
tuple((
|
space1,
|
||||||
parser_with_context!(inactive_date_range_timestamp)(context),
|
digit1,
|
||||||
opt(duration),
|
tag(":"),
|
||||||
)),
|
verify(digit1, |mm: &OrgSource<'_>| mm.len() == 2),
|
||||||
|(timestamp, duration)| (timestamp, duration.map(Into::<&str>::into)),
|
space0,
|
||||||
),
|
alt((line_ending, eof)),
|
||||||
map(
|
)))(input)
|
||||||
parser_with_context!(inactive_timestamp)(context),
|
|
||||||
|timestamp| (timestamp, None),
|
|
||||||
),
|
|
||||||
))(input)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
fn duration<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||||
let (remaining, _) = tuple((tag("=>"), space1))(input)?;
|
_context: RefContext<'b, 'g, 'r, 's>,
|
||||||
let (remaining, duration) = recognize(tuple((digit1, tag(":"), digit1)))(remaining)?;
|
input: OrgSource<'s>,
|
||||||
Ok((remaining, duration))
|
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||||
|
recognize(tuple((
|
||||||
|
tag("["),
|
||||||
|
is_not("\r\n]"),
|
||||||
|
tag("]"),
|
||||||
|
space0,
|
||||||
|
alt((line_ending, eof)),
|
||||||
|
)))(input)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ fn active_timestamp<'b, 'g, 'r, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn inactive_timestamp<'b, 'g, 'r, 's>(
|
fn inactive_timestamp<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||||
@ -299,7 +299,7 @@ fn active_time_range_timestamp<'b, 'g, 'r, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||||
@ -332,7 +332,7 @@ pub(crate) fn inactive_date_range_timestamp<'b, 'g, 'r, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub(crate) fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
fn inactive_time_range_timestamp<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
) -> Res<OrgSource<'s>, Timestamp<'s>> {
|
||||||
|
@ -84,18 +84,9 @@ pub struct SrcBlock<'s> {
|
|||||||
pub contents: String,
|
pub contents: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ClockStatus {
|
|
||||||
Running,
|
|
||||||
Closed,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Clock<'s> {
|
pub struct Clock<'s> {
|
||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
pub timestamp: Timestamp<'s>,
|
|
||||||
pub duration: Option<&'s str>,
|
|
||||||
pub status: ClockStatus,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -39,7 +39,6 @@ pub use greater_element::TableRowType;
|
|||||||
pub use lesser_element::BabelCall;
|
pub use lesser_element::BabelCall;
|
||||||
pub use lesser_element::CharOffsetInLine;
|
pub use lesser_element::CharOffsetInLine;
|
||||||
pub use lesser_element::Clock;
|
pub use lesser_element::Clock;
|
||||||
pub use lesser_element::ClockStatus;
|
|
||||||
pub use lesser_element::Comment;
|
pub use lesser_element::Comment;
|
||||||
pub use lesser_element::CommentBlock;
|
pub use lesser_element::CommentBlock;
|
||||||
pub use lesser_element::DiarySexp;
|
pub use lesser_element::DiarySexp;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user