Skip to content

Commit

Permalink
Merge pull request #21 from THCLab/feat/ast
Browse files Browse the repository at this point in the history
Expose bundle ast
  • Loading branch information
mitfik authored Dec 5, 2023
2 parents 408950a + 02e74b8 commit e37d6a4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions oca/src/facade/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use oca_bundle::state::oca::{
capture_base::CaptureBase, DynOverlay, OCABundle,
};

#[cfg(feature = "local-references")]
use std::collections::HashMap;
use std::rc::Rc;
use serde::Serialize;
Expand Down Expand Up @@ -324,6 +325,15 @@ impl Facade {
Ok(oca_file::ocafile::generate_from_ast(&oca_ast))
}

pub fn get_oca_bundle_ast(&self, said: String) -> Result<OCAAst, Vec<String>> {
let oca_bundle_steps = self.get_oca_bundle_steps(said)?;
let mut oca_ast = OCAAst::new();
for step in oca_bundle_steps {
oca_ast.commands.push(step.command);
}
Ok(oca_ast)
}

pub fn parse_oca_bundle_to_ocafile(&self, bundle: &OCABundle) -> Result<String, Vec<String>> {
let oca_ast = bundle.to_ast();
Ok(oca_file::ocafile::generate_from_ast(&oca_ast))
Expand Down

0 comments on commit e37d6a4

Please sign in to comment.