# antlr-rust-toml-parser

A TOML language parser generated by
[`antlr-rust-codegen`](https://crates.io/crates/antlr-rust-codegen) itself and
wrapped in a thin typed-value facade. The crate dogfoods the generator for its
checked-in lexer and parser, while `parse` exposes decoded keys, values,
assignments, and table headers without requiring consumers to work with the
generated recognizer directly.

## Usage

Add the parser with `cargo add antlr-rust-toml-parser`, then decode a document:

```rust
use antlr_rust_toml_parser::{Item, Value, parse};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let document = parse(
        r#"
name = "demo"
enabled = true
"#,
    )?;

    let Item::Assignment(name) = &document.items()[0] else {
        unreachable!("the first item is an assignment");
    };
    assert_eq!(name.key().as_single(), Some("name"));
    assert!(matches!(name.value(), Value::String(value) if value == "demo"));
    Ok(())
}
```

`Document` preserves assignments and table headers as flat items in source
order, which is useful for consumers that apply their own schema. Duplicate-key
and table-redefinition semantics are intentionally left to that schema layer.
