Skip to main content

pddl_core/parsers/durative/
interval.rs

1//! Provides parsers for intervals (`<interval>`).
2
3use crate::parsers::error::R;
4use crate::parsers::sexpr::Node;
5use crate::parsers::word;
6use crate::types::durative::interval::names;
7use crate::types::Interval;
8
9/// Parses an interval (`<interval>`), ignoring case.
10pub(crate) fn parse_interval(node: &Node) -> R<Interval> {
11    word(node, &[(names::ALL, Interval::All)])
12}
13
14crate::parsers::impl_parser!(Interval => parse_interval);
15
16#[cfg(test)]
17mod tests {
18    use crate::parsers::UnwrapValue;
19    use crate::{Interval, Parser};
20    use assert2::check;
21
22    #[test]
23    fn test_parse() {
24        check!(Interval::from_str("all").is_value(Interval::All));
25        check!(Interval::from_str("any").is_err());
26        check!(Interval::from_str("(all)").is_err());
27    }
28}