Skip to main content

inf2ron/
lib.rs

1// inf2ron – parse Stranded II .inf definition files to RON
2// Copyright (C) 2025  inf2ron contributors
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17//! Parse Stranded II .inf definition files to generic RON/JSON.
18//!
19//! Format-agnostic parser: accepts **any** `key=value` syntax and
20//! **any** `xxx=start` / `xxx=end` blocks. No hardcoded block names.
21//! Classification of block contents is automatic:
22//! - All lines parse as `key=value` → `Structured { fields, sub_blocks }`
23//! - Otherwise → `Text { content }`
24//!
25//! # Example
26//!
27//! ```rust
28//! use inf2ron::InfParser;
29//!
30//! let entries = InfParser::parse_str(r#"
31//! id=9
32//! name=Meat
33//! group=food
34//! script=start
35//!   on:eat { eat 5,20,10,0; }
36//! script=end
37//! "#).unwrap();
38//! assert_eq!(entries.len(), 1);
39//! assert_eq!(entries[0].fields.get("name").unwrap()[0], "Meat");
40//! assert!(entries[0].blocks.contains_key("script"));
41//! ```
42
43pub mod cli;
44pub mod error;
45pub mod parser;
46pub mod types;
47
48pub use error::{InfError, InfResult};
49pub use parser::InfParser;
50pub use types::*;