miniconf_parser/
lib.rs

1#![deny(unsafe_code)]
2#![warn(missing_docs)]
3
4//! Pest-powered parser for the MiniConf configuration language.
5//!
6//! The crate exposes [`parse_str`] for one-shot parsing and re-exports the
7//! [`Document`], [`Section`], and [`Value`] types for downstream consumers.
8
9/// Abstract syntax tree types used to represent parsed documents.
10pub mod ast;
11/// Error types emitted by the parser.
12pub mod error;
13/// Low-level parser utilities and the generated pest machinery.
14#[allow(missing_docs)]
15pub mod parser;
16
17pub use ast::{Document, Entry, Section, Value};
18pub use error::{MiniConfError, ParseErrorKind};
19
20/// Convenience function that parses `source` into a [`Document`].
21pub fn parse_str(source: &str) -> Result<Document, MiniConfError> {
22    parser::parse_document(source)
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[test]
30    fn parses_minimal_document() {
31        let doc = parse_str("key = value\n").expect("parsed");
32        let root = doc.section("root").expect("root section");
33        assert_eq!(root.entries[0].key, "key");
34    }
35}