59 lines
1.3 KiB
Rust
59 lines
1.3 KiB
Rust
mod cst;
|
|
mod ir;
|
|
mod name_analysis;
|
|
mod p3;
|
|
// mod unparse;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
// use crate::unparse::unparse;
|
|
use crate::cst::show_cst;
|
|
use crate::ir::compile_to_ir;
|
|
use crate::name_analysis::name_analysis;
|
|
use crate::p3::pretty_print_parse;
|
|
use clap::{Parser, Subcommand};
|
|
|
|
#[derive(Debug, Parser)]
|
|
#[command(name = "dmc")]
|
|
#[command(about = "Deimos Compiler", long_about = None)]
|
|
struct Cli {
|
|
#[command(subcommand)]
|
|
command: Commands,
|
|
}
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
enum Commands {
|
|
Cst { paths: Vec<PathBuf> },
|
|
P3 { paths: Vec<PathBuf> },
|
|
NameAnalysis { paths: Vec<PathBuf> },
|
|
Ir { paths: Vec<PathBuf> },
|
|
}
|
|
|
|
fn main() {
|
|
let args = Cli::parse();
|
|
match args.command {
|
|
Commands::Cst { paths } => {
|
|
for path in &paths {
|
|
show_cst(path);
|
|
}
|
|
}
|
|
Commands::P3 { paths } => {
|
|
for path in paths {
|
|
pretty_print_parse(&path);
|
|
}
|
|
}
|
|
Commands::NameAnalysis { paths } => {
|
|
let result = name_analysis(&paths);
|
|
if let Err(e) = result {
|
|
eprintln!("{}", e);
|
|
}
|
|
}
|
|
Commands::Ir { paths } => {
|
|
let result = compile_to_ir(&paths);
|
|
if let Err(e) = result {
|
|
eprintln!("{}", e);
|
|
}
|
|
}
|
|
}
|
|
}
|