9 releases

0.1.0 May 19, 2024
0.0.7 May 27, 2023
0.0.2 Apr 24, 2023

#372 in Parser implementations

Download history 5/week @ 2024-03-31 141/week @ 2024-05-19 2/week @ 2024-05-26

606 downloads per month

EUPL-1.2

450KB
9K SLoC

A PDDL 3.1 parser, strongly typed

A parser for the Planning Domain Definition Language version 3.1: written in Rust, based on nom.

GitHub Workflow Status codecov docs.rs Crates.io Crates.io

Crate documentation is available on docs.rs/pddl.

[dependencies]
pddl = "*"

The domain/problem types can be used independently of the parser; the parser is however enabled by default via the parser crate feature. To disable the parser and its dependencies, use

[dependencies]
pddl = { version = "*", default-features = false }

Documentation comments are assembled from the PDDL papers and nergmada/planning-wiki.

Usage Example

See tests/briefcase_world.rs for the full example.

use pddl::{Problem, Parser};

pub const BRIEFCASE_WORLD_PROBLEM: &'static str = r#"
    (define (problem get-paid)
        (:domain briefcase-world)
        (:init (place home) (place office)                  ; place types
               (object p) (object d) (object b)             ; object types
               (at B home) (at P home) (at D home) (in P))  ; setup
        (:goal (and (at B office) (at D office) (at P home)))
    )
    "#;

fn main() {
    let problem = Problem::from_str(BRIEFCASE_WORLD_PROBLEM).unwrap();

    assert_eq!(problem.name(), "get-paid");
    assert_eq!(problem.domain(), "briefcase-world");
    assert!(problem.requirements().is_empty());
    assert_eq!(problem.init().len(), 9);
    assert_eq!(problem.goal().len(), 3);
}

Caveat Emptor

At this point the parser supports all domain and problem definition elements required to fully describe a PDDL 3.1 environment. However, since types and enum variants are named closely to the underlying BNF descriptions (see below), they may be a bit unwieldy to use still.

Supported Elements

Parsers were implemented based on the BNF elements listed in the paper:

"Complete BNF description of PDDL 3.1 (completely corrected)", Daniel L. Kovacs

See ELEMENTS.md for a graph of BNF elements.

Dependencies

~0–365KB