1pub mod rust_parser;
11pub mod python_parser;
12
13#[cfg(feature = "pattern")]
14pub mod pattern;
15
16#[cfg(feature = "text-search")]
17pub mod text_search;
18
19use deagle_core::{Language, Node, Result};
20use std::path::Path;
21
22pub use rust_parser::ParseResult;
23
24pub fn parse_file(path: &Path, content: &str, language: Language) -> Result<Vec<Node>> {
26 match language {
27 Language::Rust => rust_parser::parse(path, content),
28 Language::Python => python_parser::parse(path, content),
29 _ => Ok(Vec::new()),
30 }
31}
32
33pub fn parse_file_with_edges(path: &Path, content: &str, language: Language) -> Result<ParseResult> {
35 match language {
36 Language::Rust => rust_parser::parse_with_edges(path, content),
37 Language::Python => python_parser::parse_with_edges(path, content),
38 _ => Ok(ParseResult { nodes: Vec::new(), edges: Vec::new() }),
39 }
40}
41
42pub fn parse_auto(path: &Path, content: &str) -> Result<Vec<Node>> {
44 let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");
45 let lang = Language::from_extension(ext);
46 parse_file(path, content, lang)
47}