#![doc = include_str!("readme.md")]
#![feature(new_range_api)]
#![doc(html_logo_url = "https://raw.githubusercontent.com/ygg-lang/oaks/refs/heads/dev/documents/logo.svg")]
#![doc(html_favicon_url = "https://raw.githubusercontent.com/ygg-lang/oaks/refs/heads/dev/documents/logo.svg")]
#![warn(missing_docs)]
pub mod ast;
pub mod builder;
pub mod language;
pub mod lexer;
#[cfg(any(feature = "lsp", feature = "oak-highlight", feature = "oak-pretty-print"))]
pub mod lsp;
#[cfg(feature = "mcp")]
pub mod mcp;
pub mod parser;
pub use crate::{
ast::ProtobufRoot,
builder::ProtobufBuilder,
language::ProtobufLanguage,
lexer::token_type::ProtobufTokenType,
parser::ProtobufParser,
};
#[cfg(feature = "lsp")]
pub use crate::lsp::ProtobufLanguageService;
pub use parser::element_type::ProtobufElementType;
pub fn parse(protobuf: &str) -> Result<crate::ast::ProtobufRoot, String> {
use oak_core::{Builder, parser::session::ParseSession, source::SourceText};
let language = ProtobufLanguage::default();
let builder = ProtobufBuilder::new(&language);
let source = SourceText::new(protobuf.to_string());
let mut cache = ParseSession::default();
let result = builder.build(&source, &[], &mut cache);
result.result.map_err(|e| format!("{:?}", e))
}