ktav 0.1.3

Ktav — a plain configuration format. Three rules, zero indentation, zero quoting. Serde-native.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The crate-level entry point for parsing a `&str` into a [`Value`].

use crate::error::Error;
use crate::value::Value;

use super::parser::Parser;

/// Parse Ktav text into a [`Value`]. Iterates the input via
/// [`str::lines`] — each iteration yields a `&str` slice into the
/// original buffer, so no per-line `String` allocation occurs.
pub(crate) fn parse_str(text: &str) -> Result<Value, Error> {
    let mut parser = Parser::new();
    for (idx, line) in text.lines().enumerate() {
        parser.handle_line(line, idx + 1)?;
    }
    parser.finish()
}