Crate figtree [] [src]

A library to parse and work with figtree documents.

Figtree is a file format designed for config files that need to be easily manipulated by real life humans. It is made up of nodes, keys, and values, and looks a bit like this:

node {
    "key": "value",
    "multiple types": ["strings", 1, 2.0, false, !identifier],

    subnodes {
        "with": {"more": "key", "value": "pairs"}
    }
}

The figtree library parses structures like this into documents that can be manipulated to use as an efficient configuration system.

Examples

extern crate figtree;

let mut figgy = figtree::Figtree::from_string("node { 'key': 'val' }");
let config = figgy.parse().ok().expect("parsing error");
let value = config.get_node("node")
    .and_then(|node| node.get_attr("key"))
    .and_then(|value| value.get_str())
    .expect("could not obtain value");
assert!(value == "val");

Reexports

pub use types::*;

Modules

types

A collection of types that define a figtree document.

Structs

Figtree

Opens, parses, and reads figtree files.

Position

Represents a position in the file

Enums

LexError

An enum representing different kinds of lexing errors

LexToken

A enum representing different kinds of lexed event

ParseError

An enum representing an error that occurs during parsing.