pub mod cli;
pub mod config;
pub mod console_utils;
pub mod diff;
pub mod input_processing;
pub mod neg_idx_vec;
pub mod parse;
pub mod render;
use anyhow::Result;
use input_processing::VectorData;
use log::{debug, info};
use parse::GrammarConfig;
use std::{fs, path::PathBuf};
pub fn generate_ast_vector_data(
path: PathBuf,
file_type: Option<&str>,
grammar_config: &GrammarConfig,
) -> Result<VectorData> {
let text = fs::read_to_string(&path)?;
let file_name = path.to_string_lossy();
debug!("Reading {} to string", file_name);
if let Some(file_type) = file_type {
info!(
"Using user-set filetype \"{}\" for {}",
file_type, file_name
);
} else {
info!("Will deduce filetype from file extension");
};
let tree = parse::parse_file(&path, file_type, grammar_config)?;
Ok(VectorData { text, tree, path })
}