Skip to main content

oak_ini/
lib.rs

1#![doc = include_str!("readme.md")]
2#![feature(new_range_api)]
3#![warn(missing_docs)]
4#![doc(html_logo_url = "https://raw.githubusercontent.com/ygg-lang/oaks/refs/heads/dev/documents/logo.svg")]
5#![doc(html_favicon_url = "https://raw.githubusercontent.com/ygg-lang/oaks/refs/heads/dev/documents/logo.svg")]
6
7/// AST module.
8pub mod ast;
9/// Builder module.
10pub mod builder;
11
12/// Type definitions module.
13/// Language configuration module.
14pub mod language;
15/// Lexer module.
16pub mod lexer;
17/// LSP module.
18#[cfg(any(feature = "lsp", feature = "oak-highlight", feature = "oak-pretty-print"))]
19pub mod lsp;
20/// MCP module.
21#[cfg(feature = "mcp")]
22pub mod mcp;
23
24/// Parser module.
25pub mod parser;
26
27pub use crate::{ast::IniRoot, builder::IniBuilder, language::IniLanguage, lexer::IniLexer, parser::IniParser};
28
29/// Parses an INI string.
30pub fn parse(ini: &str) -> Result<crate::ast::IniRoot, String> {
31    use oak_core::{Builder, parser::session::ParseSession, source::SourceText};
32    let language = IniLanguage::default();
33    let builder = IniBuilder::new(&language);
34    let source = SourceText::new(ini.to_string());
35    let mut cache = ParseSession::default();
36    let result = builder.build(&source, &[], &mut cache);
37    result.result.map_err(|e| format!("{:?}", e))
38}
39
40/// Highlighter implementation.
41#[cfg(feature = "oak-highlight")]
42pub use crate::lsp::highlighter::IniHighlighter;
43
44/// LSP implementation.
45#[cfg(feature = "lsp")]
46pub use crate::lsp::IniLanguageService;
47
48/// MCP service implementation.
49#[cfg(feature = "mcp")]
50pub use crate::mcp::serve_ini_mcp;
51pub use lexer::token_type::IniTokenType;
52pub use parser::element_type::IniElementType;