https://github.com/qu1x/bml
BML Markup Language
https://github.com/qu1x/bml
bml bsnes higan icarus markup-language parser pest rust-lang
Last synced: 10 months ago
JSON representation
BML Markup Language
- Host: GitHub
- URL: https://github.com/qu1x/bml
- Owner: qu1x
- Created: 2019-05-08T15:45:25.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-02-23T10:56:38.000Z (almost 3 years ago)
- Last Synced: 2025-04-10T01:06:16.310Z (10 months ago)
- Topics: bml, bsnes, higan, icarus, markup-language, parser, pest, rust-lang
- Language: Rust
- Size: 29.3 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bml
BML Markup Language
[![Build][]](https://github.com/qu1x/bml/actions/workflows/build.yml)
[![Documentation][]](https://docs.rs/bml)
[![Downloads][]](https://crates.io/crates/bml)
[![Version][]](https://crates.io/crates/bml)
[![Rust][]](https://www.rust-lang.org)
[![License][]](https://opensource.org/licenses/ISC)
[Build]: https://github.com/qu1x/bml/actions/workflows/build.yml/badge.svg
[Documentation]: https://docs.rs/bml/badge.svg
[Downloads]: https://img.shields.io/crates/d/bml.svg
[Version]: https://img.shields.io/crates/v/bml.svg
[Rust]: https://img.shields.io/badge/rust-stable-brightgreen.svg
[License]: https://img.shields.io/crates/l/bml.svg
[BML] is a simplified [XML] used as static [database], see the [grammar] using [PEG] as input for
the [pest] parser.
In contrast to its C++ [reference] implementation, this Rust implementation parses indents by
pushing them on a stack to compare them instead of counting characters (stack-based-indent) and it
allows tabulators between attributes (tabular-attributes) and between colons and multi-line data
(tabular-colon-data) supporting tabulator-based along with space-based alignments.
Syntax highlighting is trivial, see [vim-bml].
[BML]: https://news.ycombinator.com/item?id=8645591
[XML]: https://en.wikipedia.org/wiki/XML
[database]: https://github.com/ares-emulator/ares/tree/master/mia/Database
[grammar]: https://github.com/qu1x/bml/blob/main/src/bml.pest
[PEG]: https://en.wikipedia.org/wiki/Parsing_expression_grammar
[pest]: https://pest.rs/
[reference]: https://github.com/ares-emulator/ares/blob/master/nall/string/markup/bml.hpp
[vim-bml]: https://github.com/qu1x/vim-bml
## Examples
```rust
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");
```
## License
Licensed under `ISC`.
## Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the
works by you shall be licensed as above, without any additional terms or conditions.