[][src]Crate bml

BML Markup Language

Based on PEG, see the interactive parser implementation at pest.rs.

BML is used by the icarus database of higan/bsnes.

Usage

This crate works on Rust stable channel. It is on crates.io and can be used by adding bml to the dependencies in your project's Cargo.toml:

[dependencies]
bml = "0.2"

Use ordered-multimap feature on Rust nightly channel:

[dependencies]
bml = { version = "0.2", features = ["ordered-multimap"] }

Examples

use std::convert::TryFrom;

use bml::BmlNode;

let root = BmlNode::try_from(concat!(
	"server\n",
	"  path: /core/www/\n",
	"  host: example.com\n",
	"  port: 80\n",
	"  service: true\n",
	"  proxy\n",
	"    host: proxy.example.com\n",
	"    port: 8080\n",
	"    authentication: plain\n",
	"  description\n",
	"    :Primary web-facing server\n",
	"    :Provides commerce-related functionality\n",
	"\n",
	"server\n",
	"  // ...\n",
	"  proxy host=\"proxy.example.com\" port=\"8080\"\n",
	"    authentication: plain\n",
)).unwrap();

let (name, node) = root.nodes().next().unwrap();

assert_eq!(name, "server");
assert_eq!(node.named("port").next().unwrap().value(), "80");

Structs

BmlError

BML parser error.

BmlNode

BML node comprising data lines() and child nodes().