pybuild_parser/
lib.rs

1use std::{env, fs, path};
2
3mod entrypoint;
4mod import;
5
6/*
7__Start__
81. Ingest entrypoint path
92. Create temp directory
103. Parse entrypoint file
11
12
13__Process__
141. Read file contents of path provided
152. Find import statements
163. Process each import statement
17    1. Expand import statement into "filepath-like"
18    2. Check if "filepath-like" entry exists in HashSet
19*/
20
21#[derive(Debug)]
22pub struct Parser {
23    entrypoint: entrypoint::Entrypoint,
24    // used to store copies of files used
25    _temp_dir: path::PathBuf,
26}
27
28impl Parser {
29    pub fn new(entrypoint_path: &str) -> Parser {
30        let entrypoint = entrypoint::Entrypoint::new(entrypoint_path);
31        let _temp_dir = env::temp_dir();
32
33        Parser {
34            entrypoint,
35            _temp_dir,
36        }
37    }
38
39    pub fn parse(&self) {
40        let contents = fs::read_to_string(&self.entrypoint.file_path).unwrap();
41        let imports = import::extract_imports(&contents);
42        println!("{:?}", &imports);
43
44        for import in &imports {
45            let root = import::get_root_module(import);
46            println!("{:?}", root)
47        }
48    }
49}