figtree/
lib.rs

1//! A library to parse and work with figtree documents.
2//!
3//! Figtree is a file format designed for config files that need to be easily manipulated
4//! by real life humans.  It is made up of nodes, keys, and values, and looks a bit like
5//! this:
6//!
7//! ```text
8//! node {
9//!     "key": "value",
10//!     "multiple types": ["strings", 1, 2.0, false, !identifier],
11//!
12//!     subnodes {
13//!         "with": {"more": "key", "value": "pairs"}
14//!     }
15//! }
16//! ```
17//!
18//! The figtree library parses structures like this into documents that can be
19//! manipulated to use as an efficient configuration system.
20//!
21//! # Examples
22//! ```
23//! extern crate figtree;
24//!
25//! let mut figgy = figtree::Figtree::from_string("node { 'key': 'val' }");
26//! let config = figgy.parse().ok().expect("parsing error");
27//! let value = config.get_node("node")
28//!     .and_then(|node| node.get_attr("key"))
29//!     .and_then(|value| value.get_str())
30//!     .expect("could not obtain value");
31//! assert!(value == "val");
32//! ```
33
34#[macro_use]
35extern crate matches;
36
37mod utils;
38
39mod position;
40pub use position::Position;
41
42mod lexer;
43pub use lexer::LexToken;
44pub use lexer::LexError;
45
46mod parser;
47pub use parser::ParseError;
48
49pub mod types;
50pub use types::*;
51
52mod figtree;
53pub use figtree::Figtree;