1#![warn(missing_docs)]
5
6use oak_ruby::{ast::RubyRoot, RubyBuilder, RubyLanguage};
7use oak_core::{Builder, TextEdit, builder::BuildOutput};
8
9pub struct RustyRubyFrontend {
11 language: RubyLanguage,
12}
13
14impl Default for RustyRubyFrontend {
15 fn default() -> Self {
16 Self::new()
17 }
18}
19
20impl RustyRubyFrontend {
21 pub fn new() -> Self {
23 Self {
24 language: RubyLanguage::new(),
25 }
26 }
27
28 pub fn parse(&self, source: &str) -> Result<RubyRoot, String> {
30 let builder = RubyBuilder::new(&self.language);
31 let edits: &[TextEdit] = &[];
32 let mut cache = oak_core::parser::ParseSession::default();
33 let output: BuildOutput<RubyLanguage> = builder.build(source, edits, &mut cache);
34 output.result.map_err(|e| e.to_string())
35 }
36}