bracket_parse 0.1.4

simple parser for bracketed lists with quoted and unquoted strings -- Now deprecated, favouring Gobble instead which can do everything this does much tidier
Documentation
  • Coverage
  • 10%
    3 out of 30 items documented1 out of 21 items with examples
  • Size
  • Source code size: 14.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.82 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • storyfeet/bracket_parse
    0 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • storyfeet

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);