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
47
48
49
50
51
52
53
54
55
//! The untyped syntax tree of PDDL text: atoms, parenthesized lists and
//! comments, each with its byte range in the input.
//!
//! The [`Parser`](crate::Parser) reads every input into this tree before it
//! builds the typed AST. The tree keeps what the AST doesn't: where each name
//! was written, and the comments. It suits tools that work on the text, such as
//! editors, formatters and linters.
//!
//! ## Example
//! ```
//! use pddl::syntax::{self, Kind};
//!
//! let input = "(define (domain d)) ; done";
//! let tree = syntax::read(input).unwrap();
//! let define = &tree.nodes[0];
//! assert_eq!(define.head(), Some("define"));
//! let domain = &define.children().unwrap()[1];
//! assert_eq!(&input[domain.start..=domain.end], "(domain d)");
//! assert_eq!(&input[tree.comments[0].clone()], "; done");
//! ```
use Range;
use cratesexpr;
pub use crate;
use crateParseError;
/// The top-level nodes of an input and its comments.
/// Reads `input` into a [`SyntaxTree`].
///
/// Unbalanced parentheses are no error here; [`parsers::check`](crate::parsers::check)
/// reports them.
///
/// ## Errors
///
/// Fails only if lists are nested deeper than the parser accepts.