diff --git a/parsing_handlers/src/language.rs b/parsing_handlers/src/language.rs new file mode 100644 index 0000000..8ed4c62 --- /dev/null +++ b/parsing_handlers/src/language.rs @@ -0,0 +1,10 @@ +use crate::{java::get_default_java_parsing_handlers, ParsingHandlers}; +use model::Language; + +impl From for ParsingHandlers { + fn from(language: Language) -> Self { + match language { + Language::Java => get_default_java_parsing_handlers(), + } + } +} diff --git a/parsing_handlers/src/lib.rs b/parsing_handlers/src/lib.rs index d47c234..d7a6388 100644 --- a/parsing_handlers/src/lib.rs +++ b/parsing_handlers/src/lib.rs @@ -1,28 +1,5 @@ mod java; +mod language; +mod parsing_handlers; -use java::get_default_java_parsing_handlers; -use model::Language; - -pub type ParsingHandler = fn(root: model::CSTNode) -> model::CSTNode; - -pub struct ParsingHandlers { - handlers: Vec, -} - -impl ParsingHandlers { - pub fn new(handlers: Vec) -> Self { - Self { handlers } - } - - pub fn run<'a>(&'a self, root: model::CSTNode<'a>) -> model::CSTNode<'a> { - self.handlers.iter().fold(root, |acc, handler| handler(acc)) - } -} - -impl From for ParsingHandlers { - fn from(language: Language) -> Self { - match language { - Language::Java => get_default_java_parsing_handlers(), - } - } -} +pub use parsing_handlers::{ParsingHandler, ParsingHandlers}; diff --git a/parsing_handlers/src/parsing_handlers.rs b/parsing_handlers/src/parsing_handlers.rs new file mode 100644 index 0000000..442c42a --- /dev/null +++ b/parsing_handlers/src/parsing_handlers.rs @@ -0,0 +1,17 @@ +use model::CSTNode; + +pub type ParsingHandler = fn(root: CSTNode) -> CSTNode; + +pub struct ParsingHandlers { + handlers: Vec, +} + +impl ParsingHandlers { + pub fn new(handlers: Vec) -> Self { + Self { handlers } + } + + pub fn run<'a>(&'a self, root: CSTNode<'a>) -> CSTNode<'a> { + self.handlers.iter().fold(root, |acc, handler| handler(acc)) + } +}