1#![feature(new_range_api)]
2#![doc = include_str!("readme.md")]
3#![doc(html_logo_url = "https://raw.githubusercontent.com/ygg-lang/oaks/refs/heads/dev/documents/logo.svg")]
4#![doc(html_favicon_url = "https://raw.githubusercontent.com/ygg-lang/oaks/refs/heads/dev/documents/logo.svg")]
5
6pub mod ast;
7pub mod builder;
8pub mod errors;
9pub mod formatter;
10pub mod highlighter;
11pub mod kind;
12pub mod language;
13pub mod lexer;
14#[cfg(feature = "lsp")]
15pub mod lsp;
16#[cfg(feature = "mcp-stdio")]
17pub mod mcp;
18pub mod parser;
19
20pub use crate::{
22 builder::TomlBuilder,
23 formatter::TomlFormatter,
24 highlighter::TomlHighlighter,
25 kind::{TomlSyntaxKind, TomlTokenKind},
26 language::TomlLanguage,
27 lexer::TomlLexer,
28 parser::TomlParser,
29};
30
31pub fn parse(toml: &str) -> Result<crate::ast::TomlRoot, String> {
32 use oak_core::{Builder, SourceText, parser::session::ParseSession};
33 let language = TomlLanguage::default();
34 let builder = TomlBuilder::new(&language);
35 let source = SourceText::new(toml.to_string());
36 let mut cache = ParseSession::default();
37 let result = builder.build(&source, &[], &mut cache);
38 result.result.map_err(|e| format!("{:?}", e))
39}
40
41#[cfg(feature = "lsp")]
42pub use crate::lsp::TomlLanguageService;
43
44#[cfg(feature = "mcp-stdio")]
45pub use crate::mcp::serve_toml_mcp;