[][src]Crate bracket_parse

Bracket Parse

A Utility for parsing Bracketed lists and sets of strings.

It is now deprecated, as Gobble does everything it does better. This was one of my first Rust projects and it shows.

It is a relatively lazy way of parsing items from a bracketed string,

"hello(peter,dave)" is easy for it to handle, as are nested brackets.

The above will result in something like

Branch[Leaf("hello"),Branch[Leaf("peter"),Leaf("dave")]]

This is not intended super extensible right now, though contributions are welcome.

The list can also be constructed relatively simply by using chained builder type methods

use bracket_parse::{Bracket,br};
use bracket_parse::Bracket::{Leaf,Branch};
use std::str::FromStr;

let str1 = Bracket::from_str("hello(peter,dave)").unwrap();

//Standard Build method
let basic1 = Branch(vec![Leaf("hello".to_string()),
                        Branch(vec![Leaf("peter".to_string()),
                                    Leaf("dave".to_string())])]);

//Chaining Build method
let chain1 = br().sib_lf("hello")
                   .sib(br().sib_lf("peter").sib_lf("dave"));

assert_eq!(str1,basic1);
assert_eq!(str1,chain1);

It can also handle string input with escapes. Quotes are removed and the string item is considered a single Leaf value;

use bracket_parse::{Bracket,br,lf};
use std::str::FromStr;

let bk = Bracket::from_str(r#""hello" 'matt"' "and \"friends\"""#).unwrap();
let chn = br().sib_lf("hello").sib_lf("matt\"").sib_lf("and \"friends\"");
assert_eq!(bk,chn);

Re-exports

pub use tail::Tail;
pub use iter::*;

Modules

iter
tail

Enums

Bracket

Functions

br
lf