-
Notifications
You must be signed in to change notification settings - Fork 1
/
da_symbol.rs
46 lines (40 loc) · 1.26 KB
/
da_symbol.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Provides parsers for predicates.
use crate::parsers::{parse_name, ParseResult, Span};
use crate::types::DurativeActionSymbol;
use nom::combinator::map;
/// Parses a durative action symbol, i.e. `<name>`.
///
/// ## Example
/// ```
/// # use pddl::parsers::{parse_da_symbol, preamble::*};
/// assert!(parse_da_symbol("abcde").is_value("abcde".into()));
///```
pub fn parse_da_symbol<'a, T: Into<Span<'a>>>(input: T) -> ParseResult<'a, DurativeActionSymbol> {
map(parse_name, DurativeActionSymbol::from)(input.into())
}
impl crate::parsers::Parser for DurativeActionSymbol {
type Item = DurativeActionSymbol;
/// Parses a durative action symbol.
///
/// ## Example
/// ```
/// # use pddl::{DurativeActionSymbol, Parser};
/// let (_, value) = DurativeActionSymbol::parse("abcde").unwrap();
/// assert_eq!(value, "abcde".into());
///```
///
/// ## See also
/// See [`parse_da_symbol`].
fn parse<'a, S: Into<Span<'a>>>(input: S) -> ParseResult<'a, Self::Item> {
parse_da_symbol(input)
}
}
#[cfg(test)]
mod tests {
use crate::{DurativeActionSymbol, Parser};
#[test]
fn test_parse() {
let (_, value) = DurativeActionSymbol::parse("abcde").unwrap();
assert_eq!(value, "abcde".into());
}
}